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

Method get_cdn_manifest

legendary/core.py:1239–1268  ·  view source on GitHub ↗
(self, game, platform='Windows', disable_https=False)

Source from the content-addressed store, hash-verified

1237 return manifest_urls, base_urls, manifest_hash
1238
1239 def get_cdn_manifest(self, game, platform='Windows', disable_https=False):
1240 manifest_urls, base_urls, manifest_hash = self.get_cdn_urls(game, platform)
1241 if not manifest_urls:
1242 raise ValueError('No manifest URLs returned by API')
1243
1244 if disable_https:
1245 manifest_urls = [url.replace('https://', 'http://') for url in manifest_urls]
1246
1247 for url in manifest_urls:
1248 self.log.debug(f'Trying to download manifest from "{url}"...')
1249 try:
1250 r = self.egs.unauth_session.get(url, timeout=10.0)
1251 except Exception as e:
1252 self.log.warning(f'Unable to download manifest from "{urlparse(url).netloc}" '
1253 f'(Exception: {e!r}), trying next URL...')
1254 continue
1255
1256 if r.status_code == 200:
1257 manifest_bytes = r.content
1258 break
1259 else:
1260 self.log.warning(f'Unable to download manifest from "{urlparse(url).netloc}" '
1261 f'(status: {r.status_code}), trying next URL...')
1262 else:
1263 raise ValueError(f'Unable to get manifest from any CDN URL, last result: {r.status_code} ({r.reason})')
1264
1265 if sha1(manifest_bytes).hexdigest() != manifest_hash:
1266 raise ValueError('Manifest sha hash mismatch!')
1267
1268 return manifest_bytes, base_urls
1269
1270 def get_uri_manifest(self, uri):
1271 if uri.startswith('http'):

Callers 6

prepare_downloadMethod · 0.95
import_gameMethod · 0.95
list_filesMethod · 0.80
verify_gameMethod · 0.80
infoMethod · 0.80

Calls 1

get_cdn_urlsMethod · 0.95

Tested by

no test coverage detected