mirror of
https://gitea.pjck.top/Cookies/CookiesChartConverter.git
synced 2025-12-14 12:56:54 +08:00
97 lines
4.0 KiB
Python
97 lines
4.0 KiB
Python
import os
|
||
from ReadOpt import parse_music_xml, level_name
|
||
|
||
# 根目录
|
||
streaming_assets = "/Users/bennett/Downloads/SDEZ/Package/Sinmai_Data/StreamingAssets"
|
||
|
||
def search_music_by_id(search_id):
|
||
for asset_dir in os.listdir(streaming_assets):
|
||
root_dir = os.path.join(streaming_assets, asset_dir)
|
||
music_dir = os.path.join(root_dir, "music")
|
||
if not os.path.isdir(music_dir):
|
||
continue
|
||
|
||
for music_subdir in os.listdir(music_dir):
|
||
sub_path = os.path.join(music_dir, music_subdir)
|
||
music_xml_path = os.path.join(sub_path, "Music.xml")
|
||
if not os.path.isfile(music_xml_path):
|
||
continue
|
||
|
||
music_id, name, artist, notes = parse_music_xml(music_xml_path)
|
||
if music_id == search_id:
|
||
print(f"\n【找到曲目:{name}】")
|
||
print(f" ID:{music_id}")
|
||
print(f" 艺术家:{artist}")
|
||
print(f" 所在分区:{asset_dir}")
|
||
print(" 谱面信息:")
|
||
for i, note in enumerate(notes):
|
||
level_str = level_name[i] if i < len(level_name) else f"Diff{i}"
|
||
print(f" - {level_str}: 定数 {note['level']} / 显示 {note['levelshow']} / 谱师 {note['designer']}")
|
||
|
||
# ma2 文件
|
||
ma2_files = [f for f in os.listdir(sub_path) if f.endswith(".ma2")]
|
||
ma2_paths = [os.path.join(sub_path, f) for f in ma2_files]
|
||
ma2_paths.sort()
|
||
if ma2_files:
|
||
print(" MA2 文件:")
|
||
for f in ma2_files:
|
||
print(f" - {os.path.join(sub_path, f)}")
|
||
else:
|
||
print(" MA2 文件:未找到")
|
||
|
||
# 曲绘(查 jacket 文件夹)
|
||
jacket_dir = os.path.join(root_dir, "AssetBundleImages", "jacket")
|
||
jacket_ab = f"ui_jacket_00{int(music_id)-10000}.ab"
|
||
alt_exts = [".png", ".jpg", ".jpeg"]
|
||
alt_jacket = next((f for f in os.listdir(jacket_dir)
|
||
if f.startswith(f"ui_jacket_{music_id}")
|
||
and os.path.splitext(f)[1].lower() in alt_exts), None)
|
||
|
||
print(" 曲绘文件:")
|
||
|
||
if os.path.exists(os.path.join(jacket_dir, jacket_ab)):
|
||
print(f" - {os.path.join(jacket_dir, jacket_ab)}")
|
||
elif alt_jacket:
|
||
print(f" - {os.path.join(jacket_dir, alt_jacket)}")
|
||
else:
|
||
print(" - 未找到")
|
||
|
||
# 音频文件(SoundData)
|
||
sound_dir = os.path.join(root_dir, "SoundData")
|
||
audio_prefix = f"music00{int(music_id)-10000}"
|
||
audio_files = [f for f in os.listdir(sound_dir) if f.lower().startswith(audio_prefix)]
|
||
print(" 音频文件:")
|
||
if audio_files:
|
||
for f in audio_files:
|
||
print(f" - {os.path.join(sound_dir, f)}")
|
||
else:
|
||
print(" - 未找到")
|
||
|
||
audio_lists = []
|
||
for f in audio_files:
|
||
audio_lists.append(os.path.join(sound_dir, f))
|
||
|
||
# 视频 dat 文件(MovieData)
|
||
movie_dir = os.path.join(root_dir, "MovieData")
|
||
dat_name = f"00{int(music_id)-10000}.dat"
|
||
dat_path = os.path.join(movie_dir, dat_name)
|
||
print(" 视频 DAT 文件:")
|
||
print(f" - {dat_path}" if os.path.exists(dat_path) else " - 未找到")
|
||
|
||
return [[music_id, name, artist,notes],ma2_paths,os.path.join(jacket_dir, jacket_ab),audio_lists,dat_path]
|
||
|
||
print(f"\n未找到 ID 为 {search_id} 的曲目信息。")
|
||
return None
|
||
|
||
|
||
|
||
|
||
if __name__ == "__main__":
|
||
target_id = input("请输入要搜索的曲目 ID:").strip()
|
||
result = search_music_by_id(target_id)
|
||
print(result)
|
||
|
||
|
||
|
||
|