diff --git a/addon.xml b/addon.xml index cdfdd1a..90234ba 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -32,6 +32,10 @@ resources/media/Screenshot3.jpg resources/media/Screenshot4.jpg + [B]Version 6.3.1 - 2024-03-05[/B] + - fix refresh token bug + - fix watchlist missing resume time bug + [B]Version 6.3.0 - 2024-02-25[/B] - Added login - changed videoinfo to nexus api diff --git a/changelog.txt b/changelog.txt index 6334f2b..ba6a328 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +[B]Version 6.3.1 - 2024-03-05[/B] +- fix refresh token bug +- fix watchlist missing resume time bug + [B]Version 6.3.0 - 2024-02-25[/B] - Added login - changed videoinfo to nexus api diff --git a/resources/lib/tvapi.py b/resources/lib/tvapi.py index 2c7e7ee..afb032c 100644 --- a/resources/lib/tvapi.py +++ b/resources/lib/tvapi.py @@ -179,8 +179,12 @@ def read_tokens(self, tokens): time_struct = time.strptime(time_str, '%Y-%m-%dT%H:%M:%S') self._token_expire = datetime(*time_struct[0:6], tzinfo=timezone.utc) self._user_token = tokens[0]['value'] - self._user_name = tokens[0].get('name', 'anonymous') self._profile_token = tokens[1]['value'] + if self.user: + tokens[0]['name'] = self.get_profile()['name'] + else: + tokens[0]['name'] = 'anonymous' + self._user_name = tokens[0]['name'] def request_tokens(self): self._user_token = None @@ -193,12 +197,9 @@ def request_tokens(self): return err tokens = [self.refresh_token(t) for t in tokens_pure] self.read_tokens(tokens) - tokens[0]['name'] = self.get_profile()['name'] else: tokens = anonymous_tokens() self.read_tokens(tokens) - tokens[0]['name'] = 'anonymous' - self._user_name = tokens[0]['name'] with self.token_file.open('wb') as fh: pickle.dump(tokens, fh) return None @@ -243,9 +244,9 @@ def refresh_tokens(self): if err: raise ApiException(f'Login failed with: "{err}"') else: + self.read_tokens(tokens) with self.token_file.open('wb') as fh: pickle.dump(tokens, fh) - self.read_tokens(tokens) def user_token(self): self.refresh_tokens() @@ -343,7 +344,7 @@ def get_continue(self, use_cache=False): items = self._request_get(url, params=data, headers=headers, use_cache=use_cache)['items'] watched = self.get_profile()['watched'] for item in items: - item['ResumeTime'] = float(watched[str(item['id'])]['position']) + item['ResumeTime'] = float(watched.get(str(item['id']), {'position':0.0})['position']) return items def get_profile(self, use_cache=False):