From 666c197f47043df52deafd3ffa0a2486918bfe74 Mon Sep 17 00:00:00 2001 From: mediaminister <45148099+mediaminister@users.noreply.github.com> Date: Tue, 29 Oct 2019 22:29:28 +0100 Subject: [PATCH] Make sure we don't write empty tokens to cache (#558) --- resources/lib/tokenresolver.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/lib/tokenresolver.py b/resources/lib/tokenresolver.py index d9a62019..2d6e0304 100644 --- a/resources/lib/tokenresolver.py +++ b/resources/lib/tokenresolver.py @@ -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): @@ -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 '''