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

Method import_game

legendary/core.py:1696–1762  ·  view source on GitHub ↗
(self, game: Game, app_path: str, egl_guid='', platform='Windows')

Source from the content-addressed store, hash-verified

1694 self.lgd.set_installed_game(app_name, igame)
1695
1696 def import_game(self, game: Game, app_path: str, egl_guid='', platform='Windows') -> (Manifest, InstalledGame):
1697 needs_verify = True
1698 manifest_data = None
1699
1700 # check if the game is from an EGL installation, load manifest if possible
1701 if not game.is_dlc and os.path.exists(os.path.join(app_path, '.egstore')):
1702 mf = None
1703 if not egl_guid:
1704 for f in os.listdir(os.path.join(app_path, '.egstore')):
1705 if not f.endswith('.mancpn'):
1706 continue
1707
1708 self.log.debug(f'Checking mancpn file "{f}"...')
1709 mancpn = json.load(open(os.path.join(app_path, '.egstore', f), 'rb'))
1710 if mancpn['AppName'] == game.app_name:
1711 self.log.info('Found EGL install metadata, verifying...')
1712 mf = f.replace('.mancpn', '.manifest')
1713 break
1714 else:
1715 mf = f'{egl_guid}.manifest'
1716
1717 if mf and os.path.exists(os.path.join(app_path, '.egstore', mf)):
1718 manifest_data = open(os.path.join(app_path, '.egstore', mf), 'rb').read()
1719 else:
1720 self.log.warning('.egstore folder exists but manifest file is missing, continuing as regular import...')
1721
1722 # If there's no in-progress installation assume the game doesn't need to be verified
1723 if mf and not os.path.exists(os.path.join(app_path, '.egstore', 'bps')):
1724 needs_verify = False
1725 if os.path.exists(os.path.join(app_path, '.egstore', 'Pending')):
1726 if os.listdir(os.path.join(app_path, '.egstore', 'Pending')):
1727 needs_verify = True
1728
1729 if not needs_verify:
1730 self.log.debug(f'No in-progress installation found, assuming complete...')
1731
1732 if not manifest_data:
1733 self.log.info(f'Downloading latest manifest for "{game.app_name}"')
1734 manifest_data, base_urls = self.get_cdn_manifest(game)
1735 if not game.base_urls:
1736 game.base_urls = base_urls
1737 self.lgd.set_game_meta(game.app_name, game)
1738 else:
1739 # base urls being empty isn't an issue, they'll be fetched when updating/repairing the game
1740 base_urls = game.base_urls
1741
1742 # parse and save manifest to disk for verification step of import
1743 new_manifest = self.load_manifest(manifest_data)
1744 self.lgd.save_manifest(game.app_name, manifest_data,
1745 version=new_manifest.meta.build_version, platform=platform)
1746 install_size = sum(fm.file_size for fm in new_manifest.file_manifest_list.elements)
1747
1748 prereq = None
1749 if new_manifest.meta.prereq_ids:
1750 prereq = dict(ids=new_manifest.meta.prereq_ids, name=new_manifest.meta.prereq_name,
1751 path=new_manifest.meta.prereq_path, args=new_manifest.meta.prereq_args)
1752
1753 offline = game.metadata.get('customAttributes', {}).get('CanRunOffline', {}).get('value', 'true')

Callers

nothing calls this directly

Calls 7

get_cdn_manifestMethod · 0.95
load_manifestMethod · 0.95
InstalledGameClass · 0.85
infoMethod · 0.80
set_game_metaMethod · 0.80
save_manifestMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected