Skip to content

Commit

Permalink
Support for (more) games purchased through Steam (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
barthisius authored and FriendsOfGalaxy committed Dec 19, 2019
1 parent 3032588 commit 4adad51
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"}}}}',
Expand All @@ -19,16 +27,19 @@ async def get_owned_games(self):
headers=data)

response = await response.json()
skus = await self.get_skus()

owned_products = []
if 'products' in response:
for platforms in response['products']:
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

0 comments on commit 4adad51

Please sign in to comment.