Skip to content

Commit

Permalink
more robust handling of invalid cookies and logged out state
Browse files Browse the repository at this point in the history
  • Loading branch information
meeb committed Nov 19, 2023
1 parent a6a2d3a commit a68fe80
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bandcampsync/bandcamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,17 @@ def verify_authentication(self):
except KeyError as e:
raise BandcampError(f'Failed to parse pagedata JSON, does not contain an '
f'"identities.fan" key') from e
if not isinstance(fan, dict):
raise BandcampError(f'Failed to parse pagedata JSON, "identities.fan" is not '
f'a dictionary. Check your cookies.txt file is valid '
f'and up to date')
try:
self.user_id = fan['id']
self.user_name = fan['name']
self.user_url = fan['url']
self.user_verified = fan['verified']
self.user_private = fan['private']
except KeyError as e:
except (KeyError, TypeError) as e:
raise BandcampError(f'Failed to parse pagedata JSON, "identities.fan" seems '
f'invalid: {fan}') from e
self.is_authenticated = self.user_id > 0
Expand Down

0 comments on commit a68fe80

Please sign in to comment.