[cli/core/models] Add property for partner link id/type

This commit is contained in:
derrod 2021-12-06 18:10:30 +01:00
parent 4dd495e2f5
commit 9d18ef03fa
3 changed files with 18 additions and 8 deletions

View file

@ -1759,9 +1759,9 @@ class LegendaryCLI:
uplay_games = []
activated = 0
for game in games:
if game.metadata.get('customAttributes', {}).get('partnerLinkType', {}).get('value') != 'ubisoft':
if game.partner_link_type != 'ubisoft':
continue
if game.metadata.get('customAttributes', {}).get('partnerLinkId', {}).get('value') in redeemed:
if game.partner_link_id in redeemed:
activated += 1
continue
uplay_games.append(game)
@ -1782,8 +1782,7 @@ class LegendaryCLI:
try:
for game in uplay_games:
game_id = game.metadata.get('customAttributes', {}).get('partnerLinkId', {}).get('value')
self.core.egs.store_claim_uplay_code(ubi_account_id, game_id)
self.core.egs.store_claim_uplay_code(ubi_account_id, game.partner_link_id)
self.core.egs.store_redeem_uplay_codes(ubi_account_id)
except Exception as e:
logger.error(f'Failed to redeem Uplay codes: {e!r}')

View file

@ -1357,12 +1357,11 @@ class LegendaryCore:
uplay_required = True
# check if the game requires linking to an external account first
partner_link = game.metadata.get('customAttributes', {}).get('partnerLinkType', {}).get('value', None)
if partner_link and partner_link != 'ubisoft':
results.warnings.add(f'This game requires linking to "{partner_link}", '
if game.partner_link_type and game.partner_link_type != 'ubisoft':
results.warnings.add(f'This game requires linking to "{game.partner_link_type}", '
f'this is currently unsupported and the game may not work.')
if uplay_required or partner_link == 'ubisoft':
if uplay_required or game.partner_link_type == 'ubisoft':
if os.name == 'nt':
results.warnings.add('This game requires installation of Uplay/Ubisoft Connect, direct '
'installation via Uplay is recommended. '

View file

@ -71,6 +71,18 @@ class Game:
return None
return self.metadata.get('customAttributes', {}).get('ThirdPartyManagedApp', {}).get('value', None)
@property
def partner_link_type(self):
if not self.metadata:
return None
return self.metadata.get('customAttributes', {}).get('partnerLinkType', {}).get('value', None)
@property
def partner_link_id(self):
if not self.metadata:
return None
return self.metadata.get('customAttributes', {}).get('partnerLinkId', {}).get('value', None)
@property
def supports_cloud_saves(self):
return self.metadata and (self.metadata.get('customAttributes', {}).get('CloudSaveFolder') is not None)