From 95ef9409f58654551a7ff576335d3c42214007fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=E1=BA=BF=20H=C6=B0ng?= Date: Fri, 13 Dec 2024 13:22:38 +0700 Subject: [PATCH] feat(cli/hsr): add 'hsr install download' command Yeah --- vollerei/cli/hsr.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/vollerei/cli/hsr.py b/vollerei/cli/hsr.py index d1205b4..ba852a5 100644 --- a/vollerei/cli/hsr.py +++ b/vollerei/cli/hsr.py @@ -637,6 +637,55 @@ class RepairCommand(Command): progress.finish("Repairation completed.") +class InstallDownloadCommand(Command): + name = "hsr install download" + description = ( + "Downloads the latest version of the game. " + + "Note that this will not download the default voicepack (English), you need to download it manually." + ) + options = default_options + [ + option("pre-download", description="Pre-download the game if available"), + ] + + def handle(self): + callback(command=self) + pre_download = self.option("pre-download") + progress = utils.ProgressIndicator(self) + progress.start("Fetching install package information... ") + try: + game_info = State.game.get_remote_game(pre_download=pre_download) + except Exception as e: + progress.finish( + f"Fetching failed with following error: {e} \n{traceback.format_exc()}" + ) + return + progress.finish( + "Installation information fetched successfully." + ) + if not self.confirm("Do you want to download the game?"): + self.line("Download aborted.") + return + self.line("Downloading install package...") + first_pkg_out_path = None + for game_pkg in game_info.major.game_pkgs: + out_path = State.game.cache.joinpath(PurePath(game_pkg.url).name) + if not first_pkg_out_path: + first_pkg_out_path = out_path + try: + download_result = utils.download( + game_pkg.url, out_path, file_len=game_pkg.size + ) + except Exception as e: + self.line_error( + f"Couldn't download install package: {e}" + ) + return + if not download_result: + self.line_error("Download failed.") + return + self.line("Download completed.") + + class UpdateDownloadCommand(Command): name = "hsr update download" description = "Download the update for the local game if available" @@ -780,6 +829,7 @@ commands = [ ApplyUpdateArchive, GetVersionCommand, InstallCommand, + InstallDownloadCommand, PatchCommand, PatchInstallCommand, PatchTelemetryCommand,