Don't use base URLs from overridden manifest URLs

This commit is contained in:
Mathis Dröge 2024-11-30 18:33:50 +01:00
parent 3963382b3f
commit 1ccbffe1ad
No known key found for this signature in database
GPG key ID: 3071D4EFBB298F5F
2 changed files with 5 additions and 10 deletions

View file

@ -352,7 +352,7 @@ class LegendaryCLI:
# check if we even need to log in # check if we even need to log in
if args.override_manifest: if args.override_manifest:
logger.info(f'Loading manifest from "{args.override_manifest}"') logger.info(f'Loading manifest from "{args.override_manifest}"')
manifest_data, _ = self.core.get_uri_manifest(args.override_manifest) manifest_data = self.core.get_uri_manifest(args.override_manifest)
elif self.core.is_installed(args.app_name) and not args.force_download: elif self.core.is_installed(args.app_name) and not args.force_download:
logger.info(f'Loading installed manifest for "{args.app_name}"') logger.info(f'Loading installed manifest for "{args.app_name}"')
manifest_data, _ = self.core.get_installed_manifest(args.app_name) manifest_data, _ = self.core.get_installed_manifest(args.app_name)

View file

@ -1304,13 +1304,11 @@ class LegendaryCore:
r = self.egs.unauth_session.get(uri) r = self.egs.unauth_session.get(uri)
r.raise_for_status() r.raise_for_status()
new_manifest_data = r.content new_manifest_data = r.content
base_urls = [r.url.rpartition('/')[0]]
else: else:
base_urls = []
with open(uri, 'rb') as f: with open(uri, 'rb') as f:
new_manifest_data = f.read() new_manifest_data = f.read()
return new_manifest_data, base_urls return new_manifest_data
def get_delta_manifest(self, base_url, old_build_id, new_build_id): def get_delta_manifest(self, base_url, old_build_id, new_build_id):
"""Get optimized delta manifest (doesn't seem to exist for most games)""" """Get optimized delta manifest (doesn't seem to exist for most games)"""
@ -1338,7 +1336,7 @@ class LegendaryCore:
# load old manifest if we have one # load old manifest if we have one
if override_old_manifest: if override_old_manifest:
self.log.info(f'Overriding old manifest with "{override_old_manifest}"') self.log.info(f'Overriding old manifest with "{override_old_manifest}"')
old_bytes, _ = self.get_uri_manifest(override_old_manifest) old_bytes = self.get_uri_manifest(override_old_manifest)
old_manifest = self.load_manifest(old_bytes) old_manifest = self.load_manifest(old_bytes)
elif not disable_patching and not force and self.is_installed(game.app_name): elif not disable_patching and not force and self.is_installed(game.app_name):
old_bytes, _base_urls = self.get_installed_manifest(game.app_name) old_bytes, _base_urls = self.get_installed_manifest(game.app_name)
@ -1358,10 +1356,7 @@ class LegendaryCore:
if override_manifest: if override_manifest:
self.log.info(f'Overriding manifest with "{override_manifest}"') self.log.info(f'Overriding manifest with "{override_manifest}"')
new_manifest_data, _base_urls = self.get_uri_manifest(override_manifest) new_manifest_data = self.get_uri_manifest(override_manifest)
# if override manifest has a base URL use that instead
if _base_urls:
base_urls = _base_urls
else: else:
new_manifest_data, base_urls = self.get_cdn_manifest(game, platform, disable_https=disable_https) new_manifest_data, base_urls = self.get_cdn_manifest(game, platform, disable_https=disable_https)
# overwrite base urls in metadata with current ones to avoid using old/dead CDNs # overwrite base urls in metadata with current ones to avoid using old/dead CDNs
@ -1384,7 +1379,7 @@ class LegendaryCore:
if old_manifest and new_manifest and not disable_delta: if old_manifest and new_manifest and not disable_delta:
if override_delta_manifest: if override_delta_manifest:
self.log.info(f'Overriding delta manifest with "{override_delta_manifest}"') self.log.info(f'Overriding delta manifest with "{override_delta_manifest}"')
delta_manifest_data, _ = self.get_uri_manifest(override_delta_manifest) delta_manifest_data = self.get_uri_manifest(override_delta_manifest)
else: else:
delta_manifest_data = self.get_delta_manifest(base_urls[0], delta_manifest_data = self.get_delta_manifest(base_urls[0],
old_manifest.meta.build_id, old_manifest.meta.build_id,