Skip to content

Commit

Permalink
Fix subscriptions again (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGoogle authored Nov 25, 2020
1 parent 96e3214 commit e7cc320
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## Unreleased

[Fixed]
- Showing subscriptions (adjusting to changes in humble API again) #139

## Version 0.9.1

[Fixed]
- Showing subscriptions
- Showing subscriptions #136

## Version 0.9.0

Expand Down
13 changes: 10 additions & 3 deletions src/model/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,17 @@ def __init__(self, data: dict):
self.unlocked_content_events: t.Optional[t.List[str]] = data.get('unlockedContentEvents')

content_choice_data = data['contentChoiceData']

# Since August 2020 there is no simple 'initial' key, games may be stored under different keys:
# 'initial-without-order' # for not yet unlocked months
# 'initial-classic', # classic plan
# 'initial-basic' # XXX to be confirmed
# 'initial-premium' # XXX to be confirmed
try:
initial = content_choice_data['initial']
except KeyError: # not unlocked months have 'initial-without-order' field instead
initial = content_choice_data['initial-without-order']
initial_key = next(filter(lambda x: x.startswith('initial'), content_choice_data))
except StopIteration:
raise KeyError('initial key or similar not found in contentChoiceData')
initial = content_choice_data[initial_key]

self.content_choices: t.List[ContentChoice] = [
ContentChoice(id, c) for id, c
Expand Down
6 changes: 5 additions & 1 deletion src/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ async def get_subscription_products_with_gamekeys(self):
res_json = await res.json()
for product in res_json['products']:
if 'isChoiceTier' in product:
yield ContentChoiceOptions(product)
try:
yield ContentChoiceOptions(product)
except KeyError as e:
logging.warning(repr(e))
continue # ignore unexpected response without exiting generator
else: # no more choice content, now humble montly goes
# yield MontlyContentData(product)
return
Expand Down

0 comments on commit e7cc320

Please sign in to comment.