Skip to content

Commit

Permalink
Detect games specifying "the EA app" for their ThirdPartyManagedApp a…
Browse files Browse the repository at this point in the history
…s 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)
  • Loading branch information
CommandMC committed May 16, 2024
1 parent 96e07ff commit baab9c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions legendary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def list_games(self, args):
# a third-party application (such as Origin).
if not version:
_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 '
f'"legendary launch --origin {game.app_name}" to activate and/or run the game.')
elif _store:
Expand Down Expand Up @@ -722,7 +722,7 @@ def _launch_origin(self, args):
f'to fetch data for Origin titles before using this command.')
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.')
return

Expand Down Expand Up @@ -856,7 +856,7 @@ def install_game(self, args):

if store := game.third_party_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 '
f'activate and/or run the game.')
exit(0)
Expand Down Expand Up @@ -2125,7 +2125,7 @@ def read_service_response(response):
logger.info('Redeemed all outstanding Uplay codes.')
elif args.origin:
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:
logger.info('No redeemable games found.')
Expand Down
6 changes: 5 additions & 1 deletion legendary/models/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def is_dlc(self):
return self.metadata and 'mainGameItem' in self.metadata

@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:
return None
return self.metadata.get('customAttributes', {}).get('ThirdPartyManagedApp', {}).get('value', None)
Expand Down

0 comments on commit baab9c8

Please sign in to comment.