From 844453eabc7d5337282098331cb038e76f8603db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=E1=BA=BF=20H=C6=B0ng?= Date: Tue, 31 Dec 2024 01:52:01 +0700 Subject: [PATCH] fix(genshin): voicepack detection --- vollerei/cli/commands.py | 4 +++- vollerei/common/functions.py | 4 +++- vollerei/genshin/launcher/game.py | 9 ++++----- vollerei/zzz/launcher/game.py | 9 +++++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/vollerei/cli/commands.py b/vollerei/cli/commands.py index 8cc944b..4e14a02 100644 --- a/vollerei/cli/commands.py +++ b/vollerei/cli/commands.py @@ -281,7 +281,9 @@ class VoicepackUpdate(Command): progress = utils.ProgressIndicator(self) progress.start("Checking for updates... ") try: - update_diff: resource.Patch | None = State.game.get_update(pre_download=pre_download) + update_diff: resource.Patch | None = State.game.get_update( + pre_download=pre_download + ) game_info = State.game.get_remote_game(pre_download=pre_download) except Exception as e: progress.finish( diff --git a/vollerei/common/functions.py b/vollerei/common/functions.py index 2703a45..8a86c6e 100644 --- a/vollerei/common/functions.py +++ b/vollerei/common/functions.py @@ -46,7 +46,9 @@ def apply_update_archive( if isinstance(archive, py7zr.SevenZipFile): archive.reset() - def extract_files(archive: py7zr.SevenZipFile | zipfile.ZipFile, files, path: PathLike): + def extract_files( + archive: py7zr.SevenZipFile | zipfile.ZipFile, files, path: PathLike + ): if isinstance(archive, py7zr.SevenZipFile): # .7z archive archive.extract(path, files) diff --git a/vollerei/genshin/launcher/game.py b/vollerei/genshin/launcher/game.py index 161eb47..bd4ed75 100644 --- a/vollerei/genshin/launcher/game.py +++ b/vollerei/genshin/launcher/game.py @@ -272,12 +272,11 @@ class Game(GameABC): """ if not self.is_installed(): raise GameNotInstalledError("Game is not installed.") + audio_assets = self.data_folder().joinpath("StreamingAssets/AudioAssets/") + if audio_assets.joinpath("AudioPackage").is_dir(): + audio_assets = audio_assets.joinpath("AudioPackage") voicepacks = [] - for child in ( - self.data_folder() - .joinpath("StreamingAssets/AudioAssets/AudioPackage/") - .iterdir() - ): + for child in audio_assets.iterdir(): if child.resolve().is_dir(): try: voicepacks.append(VoicePackLanguage[child.name]) diff --git a/vollerei/zzz/launcher/game.py b/vollerei/zzz/launcher/game.py index e7e98c3..5f67963 100644 --- a/vollerei/zzz/launcher/game.py +++ b/vollerei/zzz/launcher/game.py @@ -224,7 +224,12 @@ class Game(GameABC): for byte in f.read(10000): match byte: case 0: - if correct and len(version_bytes[0]) > 0 and len(version_bytes[1]) > 0 and len(version_bytes[2]) > 0: + if ( + correct + and len(version_bytes[0]) > 0 + and len(version_bytes[1]) > 0 + and len(version_bytes[2]) > 0 + ): found_version = tuple( bytes_to_int(i) for i in version_bytes ) @@ -232,7 +237,7 @@ class Game(GameABC): version_bytes = [[], [], []] version_ptr = 0 correct = True - case b'.': + case b".": version_ptr += 1 if version_ptr > 2: correct = False