diff --git a/legendary/cli.py b/legendary/cli.py index 1d520dd..58d6533 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -153,9 +153,15 @@ class LegendaryCLI: if not self.core.login(): logger.error('Login failed, cannot continue!') exit(1) - logger.info('Getting game list... (this may take a while)') + + if args.force_refresh: + logger.info('Refreshing game list, this may take a while...') + else: + logger.info('Getting game list... (this may take a while)') + 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, + force_refresh=args.force_refresh ) # Get information for games that cannot be installed through legendary (yet), such # as games that have to be activated on and launched through Origin. @@ -1376,6 +1382,8 @@ def main(): 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('--json', dest='json', action='store_true', help='List games in JSON format') + list_parser.add_argument('--force-refresh', dest='force_refresh', action='store_true', + help='Force a refresh of all game metadata') list_installed_parser.add_argument('--check-updates', dest='check_updates', action='store_true', help='Check for updates for installed games') diff --git a/legendary/core.py b/legendary/core.py index f5e4cfc..c40d5a6 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -307,9 +307,8 @@ class LegendaryCore: def get_game_list(self, update_assets=True) -> List[Game]: return self.get_game_and_dlc_list(update_assets=update_assets)[0] - def get_game_and_dlc_list(self, update_assets=True, - platform_override=None, - skip_ue=True) -> (List[Game], Dict[str, List[Game]]): + def get_game_and_dlc_list(self, update_assets=True, platform_override=None, + force_refresh=False, skip_ue=True) -> (List[Game], Dict[str, List[Game]]): _ret = [] _dlc = defaultdict(list) @@ -319,7 +318,7 @@ class LegendaryCore: continue game = self.lgd.get_game_meta(ga.app_name) - if update_assets and (not game or + if update_assets and (not game or force_refresh or (game and game.app_version != ga.build_version and not platform_override)): if game and game.app_version != ga.build_version and not platform_override: self.log.info(f'Updating meta for {game.app_name} due to build version mismatch') @@ -343,11 +342,13 @@ class LegendaryCore: return _ret, _dlc - def get_non_asset_library_items(self, skip_ue=True) -> (List[Game], Dict[str, List[Game]]): + def get_non_asset_library_items(self, force_refresh=False, + 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 force_refresh: Force a metadata refresh :param skip_ue: Ingore Unreal Marketplace entries :return: List of Games and DLC that do not have assets """ @@ -363,7 +364,7 @@ class LegendaryCore: continue game = self.lgd.get_game_meta(libitem['appName']) - if not game: + if not game or force_refresh: 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)