Skip to content

Commit

Permalink
No resumetime issue and fix name from refresh token (#89)
Browse files Browse the repository at this point in the history
* added fix for continue watching missing resume times
* added fix for possible missing user_name after refresh
  • Loading branch information
TermeHansen authored Mar 5, 2024
1 parent 9bf5def commit 401f746
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.drnu" version="6.3.0" name="DR TV" provider-name="TermeHansen">
<addon id="plugin.video.drnu" version="6.3.1" name="DR TV" provider-name="TermeHansen">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.dateutil" version="2.8.2" />
Expand Down Expand Up @@ -32,6 +32,10 @@
<screenshot>resources/media/Screenshot3.jpg</screenshot>
<screenshot>resources/media/Screenshot4.jpg</screenshot>
</assets>
<news>[B]Version 6.3.1 - 2024-03-05[/B]
- fix refresh token bug
- fix watchlist missing resume time bug
</news>
<news>[B]Version 6.3.0 - 2024-02-25[/B]
- Added login
- changed videoinfo to nexus api
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 7 additions & 6 deletions resources/lib/tvapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 401f746

Please sign in to comment.