[api] EGS: Add method to fetch library items

This is required for us to also get items that don't have assets
(e.g. some DLCs/Origin-managed games)
This commit is contained in:
derrod 2021-01-20 14:43:32 +01:00
parent edad963200
commit f040f4bd40

View file

@ -21,6 +21,7 @@ class EPCAPI:
_catalog_host = 'catalog-public-service-prod06.ol.epicgames.com'
_ecommerce_host = 'ecommerceintegration-public-service-ecomprod02.ol.epicgames.com'
_datastorage_host = 'datastorage-public-service-liveegs.live.use1a.on.epicgames.com'
_library_host = 'library-service.live.use1a.on.epicgames.com'
def __init__(self, lc='en', cc='US'):
self.session = requests.session()
@ -122,6 +123,24 @@ class EPCAPI:
r.raise_for_status()
return r.json().get(catalog_item_id, None)
def get_library_items(self, include_metadata=True):
records = []
r = self.session.get(f'https://{self._library_host}/library/api/public/items',
params=dict(includeMetadata=include_metadata))
r.raise_for_status()
j = r.json()
records.extend(j['records'])
# Fetch remaining library entries as long as there is a cursor
while cursor := j['responseMetadata'].get('nextCursor', None):
r = self.session.get(f'https://{self._library_host}/library/api/public/items',
params=dict(includeMetadata=include_metadata, cursor=cursor))
r.raise_for_status()
j = r.json()
records.extend(j['records'])
return records
def get_user_cloud_saves(self, app_name='', manifests=False, filenames=None):
if app_name and manifests:
app_name += '/manifests/'