[cli/core] Allow bottle downloads to specify a base url

This commit is contained in:
derrod 2021-12-31 21:24:47 +01:00
parent edadf1c780
commit 05aac59836
2 changed files with 6 additions and 3 deletions

View file

@ -2240,7 +2240,8 @@ class LegendaryCLI:
return
bottle_name = clean_filename(new_name).strip()
dlm, ares, path = self.core.prepare_bottle_download(bottle_name, install_candidate['manifest'])
dlm, ares, path = self.core.prepare_bottle_download(bottle_name, install_candidate['manifest'],
base_url=install_candidate.get('base_url'))
logger.info(f'Bottle install directory: {path}')
logger.info(f'Bottle size: {ares.install_size / 1024 / 1024:.2f} MiB')

View file

@ -1839,11 +1839,13 @@ class LegendaryCore:
lgd_version_data = self.lgd.get_cached_version()
return lgd_version_data.get('data', {}).get('cx_bottles', [])
def prepare_bottle_download(self, bottle_name, manifest_url):
def prepare_bottle_download(self, bottle_name, manifest_url, base_url=None):
r = self.egs.unauth_session.get(manifest_url)
r.raise_for_status()
manifest = self.load_manifest(r.content)
base_url = manifest_url.rpartition('/')[0]
if not base_url:
base_url = manifest_url.rpartition('/')[0]
path = mac_get_bottle_path(bottle_name)
if os.path.exists(path):