Skip to content

Commit

Permalink
unfold mylist and continue watching lists (#96)
Browse files Browse the repository at this point in the history
* unfold mylist and continue watching lists

* bump version
  • Loading branch information
TermeHansen authored May 7, 2024
1 parent d6431e3 commit c9559eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 5 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.drnu" version="6.4.1" name="DR TV" provider-name="TermeHansen">
<addon id="plugin.video.drnu" version="6.4.2" name="DR TV" provider-name="TermeHansen">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="script.module.dateutil" version="2.8.2" />
<import addon="script.module.requests" version="2.31.0" />
<import addon="script.module.requests-cache" version="0.5.2+matrix.2"/>
Expand Down Expand Up @@ -32,6 +32,9 @@
<screenshot>resources/media/Screenshot3.jpg</screenshot>
<screenshot>resources/media/Screenshot4.jpg</screenshot>
</assets>
<news>[B]Version 6.4.2 - 2024-05-06[/B]
- Fix not unfolding my-list
</news>
<news>[B]Version 6.4.1 - 2024-03-29[/B]
- Fix live channels not working from EU
</news>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[B]Version 6.4.2 - 2024-05-06[/B]
- Fix not unfolding my-list

[B]Version 6.4.1 - 2024-03-29[/B]
- Fix live channels not working from EU

Expand Down
16 changes: 9 additions & 7 deletions resources/lib/tvapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ def get_item(self, id, use_cache=True):
url = URL + f'/items/{int(id)}?'
return self._request_get(url)

def get_next(self, path, use_cache=True):
def get_next(self, path, use_cache=True, headers=None):
url = URL + path
return self._request_get(url, use_cache=use_cache)
return self._request_get(url, headers=headers, use_cache=use_cache)

def get_list(self, id, param, use_cache=True):
if isinstance(id, str):
Expand Down Expand Up @@ -338,7 +338,8 @@ def get_mylist(self, use_cache=False):
url = URL + '/account/profile/bookmarks/list'
data = {'page_size': '24'}
headers = {"X-Authorization": f'Bearer {self.profile_token()}'}
items = self._request_get(url, params=data, headers=headers, use_cache=use_cache)['items']
item = self._request_get(url, params=data, headers=headers, use_cache=use_cache)
items = self.unfold_list(item, headers=headers)
for item in items:
item['in_mylist'] = True
return items
Expand All @@ -347,7 +348,8 @@ def get_continue(self, use_cache=False):
url = URL + '/account/profile/continue-watching/list'
data = {'page_size': '24'}
headers = {"X-Authorization": f'Bearer {self.profile_token()}'}
items = self._request_get(url, params=data, headers=headers, use_cache=use_cache)['items']
item = self._request_get(url, params=data, headers=headers, use_cache=use_cache)
items = self.unfold_list(item, headers=headers)
watched = self.get_profile()['watched']
for item in items:
item['ResumeTime'] = float(watched.get(str(item['id']), {'position':0.0})['position'])
Expand All @@ -368,13 +370,13 @@ def kids_item(self, item):
return True
return False

def unfold_list(self, item, filter_kids=False):
def unfold_list(self, item, filter_kids=False, headers=None):
items = item['items']
if 'next' in item['paging']:
next_js = self.get_next(item['paging']['next'])
next_js = self.get_next(item['paging']['next'], headers=headers)
items += next_js['items']
while 'next' in next_js['paging']:
next_js = self.get_next(next_js['paging']['next'])
next_js = self.get_next(next_js['paging']['next'], headers=headers)
items += next_js['items']
if filter_kids:
items = [item for item in items if not self.kids_item(item)]
Expand Down

0 comments on commit c9559eb

Please sign in to comment.