From e0b4769af2a3a999d8b6537b9487e70e3389cf4e Mon Sep 17 00:00:00 2001 From: derrod Date: Tue, 28 Apr 2020 15:12:17 +0200 Subject: [PATCH] [cli/core] Add option to override platform when downloading This can be used to download Mac or 32-bit builds if desired. For example: legendary download Corydalis --platform Mac Will download the Slime Rancher macOS build. Closes #12 --- legendary/cli.py | 8 +++++++- legendary/core.py | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/legendary/cli.py b/legendary/cli.py index 3e08a12..c4a6eba 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -172,6 +172,9 @@ class LegendaryCLI: logger.error(f'Update requested for "{args.app_name}", but app not installed!') exit(1) + if args.platform_override: + args.no_install = True + game = self.core.get_game(args.app_name, update_meta=True) if not game: @@ -199,7 +202,8 @@ class LegendaryCLI: disable_patching=args.disable_patching, override_manifest=args.override_manifest, override_old_manifest=args.override_old_manifest, - override_base_url=args.override_base_url) + override_base_url=args.override_base_url, + platform_override=args.platform_override) # game is either up to date or hasn't changed, so we have nothing to do if not analysis.dl_size: @@ -372,6 +376,8 @@ def main(): help='Abort if game is not already installed (for automation)') install_parser.add_argument('--dlm-debug', dest='dlm_debug', action='store_true', help='Set download manager and worker processes\' loglevel to debug') + install_parser.add_argument('--platform', dest='platform_override', action='store', metavar='', + type=str, help='Platform override for download (disables install)') launch_parser.add_argument('--offline', dest='offline', action='store_true', default=False, help='Skip login and launch game without online authentication') diff --git a/legendary/core.py b/legendary/core.py index 23b2700..463b96b 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -302,7 +302,8 @@ class LegendaryCore: status_q: Queue = None, max_shm: int = 0, max_workers: int = 0, force: bool = False, disable_patching: bool = False, game_folder: str = '', override_manifest: str = '', override_old_manifest: str = '', - override_base_url: str = '') -> (DLManager, AnalysisResult, ManifestMeta): + override_base_url: str = '', platform_override: str = '', + ) -> (DLManager, AnalysisResult, ManifestMeta): # load old manifest old_manifest = None @@ -336,9 +337,10 @@ class LegendaryCore: new_manifest_data = f.read() else: # get latest manifest from API + platform = 'Windows' if not platform_override else platform_override m_api_r = self.egs.get_game_manifest(game.asset_info.namespace, game.asset_info.catalog_item_id, - game.app_name) + game.app_name, platform) # never seen this outside the launcher itself, but if it happens: PANIC! if len(m_api_r['elements']) > 1: