Detect games specifying "the EA app" for their ThirdPartyManagedApp as Origin games

Note that the actual title has different case for different games (e.g.
it's "the EA app" for one game, but "The EA App" for another)
This commit is contained in:
Mathis Dröge 2023-12-30 16:32:13 +01:00
parent 96e07ff453
commit baab9c8359
No known key found for this signature in database
GPG key ID: 3071D4EFBB298F5F
2 changed files with 9 additions and 5 deletions

View file

@ -242,7 +242,7 @@ class LegendaryCLI:
# a third-party application (such as Origin). # a third-party application (such as Origin).
if not version: if not version:
_store = game.third_party_store _store = game.third_party_store
if _store == 'Origin': if game.is_origin_game:
print(f' - This game has to be activated, installed, and launched via Origin, use ' print(f' - This game has to be activated, installed, and launched via Origin, use '
f'"legendary launch --origin {game.app_name}" to activate and/or run the game.') f'"legendary launch --origin {game.app_name}" to activate and/or run the game.')
elif _store: elif _store:
@ -722,7 +722,7 @@ class LegendaryCLI:
f'to fetch data for Origin titles before using this command.') f'to fetch data for Origin titles before using this command.')
return return
if not game.third_party_store or game.third_party_store != 'Origin': if not game.is_origin_game:
logger.error(f'The specified game is not an Origin title.') logger.error(f'The specified game is not an Origin title.')
return return
@ -856,7 +856,7 @@ class LegendaryCLI:
if store := game.third_party_store: if store := game.third_party_store:
logger.error(f'The selected title has to be installed via a third-party store: {store}') logger.error(f'The selected title has to be installed via a third-party store: {store}')
if store == 'Origin': if game.is_origin_game:
logger.info(f'For Origin games use "legendary launch --origin {args.app_name}" to ' logger.info(f'For Origin games use "legendary launch --origin {args.app_name}" to '
f'activate and/or run the game.') f'activate and/or run the game.')
exit(0) exit(0)
@ -2125,7 +2125,7 @@ class LegendaryCLI:
logger.info('Redeemed all outstanding Uplay codes.') logger.info('Redeemed all outstanding Uplay codes.')
elif args.origin: elif args.origin:
na_games, _ = self.core.get_non_asset_library_items(skip_ue=True) na_games, _ = self.core.get_non_asset_library_items(skip_ue=True)
origin_games = [game for game in na_games if game.third_party_store == 'Origin'] origin_games = [game for game in na_games if game.is_origin_game]
if not origin_games: if not origin_games:
logger.info('No redeemable games found.') logger.info('No redeemable games found.')

View file

@ -66,7 +66,11 @@ class Game:
return self.metadata and 'mainGameItem' in self.metadata return self.metadata and 'mainGameItem' in self.metadata
@property @property
def third_party_store(self): def is_origin_game(self) -> bool:
return self.third_party_store and self.third_party_store.lower() in ['origin', 'the ea app']
@property
def third_party_store(self) -> Optional[str]:
if not self.metadata: if not self.metadata:
return None return None
return self.metadata.get('customAttributes', {}).get('ThirdPartyManagedApp', {}).get('value', None) return self.metadata.get('customAttributes', {}).get('ThirdPartyManagedApp', {}).get('value', None)