ongeki: read music version from the xml
This commit is contained in:
parent
0cf41ff389
commit
ab64eea5c9
@ -27,6 +27,27 @@ class OngekiReader(BaseReader):
|
|||||||
self.logger.error(f"Invalid ongeki version {version}")
|
self.logger.error(f"Invalid ongeki version {version}")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
def parse_version(self, troot) -> int:
|
||||||
|
version_ids = {
|
||||||
|
"1000": OngekiConstants.VER_ONGEKI,
|
||||||
|
"1005": OngekiConstants.VER_ONGEKI_PLUS,
|
||||||
|
"1010": OngekiConstants.VER_ONGEKI_SUMMER,
|
||||||
|
"1015": OngekiConstants.VER_ONGEKI_SUMMER_PLUS,
|
||||||
|
"1020": OngekiConstants.VER_ONGEKI_RED,
|
||||||
|
"1025": OngekiConstants.VER_ONGEKI_RED_PLUS,
|
||||||
|
"1030": OngekiConstants.VER_ONGEKI_BRIGHT,
|
||||||
|
"1035": OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY,
|
||||||
|
"1040": OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY
|
||||||
|
}
|
||||||
|
|
||||||
|
node = troot.find("VersionID").find("id")
|
||||||
|
|
||||||
|
if node.text not in version_ids:
|
||||||
|
self.logger.warn(f"Unknown VersionID {node.text}")
|
||||||
|
return OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY
|
||||||
|
|
||||||
|
return version_ids[node.text]
|
||||||
|
|
||||||
async def read(self) -> None:
|
async def read(self) -> None:
|
||||||
data_dirs = []
|
data_dirs = []
|
||||||
if self.bin_dir is not None:
|
if self.bin_dir is not None:
|
||||||
@ -44,17 +65,6 @@ class OngekiReader(BaseReader):
|
|||||||
async def read_card(self, base_dir: str) -> None:
|
async def read_card(self, base_dir: str) -> None:
|
||||||
self.logger.info(f"Reading cards from {base_dir}...")
|
self.logger.info(f"Reading cards from {base_dir}...")
|
||||||
|
|
||||||
version_ids = {
|
|
||||||
"1000": OngekiConstants.VER_ONGEKI,
|
|
||||||
"1005": OngekiConstants.VER_ONGEKI_PLUS,
|
|
||||||
"1010": OngekiConstants.VER_ONGEKI_SUMMER,
|
|
||||||
"1015": OngekiConstants.VER_ONGEKI_SUMMER_PLUS,
|
|
||||||
"1020": OngekiConstants.VER_ONGEKI_RED,
|
|
||||||
"1025": OngekiConstants.VER_ONGEKI_RED_PLUS,
|
|
||||||
"1030": OngekiConstants.VER_ONGEKI_BRIGHT,
|
|
||||||
"1035": OngekiConstants.VER_ONGEKI_BRIGHT_MEMORY,
|
|
||||||
}
|
|
||||||
|
|
||||||
for root, dirs, files in os.walk(base_dir):
|
for root, dirs, files in os.walk(base_dir):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if os.path.exists(f"{root}/{dir}/Card.xml"):
|
if os.path.exists(f"{root}/{dir}/Card.xml"):
|
||||||
@ -92,11 +102,10 @@ class OngekiReader(BaseReader):
|
|||||||
troot.find("ChoKaikaSkillID").find("id").text
|
troot.find("ChoKaikaSkillID").find("id").text
|
||||||
)
|
)
|
||||||
|
|
||||||
version = version_ids[troot.find("VersionID").find("id").text]
|
|
||||||
card_number = troot.find("CardNumberString").text
|
card_number = troot.find("CardNumberString").text
|
||||||
|
|
||||||
await self.data.static.put_card(
|
await self.data.static.put_card(
|
||||||
version,
|
self.parse_version(troot),
|
||||||
card_id,
|
card_id,
|
||||||
name=name,
|
name=name,
|
||||||
charaId=chara_id,
|
charaId=chara_id,
|
||||||
@ -151,6 +160,7 @@ class OngekiReader(BaseReader):
|
|||||||
title = name.find("str").text
|
title = name.find("str").text
|
||||||
artist = troot.find("ArtistName").find("str").text
|
artist = troot.find("ArtistName").find("str").text
|
||||||
genre = troot.find("Genre").find("str").text
|
genre = troot.find("Genre").find("str").text
|
||||||
|
version = self.parse_version(troot)
|
||||||
|
|
||||||
fumens = troot.find("FumenData")
|
fumens = troot.find("FumenData")
|
||||||
for fumens_data in fumens.findall("FumenData"):
|
for fumens_data in fumens.findall("FumenData"):
|
||||||
@ -164,7 +174,7 @@ class OngekiReader(BaseReader):
|
|||||||
)
|
)
|
||||||
|
|
||||||
await self.data.static.put_chart(
|
await self.data.static.put_chart(
|
||||||
self.version, song_id, chart_id, title, artist, genre, level
|
version, song_id, chart_id, title, artist, genre, level
|
||||||
)
|
)
|
||||||
self.logger.info(f"Added song {song_id} chart {chart_id}")
|
self.logger.info(f"Added song {song_id} chart {chart_id}")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user