fix(genshin): voicepack detection

This commit is contained in:
2024-12-31 01:52:01 +07:00
parent d6d1fdee6e
commit 844453eabc
4 changed files with 17 additions and 9 deletions

View File

@ -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(

View File

@ -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)

View File

@ -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])

View File

@ -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