mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 17:55:27 +00:00
[cli/core/models] Access namespace/catalog item id directly
This commit is contained in:
parent
999ff36667
commit
356f0f84f5
|
@ -218,7 +218,7 @@ class LegendaryCLI:
|
||||||
writer.writerow(['App name', 'App title', 'Version', 'Is DLC'])
|
writer.writerow(['App name', 'App title', 'Version', 'Is DLC'])
|
||||||
for game in games:
|
for game in games:
|
||||||
writer.writerow((game.app_name, game.app_title, game.app_version(args.platform), False))
|
writer.writerow((game.app_name, game.app_title, game.app_version(args.platform), False))
|
||||||
for dlc in dlc_list[game.asset_infos[args.platform].catalog_item_id]:
|
for dlc in dlc_list[game.catalog_item_id]:
|
||||||
writer.writerow((dlc.app_name, dlc.app_title, dlc.app_version(args.platform), True))
|
writer.writerow((dlc.app_name, dlc.app_title, dlc.app_version(args.platform), True))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ class LegendaryCLI:
|
||||||
_out = []
|
_out = []
|
||||||
for game in games:
|
for game in games:
|
||||||
_j = vars(game)
|
_j = vars(game)
|
||||||
_j['dlcs'] = [vars(dlc) for dlc in dlc_list[game.asset_infos[args.platform].catalog_item_id]]
|
_j['dlcs'] = [vars(dlc) for dlc in dlc_list[game.catalog_item_id]]
|
||||||
_out.append(_j)
|
_out.append(_j)
|
||||||
|
|
||||||
return self._print_json(_out, args.pretty_json)
|
return self._print_json(_out, args.pretty_json)
|
||||||
|
@ -243,10 +243,10 @@ class LegendaryCLI:
|
||||||
print(f' ! This game has to be installed through third-party store ({_store}, not supported)')
|
print(f' ! This game has to be installed through third-party store ({_store}, not supported)')
|
||||||
else:
|
else:
|
||||||
print(f' ! No version information (unknown cause)')
|
print(f' ! No version information (unknown cause)')
|
||||||
for dlc in dlc_list[game.asset_infos[args.platform].catalog_item_id]:
|
for dlc in dlc_list[game.catalog_item_id]:
|
||||||
print(f' + {dlc.app_title} (App name: {dlc.app_name} | Version: {dlc.app_version(args.platform)})')
|
print(f' + {dlc.app_title} (App name: {dlc.app_name} | Version: {dlc.app_version(args.platform)})')
|
||||||
if not dlc.app_version(args.platform):
|
if not dlc.app_version(args.platform):
|
||||||
print(' ! This DLC is included in the game does not have to be downloaded separately')
|
print(f' ! This DLC is either included in the base game, or not available for {args.platform}')
|
||||||
|
|
||||||
print(f'\nTotal: {len(games)}')
|
print(f'\nTotal: {len(games)}')
|
||||||
|
|
||||||
|
@ -1382,17 +1382,11 @@ class LegendaryCLI:
|
||||||
logger.info('Game not installed and offline mode enabled, cannot load manifest.')
|
logger.info('Game not installed and offline mode enabled, cannot load manifest.')
|
||||||
elif game:
|
elif game:
|
||||||
entitlements = self.core.egs.get_user_entitlements()
|
entitlements = self.core.egs.get_user_entitlements()
|
||||||
# get latest metadata and manifest
|
egl_meta = self.core.egs.get_game_info(game.namespace, game.catalog_item_id)
|
||||||
if game.asset_infos[args.platform].catalog_item_id:
|
game.metadata = egl_meta
|
||||||
egl_meta = self.core.egs.get_game_info(game.asset_infos[args.platform].namespace,
|
# Get manifest if asset exists for current platform
|
||||||
game.asset_infos[args.platform].catalog_item_id)
|
if args.platform in game.asset_infos:
|
||||||
game.metadata = egl_meta
|
|
||||||
manifest_data, _ = self.core.get_cdn_manifest(game, args.platform)
|
manifest_data, _ = self.core.get_cdn_manifest(game, args.platform)
|
||||||
else:
|
|
||||||
# Origin games do not have asset info, so fall back to info from metadata
|
|
||||||
egl_meta = self.core.egs.get_game_info(game.metadata['namespace'],
|
|
||||||
game.metadata['id'])
|
|
||||||
game.metadata = egl_meta
|
|
||||||
|
|
||||||
if game:
|
if game:
|
||||||
game_infos = info_items['game']
|
game_infos = info_items['game']
|
||||||
|
|
|
@ -473,7 +473,7 @@ class LegendaryCore:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
_, dlcs = self.get_game_and_dlc_list(update_assets=False, platform=platform)
|
_, dlcs = self.get_game_and_dlc_list(update_assets=False, platform=platform)
|
||||||
return dlcs[game.asset_infos[platform].catalog_item_id]
|
return dlcs[game.catalog_item_id]
|
||||||
|
|
||||||
def get_installed_platforms(self):
|
def get_installed_platforms(self):
|
||||||
return {i.platform for i in self._get_installed_list(False)}
|
return {i.platform for i in self._get_installed_list(False)}
|
||||||
|
@ -602,11 +602,8 @@ class LegendaryCore:
|
||||||
|
|
||||||
if install.requires_ot and not offline:
|
if install.requires_ot and not offline:
|
||||||
self.log.info('Getting ownership token.')
|
self.log.info('Getting ownership token.')
|
||||||
ovt = self.egs.get_ownership_token(game.asset_infos[install.platform].namespace,
|
ovt = self.egs.get_ownership_token(game.namespace, game.catalog_item_id)
|
||||||
game.asset_infos[install.platform].catalog_item_id)
|
ovt_path = os.path.join(self.lgd.get_tmp_path(), f'{game.namespace}{game.catalog_item_id}.ovt')
|
||||||
ovt_path = os.path.join(self.lgd.get_tmp_path(),
|
|
||||||
f'{game.asset_infos[install.platform].namespace}'
|
|
||||||
f'{game.asset_infos[install.platform].catalog_item_id}.ovt')
|
|
||||||
with open(ovt_path, 'wb') as f:
|
with open(ovt_path, 'wb') as f:
|
||||||
f.write(ovt)
|
f.write(ovt)
|
||||||
params.egl_parameters.append(f'-epicovt={ovt_path}')
|
params.egl_parameters.append(f'-epicovt={ovt_path}')
|
||||||
|
@ -995,8 +992,7 @@ class LegendaryCore:
|
||||||
return old_bytes, igame.base_urls
|
return old_bytes, igame.base_urls
|
||||||
|
|
||||||
def get_cdn_urls(self, game, platform='Windows'):
|
def get_cdn_urls(self, game, platform='Windows'):
|
||||||
m_api_r = self.egs.get_game_manifest(game.asset_infos[platform].namespace,
|
m_api_r = self.egs.get_game_manifest(game.namespace, game.catalog_item_id,
|
||||||
game.asset_infos[platform].catalog_item_id,
|
|
||||||
game.app_name, platform)
|
game.app_name, platform)
|
||||||
|
|
||||||
# never seen this outside the launcher itself, but if it happens: PANIC!
|
# never seen this outside the launcher itself, but if it happens: PANIC!
|
||||||
|
@ -1531,8 +1527,8 @@ class LegendaryCore:
|
||||||
mf.write(manifest_data)
|
mf.write(manifest_data)
|
||||||
|
|
||||||
mancpn = dict(FormatVersion=0, AppName=app_name,
|
mancpn = dict(FormatVersion=0, AppName=app_name,
|
||||||
CatalogItemId=lgd_game.asset_infos['Windows'].catalog_item_id,
|
CatalogItemId=lgd_game.catalog_item_id,
|
||||||
CatalogNamespace=lgd_game.asset_infos['Windows'].namespace)
|
CatalogNamespace=lgd_game.namespace)
|
||||||
with open(os.path.join(egstore_folder, f'{egl_game.installation_guid}.mancpn', ), 'w') as mcpnf:
|
with open(os.path.join(egstore_folder, f'{egl_game.installation_guid}.mancpn', ), 'w') as mcpnf:
|
||||||
json.dump(mancpn, mcpnf, indent=4, sort_keys=True)
|
json.dump(mancpn, mcpnf, indent=4, sort_keys=True)
|
||||||
|
|
||||||
|
|
|
@ -134,8 +134,8 @@ class EGLManifest:
|
||||||
tmp.app_version_string = igame.version
|
tmp.app_version_string = igame.version
|
||||||
tmp.base_urls = igame.base_urls
|
tmp.base_urls = igame.base_urls
|
||||||
tmp.build_label = 'Live'
|
tmp.build_label = 'Live'
|
||||||
tmp.catalog_item_id = game.asset_infos['Windows'].catalog_item_id
|
tmp.catalog_item_id = game.catalog_item_id
|
||||||
tmp.namespace = game.asset_infos['Windows'].namespace
|
tmp.namespace = game.namespace
|
||||||
tmp.display_name = igame.title
|
tmp.display_name = igame.title
|
||||||
tmp.install_location = igame.install_path
|
tmp.install_location = igame.install_path
|
||||||
tmp.install_size = igame.install_size
|
tmp.install_size = igame.install_size
|
||||||
|
|
|
@ -75,6 +75,18 @@ class Game:
|
||||||
def supports_cloud_saves(self):
|
def supports_cloud_saves(self):
|
||||||
return self.metadata and (self.metadata.get('customAttributes', {}).get('CloudSaveFolder') is not None)
|
return self.metadata and (self.metadata.get('customAttributes', {}).get('CloudSaveFolder') is not None)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def catalog_item_id(self):
|
||||||
|
if not self.metadata:
|
||||||
|
return None
|
||||||
|
return self.metadata['id']
|
||||||
|
|
||||||
|
@property
|
||||||
|
def namespace(self):
|
||||||
|
if not self.metadata:
|
||||||
|
return None
|
||||||
|
return self.metadata['namespace']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, json):
|
def from_json(cls, json):
|
||||||
tmp = cls(
|
tmp = cls(
|
||||||
|
|
Loading…
Reference in a new issue