MCPcopy
hub / github.com/legendary-gl/legendary / prepare_download

Method prepare_download

legendary/core.py:1291–1512  ·  view source on GitHub ↗
(self, game: Game, base_game: Game = None, base_path: str = '',
                         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 = '',
                         platform: str = 'Windows', file_prefix_filter: list = None,
                         file_exclude_filter: list = None, file_install_tag: list = None,
                         dl_optimizations: bool = False, dl_timeout: int = 10,
                         repair: bool = False, repair_use_latest: bool = False,
                         disable_delta: bool = False, override_delta_manifest: str = '',
                         egl_guid: str = '', preferred_cdn: str = None,
                         disable_https: bool = False, bind_ip: str = None)

Source from the content-addressed store, hash-verified

1289 return r.content if r.status_code == 200 else None
1290
1291 def prepare_download(self, game: Game, base_game: Game = None, base_path: str = '',
1292 status_q: Queue = None, max_shm: int = 0, max_workers: int = 0,
1293 force: bool = False, disable_patching: bool = False,
1294 game_folder: str = '', override_manifest: str = '',
1295 override_old_manifest: str = '', override_base_url: str = '',
1296 platform: str = 'Windows', file_prefix_filter: list = None,
1297 file_exclude_filter: list = None, file_install_tag: list = None,
1298 dl_optimizations: bool = False, dl_timeout: int = 10,
1299 repair: bool = False, repair_use_latest: bool = False,
1300 disable_delta: bool = False, override_delta_manifest: str = '',
1301 egl_guid: str = '', preferred_cdn: str = None,
1302 disable_https: bool = False, bind_ip: str = None) -> (DLManager, AnalysisResult, ManifestMeta):
1303 # load old manifest
1304 old_manifest = None
1305
1306 # load old manifest if we have one
1307 if override_old_manifest:
1308 self.log.info(f'Overriding old manifest with "{override_old_manifest}"')
1309 old_bytes, _ = self.get_uri_manifest(override_old_manifest)
1310 old_manifest = self.load_manifest(old_bytes)
1311 elif not disable_patching and not force and self.is_installed(game.app_name):
1312 old_bytes, _base_urls = self.get_installed_manifest(game.app_name)
1313 if _base_urls and not game.base_urls:
1314 game.base_urls = _base_urls
1315
1316 if not old_bytes:
1317 self.log.error(f'Could not load old manifest, patching will not work!')
1318 else:
1319 old_manifest = self.load_manifest(old_bytes)
1320
1321 base_urls = game.base_urls
1322
1323 # The EGS client uses plaintext HTTP by default for the purposes of enabling simple DNS based
1324 # CDN redirection to a (local) cache. In Legendary this will be a config option.
1325 disable_https = disable_https or self.lgd.config.getboolean('Legendary', 'disable_https', fallback=False)
1326
1327 if override_manifest:
1328 self.log.info(f'Overriding manifest with "{override_manifest}"')
1329 new_manifest_data, _base_urls = self.get_uri_manifest(override_manifest)
1330 # if override manifest has a base URL use that instead
1331 if _base_urls:
1332 base_urls = _base_urls
1333 else:
1334 new_manifest_data, base_urls = self.get_cdn_manifest(game, platform, disable_https=disable_https)
1335 # overwrite base urls in metadata with current ones to avoid using old/dead CDNs
1336 game.base_urls = base_urls
1337 # save base urls to game metadata
1338 self.lgd.set_game_meta(game.app_name, game)
1339
1340 self.log.info('Parsing game manifest...')
1341 new_manifest = self.load_manifest(new_manifest_data)
1342 self.log.debug(f'Base urls: {base_urls}')
1343 # save manifest with version name as well for testing/downgrading/etc.
1344 self.lgd.save_manifest(game.app_name, new_manifest_data,
1345 version=new_manifest.meta.build_version,
1346 platform=platform)
1347
1348 # check if we should use a delta manifest or not

Callers 1

install_gameMethod · 0.80

Calls 15

get_uri_manifestMethod · 0.95
load_manifestMethod · 0.95
is_installedMethod · 0.95
get_cdn_manifestMethod · 0.95
get_delta_manifestMethod · 0.95
get_installed_gameMethod · 0.95
run_analysisMethod · 0.95
clean_filenameFunction · 0.90
is_opt_enabledFunction · 0.90
DLManagerClass · 0.90

Tested by

no test coverage detected