From c9559eb5f5fcff131a9b9c6965e3e12800c56ab5 Mon Sep 17 00:00:00 2001 From: Rasmus Lundsgaard Date: Tue, 7 May 2024 08:54:15 +0200 Subject: [PATCH] unfold mylist and continue watching lists (#96) * unfold mylist and continue watching lists * bump version --- addon.xml | 7 +++++-- changelog.txt | 3 +++ resources/lib/tvapi.py | 16 +++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/addon.xml b/addon.xml index 3a7e949..1b1b244 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ - + - + @@ -32,6 +32,9 @@ resources/media/Screenshot3.jpg resources/media/Screenshot4.jpg + [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 diff --git a/changelog.txt b/changelog.txt index f4204a8..dd84ff2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/resources/lib/tvapi.py b/resources/lib/tvapi.py index 4731832..79e8bc2 100644 --- a/resources/lib/tvapi.py +++ b/resources/lib/tvapi.py @@ -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): @@ -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 @@ -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']) @@ -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)]