feat: 5.0 apk support
This commit is contained in:
parent
2e5b90bc85
commit
d8651abeab
54
andreal.py
54
andreal.py
@ -5,6 +5,8 @@ import sys
|
|||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
|
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
from common import ArcaeaApkParser, ExtractTask, extract
|
from common import ArcaeaApkParser, ExtractTask, extract
|
||||||
|
|
||||||
ROOT_OUTPUT_PATH = Path(sys.argv[0]).parent.absolute()
|
ROOT_OUTPUT_PATH = Path(sys.argv[0]).parent.absolute()
|
||||||
@ -52,12 +54,23 @@ class SongParser(ArcaeaApkParser):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
song_id = re.sub(r"^dl_", "", song_zf_path.name)
|
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
|
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"
|
new_file_name_stem = f"{song_id}_night"
|
||||||
elif file_pure_path.stem in ["0", "1", "2", "3"]:
|
elif file_pure_path.stem in [
|
||||||
new_file_name_stem = f"{song_id}_{file_pure_path.stem}"
|
"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:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -69,7 +82,8 @@ class SongParser(ArcaeaApkParser):
|
|||||||
|
|
||||||
|
|
||||||
class CharParser(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
|
@property
|
||||||
def OUTPUT_PATH_CHAR(self):
|
def OUTPUT_PATH_CHAR(self):
|
||||||
@ -80,23 +94,37 @@ class CharParser(ArcaeaApkParser):
|
|||||||
return ROOT_OUTPUT_PATH / "Icon"
|
return ROOT_OUTPUT_PATH / "Icon"
|
||||||
|
|
||||||
def parse(self):
|
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_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 = []
|
tasks = []
|
||||||
|
|
||||||
for char_zf_path in char_zf_path_list:
|
for char_zf_path in char_zf_path_list:
|
||||||
char_pure_path = PurePath(str(char_zf_path))
|
char_pure_path = PurePath(str(char_zf_path))
|
||||||
if not re.match(self.CHAR_RE, char_pure_path.name):
|
if not re.match(self.CHAR_RE, char_pure_path.name):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if "_icon" in char_pure_path.stem:
|
new_file_name = char_pure_path.name
|
||||||
new_file_name = char_pure_path.name.replace("_icon", "")
|
new_file_path = self.OUTPUT_PATH_CHAR / new_file_name
|
||||||
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
|
|
||||||
|
|
||||||
tasks.append(ExtractTask(char_zf_path, new_file_path))
|
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
|
return tasks
|
||||||
|
|
||||||
|
|
||||||
@ -135,5 +163,5 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
tasks = sp_tasks + cp_tasks
|
tasks = sp_tasks + cp_tasks
|
||||||
logger.info("Extracting, please wait...")
|
logger.info("Extracting, please wait...")
|
||||||
for task in tasks:
|
for task in tqdm(tasks):
|
||||||
extract(task)
|
extract(task)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user