From d8651abeab659d66c0d77c255d5ab26f61c0255a Mon Sep 17 00:00:00 2001 From: 283375 Date: Wed, 11 Oct 2023 00:14:17 +0800 Subject: [PATCH] feat: 5.0 apk support --- andreal.py | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/andreal.py b/andreal.py index be08bf7..b6423eb 100644 --- a/andreal.py +++ b/andreal.py @@ -5,6 +5,8 @@ import sys import zipfile from pathlib import Path, PurePath +from tqdm import tqdm + from common import ArcaeaApkParser, ExtractTask, extract ROOT_OUTPUT_PATH = Path(sys.argv[0]).parent.absolute() @@ -52,12 +54,23 @@ class SongParser(ArcaeaApkParser): continue song_id = re.sub(r"^dl_", "", song_zf_path.name) - if file_pure_path.stem == "base": + if file_pure_path.stem in ["base", "1080_base"]: new_file_name_stem = song_id - elif file_pure_path.stem == "base_night": + elif file_pure_path.stem in ["1080_base_night", "base_night"]: new_file_name_stem = f"{song_id}_night" - elif file_pure_path.stem in ["0", "1", "2", "3"]: - new_file_name_stem = f"{song_id}_{file_pure_path.stem}" + elif file_pure_path.stem in [ + "0", + "1", + "2", + "3", + "1080_0", + "1080_1", + "1080_2", + "1080_3", + ]: + new_file_name_stem = ( + f"{song_id}_{file_pure_path.stem.replace('1080_', '')}" + ) else: continue @@ -69,7 +82,8 @@ class SongParser(ArcaeaApkParser): class CharParser(ArcaeaApkParser): - CHAR_RE = r"^\d*u?(_icon)?\.png$" + CHAR_RE = r"^\d+u?\.png$" + CHAR_ICON_RE = r"^\d+u?_icon\.png$" @property def OUTPUT_PATH_CHAR(self): @@ -80,23 +94,37 @@ class CharParser(ArcaeaApkParser): return ROOT_OUTPUT_PATH / "Icon" def parse(self): - char_dir_zf_path = zipfile.Path(self.zf) / "assets" / "char" + if (zipfile.Path(self.zf) / "assets" / "char" / "1080").exists(): + char_dir_zf_path = zipfile.Path(self.zf) / "assets" / "char" / "1080" + else: + char_dir_zf_path = zipfile.Path(self.zf) / "assets" / "char" char_zf_path_list = [zfp for zfp in char_dir_zf_path.iterdir() if zfp.is_file()] + char_icon_dir_zf_path = zipfile.Path(self.zf) / "assets" / "char" + char_icon_zf_path_list = [ + zfp for zfp in char_icon_dir_zf_path.iterdir() if zfp.is_file() + ] tasks = [] + for char_zf_path in char_zf_path_list: char_pure_path = PurePath(str(char_zf_path)) if not re.match(self.CHAR_RE, char_pure_path.name): continue - if "_icon" in char_pure_path.stem: - new_file_name = char_pure_path.name.replace("_icon", "") - new_file_path = self.OUTPUT_PATH_ICON / new_file_name - else: - new_file_name = char_pure_path.name - new_file_path = self.OUTPUT_PATH_CHAR / new_file_name + new_file_name = char_pure_path.name + new_file_path = self.OUTPUT_PATH_CHAR / new_file_name tasks.append(ExtractTask(char_zf_path, new_file_path)) + + for char_icon_zf_path in char_icon_zf_path_list: + char_icon_pure_path = PurePath(str(char_icon_zf_path)) + if not re.match(self.CHAR_ICON_RE, char_icon_pure_path.name): + continue + + new_file_name = char_icon_pure_path.name.replace("_icon", "") + new_file_path = self.OUTPUT_PATH_ICON / new_file_name + + tasks.append(ExtractTask(char_icon_zf_path, new_file_path)) return tasks @@ -135,5 +163,5 @@ if __name__ == "__main__": tasks = sp_tasks + cp_tasks logger.info("Extracting, please wait...") - for task in tasks: + for task in tqdm(tasks): extract(task)