Skip to content

Commit

Permalink
Make sure we don't write empty tokens to cache (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister authored and dagwieers committed Oct 29, 2019
1 parent 939d703 commit 666c197
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions resources/lib/tokenresolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def _get_new_playertoken(self, token_url, headers, token_variant=None):
self._kodi.log(2, 'URL post: {url}', url=unquote(token_url))
req = Request(token_url, data=b'', headers=headers)
playertoken = json.load(urlopen(req))
self._set_cached_token(playertoken, token_variant)
if playertoken is not None:
self._set_cached_token(playertoken, token_variant)
return playertoken.get('vrtPlayerToken')

def login(self, refresh=False, token_variant=None):
Expand Down Expand Up @@ -252,8 +253,10 @@ def _get_fresh_token(self, refresh_token, token_name, token_variant=None):
req = Request(refresh_url, headers=headers)
opener.open(req)
token = TokenResolver._create_token_dictionary(cookiejar, token_name)
self._set_cached_token(token, token_variant)
return list(token.values())[0]
if token is not None:
self._set_cached_token(token, token_variant)
token = list(token.values())[0]
return token

def _get_roaming_xvrttoken(self, xvrttoken):
''' Get new 'roaming' X-VRT-Token from VRT NU website '''
Expand Down

0 comments on commit 666c197

Please sign in to comment.