mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[cli/core] Fix fetching more than 1000 entitlements
This commit is contained in:
parent
96e07ff453
commit
7fefdc4973
|
@ -186,13 +186,24 @@ class EPCAPI:
|
|||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
def get_user_entitlements(self):
|
||||
def get_user_entitlements(self, start=0):
|
||||
user_id = self.user.get('account_id')
|
||||
r = self.session.get(f'https://{self._entitlements_host}/entitlement/api/account/{user_id}/entitlements',
|
||||
params=dict(start=0, count=5000), timeout=self.request_timeout)
|
||||
params=dict(start=start, count=1000), timeout=self.request_timeout)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
def get_user_entitlements_full(self):
|
||||
ret = []
|
||||
|
||||
while True:
|
||||
resp = self.get_user_entitlements(start=len(ret))
|
||||
ret.extend(resp)
|
||||
if len(resp) < 1000:
|
||||
break
|
||||
|
||||
return ret
|
||||
|
||||
def get_game_info(self, namespace, catalog_item_id, timeout=None):
|
||||
r = self.session.get(f'https://{self._catalog_host}/catalog/api/shared/namespace/{namespace}/bulk/items',
|
||||
params=dict(id=catalog_item_id, includeDLCDetails=True, includeMainGameDetails=True,
|
||||
|
|
|
@ -1657,7 +1657,7 @@ class LegendaryCLI:
|
|||
else:
|
||||
logger.info('Game not installed and offline mode enabled, cannot load manifest.')
|
||||
elif game:
|
||||
entitlements = self.core.egs.get_user_entitlements()
|
||||
entitlements = self.core.egs.get_user_entitlements_full()
|
||||
egl_meta = self.core.egs.get_game_info(game.namespace, game.catalog_item_id)
|
||||
game.metadata = egl_meta
|
||||
# Get manifest if asset exists for current platform
|
||||
|
@ -2046,7 +2046,7 @@ class LegendaryCLI:
|
|||
redeemed = {k['gameId'] for k in key_list if k['redeemedOnUplay']}
|
||||
|
||||
games = self.core.get_game_list()
|
||||
entitlements = self.core.egs.get_user_entitlements()
|
||||
entitlements = self.core.egs.get_user_entitlements_full()
|
||||
owned_entitlements = {i['entitlementName'] for i in entitlements}
|
||||
|
||||
uplay_games = []
|
||||
|
|
Loading…
Reference in a new issue