From 4adad518bfa91cc7f3d273458924d1242f54446e Mon Sep 17 00:00:00 2001 From: Tracy <7706977+barthisius@users.noreply.github.com> Date: Thu, 19 Dec 2019 02:29:26 -0600 Subject: [PATCH] Support for (more) games purchased through Steam (#5) --- src/backend.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/backend.py b/src/backend.py index 3e91f86..f90fa3a 100644 --- a/src/backend.py +++ b/src/backend.py @@ -4,6 +4,14 @@ class ParadoxClient: def __init__(self, http_client): self.http_client = http_client + self._skus = {} + + async def get_skus(self): + if not self._skus: + skus = await self.http_client.do_request('GET', 'https://accounts.paradoxplaza.com/api/skus', + headers={'content-type': 'application/json'}) + self._skus = await skus.json() + return self._skus async def get_account_id(self): data = {'Authorization': f'{{"session":{{"token":"{self.http_client.token}"}}}}', @@ -19,6 +27,7 @@ async def get_owned_games(self): headers=data) response = await response.json() + skus = await self.get_skus() owned_products = [] if 'products' in response: @@ -26,9 +35,11 @@ async def get_owned_games(self): for platform in platforms: for game in platforms[platform]: log.info(game) - if game['sku'] and game['title'] and game['product_type'] and "paradox builds" in game['platforms']: - owned_products.append({'sku': game['sku'], - 'title': game['title'], - 'type': game['product_type']}) + if game['sku'] and game['title'] and game['product_type']: + if (game['sku'] in skus and 'paradoxLauncher' in skus[game['sku']]['platform']) \ + or "paradox builds" in game['platforms']: + owned_products.append({'sku': game['sku'], + 'title': game['title'], + 'type': game['product_type']}) log.info(owned_products) return owned_products