feat: dump music level

This commit is contained in:
mokurin000
2025-08-01 02:27:30 +08:00
parent 6fd7361ca1
commit 1c2a6b6161
3 changed files with 36721 additions and 4 deletions

2
.gitignore vendored
View File

@@ -5,4 +5,4 @@
/players.redb /players.redb
/players.json* /players.json*
/*.json /test.json

36666
musicDB.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -18,7 +18,7 @@ def makeMusicDBJson():
) )
OPTION_DIR = Path("C:/MaimaiDX/SDGA-1.50-G/NoMovieData/StreamingAssets") 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") DEST_PATH = Path("./musicDB.json")
dup_count = 0 dup_count = 0
@@ -56,10 +56,56 @@ def makeMusicDBJson():
.firstChild.data .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: if music_id not in music_ids:
music_ids.add(music_id) music_ids.add(music_id)
music_db.append( 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: else:
# e.g. SDEZ-only song # e.g. SDEZ-only song
@@ -68,8 +114,13 @@ def makeMusicDBJson():
print(f"Found {len(music_db)} music data") print(f"Found {len(music_db)} music data")
print(f"Found {dup_count} duplications") 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: 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__": if __name__ == "__main__":