feat: dump music level
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,4 +5,4 @@
|
||||
/players.redb
|
||||
/players.json*
|
||||
|
||||
/*.json
|
||||
/test.json
|
||||
36666
musicDB.json
Normal file
36666
musicDB.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ def makeMusicDBJson():
|
||||
)
|
||||
OPTION_DIR = Path("C:/MaimaiDX/SDGA-1.50-G/NoMovieData/StreamingAssets")
|
||||
|
||||
music_db: list[dict[str, str | int]] = []
|
||||
music_db: list[dict[str, str | int | list[dict[str, str | int]]]] = []
|
||||
DEST_PATH = Path("./musicDB.json")
|
||||
|
||||
dup_count = 0
|
||||
@@ -56,10 +56,56 @@ def makeMusicDBJson():
|
||||
.firstChild.data
|
||||
)
|
||||
|
||||
def handle_note(note: minidom.Element):
|
||||
if (
|
||||
"false"
|
||||
== note.getElementsByTagName("isEnable")
|
||||
.pop()
|
||||
.firstChild.data.lower()
|
||||
):
|
||||
return
|
||||
|
||||
if music_id >= 100000:
|
||||
level = 5
|
||||
else:
|
||||
level = int(
|
||||
note.getElementsByTagName("file")
|
||||
.pop()
|
||||
.getElementsByTagName("path")
|
||||
.pop()
|
||||
.firstChild.data[-5]
|
||||
)
|
||||
difficulty_int = (
|
||||
note.getElementsByTagName("level").pop().firstChild.data
|
||||
)
|
||||
difficulty_dec = (
|
||||
note.getElementsByTagName("levelDecimal").pop().firstChild.data
|
||||
)
|
||||
difficulty = f"{difficulty_int}.{difficulty_dec}"
|
||||
return level, difficulty
|
||||
|
||||
music_levels = [
|
||||
{"level": level, "difficulty": difficulty}
|
||||
for level, difficulty in filter(
|
||||
lambda d: d is not None,
|
||||
(
|
||||
handle_note(note)
|
||||
for note in data.getElementsByTagName("notesData")[
|
||||
0
|
||||
].getElementsByTagName("Notes")
|
||||
),
|
||||
)
|
||||
]
|
||||
|
||||
if music_id not in music_ids:
|
||||
music_ids.add(music_id)
|
||||
music_db.append(
|
||||
{"id": music_id, "name": music_name, "version": int(music_version)}
|
||||
{
|
||||
"id": music_id,
|
||||
"name": music_name,
|
||||
"version": int(music_version),
|
||||
"levels": music_levels,
|
||||
}
|
||||
)
|
||||
else:
|
||||
# e.g. SDEZ-only song
|
||||
@@ -68,8 +114,13 @@ def makeMusicDBJson():
|
||||
print(f"Found {len(music_db)} music data")
|
||||
print(f"Found {dup_count} duplications")
|
||||
|
||||
music_db = sorted(
|
||||
music_db,
|
||||
key=lambda m: m["id"],
|
||||
)
|
||||
|
||||
with open(DEST_PATH, "w", encoding="utf-8") as f:
|
||||
json.dump(music_db, f, ensure_ascii=False)
|
||||
json.dump(music_db, f, ensure_ascii=False, indent=4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user