优化单位数ID

This commit is contained in:
Bennett 2025-05-10 23:10:52 +08:00
parent 374037cfea
commit 8ef9d502f1
4 changed files with 46 additions and 20 deletions

View File

@ -20,6 +20,9 @@ def parse_music_xml(file_path):
artist_elem = root.find("artistName/str")
artist_name = artist_elem.text if artist_elem is not None else "?"
version_elem = root.find("AddVersion/str")
version_name = version_elem.text if version_elem is not None else "?"
# 提取启用谱面信息(设计者 + 等级)
note_infos = []
notes_data = root.find("notesData")
@ -45,12 +48,12 @@ def parse_music_xml(file_path):
"levelshow": f"{level}{PLUS if int(level_decimal) > 6 else EMPTY}",
})
return id,music_name, artist_name, note_infos
return id,music_name, artist_name, note_infos , version_name
if __name__ == "__main__":
file_path = "/Users/bennett/Downloads/SDEZ/Package/Sinmai_Data/StreamingAssets/A000/music/music011663/Music.xml"
id,music_name, artist_name, note_infos = parse_music_xml(file_path)
id,music_name, artist_name, note_infos,version_name = parse_music_xml(file_path)
print("ID:",id)
print("音乐名称:", music_name)
print("艺术家名称:", artist_name)

View File

@ -71,6 +71,9 @@ def convert_to_simai_folder(result,output_folder):
acb_list = result[3]
awb_file = next((f for f in acb_list if f.endswith('.awb')), None)
dat_file = result[4]
versionname = result[5]
if name is None or artist is None or designers is [] or levels is [] or ma2_list is [] or acb_list is [] or awb_file is None or dat_file is None or versionname is None:
return None
convert_results = {}
for path in ma2_list:
filename = os.path.basename(path)
@ -93,7 +96,7 @@ def convert_to_simai_folder(result,output_folder):
source_folder = of
# 目标文件夹路径
target_folder = f"{npof}/{name}"
target_folder = f"{npof}/{versionname}/{name}"
# 要复制的文件列表
files_to_copy = ["bg.png", "maidata.txt", "pv.mp4", "track.mp3"]
@ -133,8 +136,11 @@ def convert_to_simai_folder(result,output_folder):
# 示例调用
if __name__ == "__main__":
res = search_music_by_id(input("ID:"))
logger.info(res)
logger.info("Converting...")
convert_to_simai_folder(res,"result")
for i in range(11822,11838):
res = search_music_by_id(str(i))
if res is None:
continue
logger.info(res)
logger.info("Converting...")
convert_to_simai_folder(res,"/Volumes/Ventoy/Converts")

View File

@ -38,26 +38,30 @@ def get_video_duration(path: Path) -> float:
return 0.0
def dat_to_mp4(dat_file: str, id: str):
""" 将 .dat 文件当作 .usm 文件处理,提取并转换为 .mp4 """
"""将 .dat 文件当作 .usm 文件处理,提取并转换为 .mp4"""
dat_path = Path(dat_file).resolve()
base_name = dat_path.stem
work_dir = Path("/Users/bennett/PJCK/CookiesChartConverter") / "work" / id
usm_path = Path(dat_file)
ivf_path = work_dir / "output" / f"{base_name}.dat" / "videos" / f"{base_name}.ivf"
usm_path = dat_path
ivf_dir = work_dir / "output" / f"{base_name}.dat" / "videos"
mp4_path = work_dir / f"{base_name}.mp4"
# 直接将 .dat 当作 .usm 文件处理
# Step 1: 提取 USM 内容
print(f"[1/3] 提取 USM 内容 ...")
extract_usm(usm_path, work_dir)
if not ivf_path.exists():
print(f"❌ 提取失败,未找到 {ivf_path.name}")
return
# Step 2: 找到第一个 .ivf 文件
ivf_files = list(ivf_dir.glob("*.ivf"))
if not ivf_files:
print(f"❌ 提取失败,未找到 .ivf 文件")
return None
ivf_path = ivf_files[0]
print(f"[2/3] 转换为 MP4 ...")
convert_ivf_to_mp4(ivf_path, mp4_path)
# Step 3: 检查视频时长
duration = get_video_duration(mp4_path)
if duration < 1.0:
print(f"⚠️ 视频时长 {duration:.2f}s 太短,跳过生成 pv.mp4")
@ -67,7 +71,6 @@ def dat_to_mp4(dat_file: str, id: str):
process_video(mp4_path, work_dir / "pv.mp4")
return mp4_path
# === 示例用法 ===
if __name__ == "__main__":
import sys

View File

@ -22,7 +22,7 @@ def search_music_by_id(search_id):
if not os.path.isfile(music_xml_path):
continue
music_id, name, artist, notes = parse_music_xml(music_xml_path)
music_id, name, artist, notes,version_name = parse_music_xml(music_xml_path)
if music_id == search_id:
logger.info(f"\n【找到曲目:{name}")
logger.info(f" ID{music_id}")
@ -46,7 +46,11 @@ def search_music_by_id(search_id):
# 曲绘(查 jacket 文件夹)
jacket_dir = os.path.join(rd, "AssetBundleImages", "jacket")
jacket_ab = f"ui_jacket_00{int(music_id)-10000}.ab"
music_num = int(music_id)
if music_num >= 10000:
jacket_ab = f"ui_jacket_{music_num - 10000:06d}.ab"
else:
jacket_ab = f"ui_jacket_{music_num:06d}.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}")
@ -63,7 +67,12 @@ def search_music_by_id(search_id):
# 音频文件SoundData
sound_dir = os.path.join(rd, "SoundData")
audio_prefix = f"music00{int(music_id)-10000}"
music_num = int(music_id)
if music_num >= 10000:
audio_prefix = f"music{music_num - 10000:06d}"
else:
audio_prefix = f"music{music_num:06d}"
audio_files = [f for f in os.listdir(sound_dir) if f.lower().startswith(audio_prefix)]
logger.info(" 音频文件:")
if audio_files:
@ -78,12 +87,17 @@ def search_music_by_id(search_id):
# 视频 dat 文件MovieData
movie_dir = os.path.join(rd, "MovieData")
dat_name = f"00{int(music_id)-10000}.dat"
music_num = int(music_id)
if music_num >= 10000:
dat_name = f"{music_num - 10000:06d}.dat"
else:
dat_name = f"{music_num:06d}.dat"
dat_path = os.path.join(movie_dir, dat_name)
logger.info(" 视频 DAT 文件:")
logger.info(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]
return [[music_id, name, artist,notes],ma2_paths,os.path.join(jacket_dir, jacket_ab),audio_lists,dat_path,version_name]
logger.error(f"\n未找到 ID 为 {search_id} 的曲目信息。")
return None