mirror of
https://github.com/derrod/legendary.git
synced 2025-01-03 04:45:28 +00:00
[cli/core] Add flag to show non-installable games/DLCs
This primarily means titles that have to be activated on external stores such as Battlefront II which has to be installed via Origin. Addresses half of #202
This commit is contained in:
parent
6746ce85a1
commit
a80244ed37
|
@ -146,9 +146,19 @@ class LegendaryCLI:
|
||||||
games, dlc_list = self.core.get_game_and_dlc_list(
|
games, dlc_list = self.core.get_game_and_dlc_list(
|
||||||
platform_override=args.platform_override, skip_ue=not args.include_ue
|
platform_override=args.platform_override, skip_ue=not args.include_ue
|
||||||
)
|
)
|
||||||
|
# Get information for games that cannot be installed through legendary (yet), such
|
||||||
|
# as games that have to be activated on and launched through Origin.
|
||||||
|
if args.include_noasset:
|
||||||
|
na_games, na_dlcs = self.core.get_non_asset_library_items(skip_ue=not args.include_ue)
|
||||||
|
games.extend(na_games)
|
||||||
|
else:
|
||||||
|
na_dlcs = []
|
||||||
|
|
||||||
# sort games and dlc by name
|
# sort games and dlc by name
|
||||||
games = sorted(games, key=lambda x: x.app_title.lower())
|
games = sorted(games, key=lambda x: x.app_title.lower())
|
||||||
for citem_id in dlc_list.keys():
|
for citem_id in dlc_list.keys():
|
||||||
|
if citem_id in na_dlcs:
|
||||||
|
dlc_list[citem_id].extend(na_dlcs[citem_id])
|
||||||
dlc_list[citem_id] = sorted(dlc_list[citem_id], key=lambda d: d.app_title.lower())
|
dlc_list[citem_id] = sorted(dlc_list[citem_id], key=lambda d: d.app_title.lower())
|
||||||
|
|
||||||
if args.csv or args.tsv:
|
if args.csv or args.tsv:
|
||||||
|
@ -173,8 +183,12 @@ class LegendaryCLI:
|
||||||
print('\nAvailable games:')
|
print('\nAvailable games:')
|
||||||
for game in games:
|
for game in games:
|
||||||
print(f' * {game.app_title} (App name: {game.app_name} | Version: {game.app_version})')
|
print(f' * {game.app_title} (App name: {game.app_name} | Version: {game.app_version})')
|
||||||
|
if not game.app_version:
|
||||||
|
print(' ! This game has to be activated and installed through third-party store (not supported)')
|
||||||
for dlc in dlc_list[game.asset_info.catalog_item_id]:
|
for dlc in dlc_list[game.asset_info.catalog_item_id]:
|
||||||
print(f' + {dlc.app_title} (App name: {dlc.app_name} | Version: {dlc.app_version})')
|
print(f' + {dlc.app_title} (App name: {dlc.app_name} | Version: {dlc.app_version})')
|
||||||
|
if not dlc.app_version:
|
||||||
|
print(' ! This DLC is included in the game does not have to be downloaded separately')
|
||||||
|
|
||||||
print(f'\nTotal: {len(games)}')
|
print(f'\nTotal: {len(games)}')
|
||||||
|
|
||||||
|
@ -1254,6 +1268,8 @@ def main():
|
||||||
type=str, help='Override platform that games are shown for (e.g. Win32/Mac)')
|
type=str, help='Override platform that games are shown for (e.g. Win32/Mac)')
|
||||||
list_parser.add_argument('--include-ue', dest='include_ue', action='store_true',
|
list_parser.add_argument('--include-ue', dest='include_ue', action='store_true',
|
||||||
help='Also include Unreal Engine content (Engine/Marketplace) in list')
|
help='Also include Unreal Engine content (Engine/Marketplace) in list')
|
||||||
|
list_parser.add_argument('--include-non-installable', dest='include_noasset', action='store_true',
|
||||||
|
help='Include apps that are not installable (e.g. that have to be activated on Origin)')
|
||||||
list_parser.add_argument('--csv', dest='csv', action='store_true', help='List games in CSV format')
|
list_parser.add_argument('--csv', dest='csv', action='store_true', help='List games in CSV format')
|
||||||
list_parser.add_argument('--tsv', dest='tsv', action='store_true', help='List games in TSV format')
|
list_parser.add_argument('--tsv', dest='tsv', action='store_true', help='List games in TSV format')
|
||||||
list_parser.add_argument('--json', dest='json', action='store_true', help='List games in JSON format')
|
list_parser.add_argument('--json', dest='json', action='store_true', help='List games in JSON format')
|
||||||
|
|
|
@ -255,6 +255,38 @@ class LegendaryCore:
|
||||||
|
|
||||||
return _ret, _dlc
|
return _ret, _dlc
|
||||||
|
|
||||||
|
def get_non_asset_library_items(self, skip_ue=True) -> (List[Game], Dict[str, List[Game]]):
|
||||||
|
"""
|
||||||
|
Gets a list of Games without assets for installation, for instance Games delivered via
|
||||||
|
third-party stores that do not have assets for installation
|
||||||
|
|
||||||
|
:param skip_ue: Ingore Unreal Marketplace entries
|
||||||
|
:return: List of Games and DLC that do not have assets
|
||||||
|
"""
|
||||||
|
_ret = []
|
||||||
|
_dlc = defaultdict(list)
|
||||||
|
# get all the appnames we have to ignore
|
||||||
|
ignore = set(i.app_name for i in self.get_assets())
|
||||||
|
|
||||||
|
for libitem in self.egs.get_library_items():
|
||||||
|
if libitem['namespace'] == 'ue' and skip_ue:
|
||||||
|
continue
|
||||||
|
if libitem['appName'] in ignore:
|
||||||
|
continue
|
||||||
|
|
||||||
|
game = self.lgd.get_game_meta(libitem['appName'])
|
||||||
|
if not game:
|
||||||
|
eg_meta = self.egs.get_game_info(libitem['namespace'], libitem['catalogItemId'])
|
||||||
|
game = Game(app_name=libitem['appName'], app_version=None,
|
||||||
|
app_title=eg_meta['title'], asset_info=None, metadata=eg_meta)
|
||||||
|
|
||||||
|
if game.is_dlc:
|
||||||
|
_dlc[game.metadata['mainGameItem']['id']].append(game)
|
||||||
|
elif not any(i['path'] == 'mods' for i in game.metadata.get('categories', [])):
|
||||||
|
_ret.append(game)
|
||||||
|
|
||||||
|
return _ret, _dlc
|
||||||
|
|
||||||
def get_dlc_for_game(self, app_name):
|
def get_dlc_for_game(self, app_name):
|
||||||
game = self.get_game(app_name)
|
game = self.get_game(app_name)
|
||||||
if not game:
|
if not game:
|
||||||
|
@ -347,11 +379,11 @@ class LegendaryCore:
|
||||||
params.extend(shlex.split(install.launch_parameters, posix=False))
|
params.extend(shlex.split(install.launch_parameters, posix=False))
|
||||||
|
|
||||||
params.extend([
|
params.extend([
|
||||||
'-AUTH_LOGIN=unused',
|
'-AUTH_LOGIN=unused',
|
||||||
f'-AUTH_PASSWORD={game_token}',
|
f'-AUTH_PASSWORD={game_token}',
|
||||||
'-AUTH_TYPE=exchangecode',
|
'-AUTH_TYPE=exchangecode',
|
||||||
f'-epicapp={app_name}',
|
f'-epicapp={app_name}',
|
||||||
'-epicenv=Prod'])
|
'-epicenv=Prod'])
|
||||||
|
|
||||||
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.')
|
||||||
|
@ -368,10 +400,10 @@ class LegendaryCore:
|
||||||
language_code = self.language_code
|
language_code = self.language_code
|
||||||
|
|
||||||
params.extend([
|
params.extend([
|
||||||
'-EpicPortal',
|
'-EpicPortal',
|
||||||
f'-epicusername={user_name}',
|
f'-epicusername={user_name}',
|
||||||
f'-epicuserid={account_id}',
|
f'-epicuserid={account_id}',
|
||||||
f'-epiclocale={language_code}'
|
f'-epiclocale={language_code}'
|
||||||
])
|
])
|
||||||
|
|
||||||
if extra_args:
|
if extra_args:
|
||||||
|
|
Loading…
Reference in a new issue