From ff50421c4868345922a508a0d3f1b28d871d9eb4 Mon Sep 17 00:00:00 2001 From: twolaw Date: Tue, 25 Oct 2022 14:03:24 +0200 Subject: [PATCH] add show_id to TVEpisode --- trakt/calendar.py | 3 ++- trakt/sync.py | 4 +++- trakt/tv.py | 9 ++++++--- trakt/users.py | 6 ++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/trakt/calendar.py b/trakt/calendar.py index d5a5980e..dd63ec4e 100644 --- a/trakt/calendar.py +++ b/trakt/calendar.py @@ -81,7 +81,8 @@ def _build(self, data): 'show_data': TVShow(**show_data) } self._calendar.append( - TVEpisode(show_data['title'], season, ep_num, **e_data) + TVEpisode(show_data['title'], season, ep_num, + show_id=show_data['trakt'], **e_data) ) self._calendar = sorted(self._calendar, key=lambda x: x.airs_at) diff --git a/trakt/sync.py b/trakt/sync.py index 32c7bc78..bdd90576 100644 --- a/trakt/sync.py +++ b/trakt/sync.py @@ -336,7 +336,9 @@ def get_watchlist(list_type=None, sort=None): from trakt.tv import TVEpisode show = d.pop('show') extract_ids(d['episode']) - results.append(TVEpisode(show.get('title', None), **d['episode'])) + results.append(TVEpisode(show.get('title', None), + show_id=show.get('trakt', None), + **d['episode'])) elif 'movie' in d: from trakt.movies import Movie results.append(Movie(**d.pop('movie'))) diff --git a/trakt/tv.py b/trakt/tv.py index 3b8fc52e..0890d82d 100644 --- a/trakt/tv.py +++ b/trakt/tv.py @@ -439,7 +439,8 @@ def seasons(self): # Prepare episodes episodes = [] for ep in season.pop('episodes', []): - episode = TVEpisode(show=self.title, **ep) + episode = TVEpisode(show=self.title, + show_id=self.trakt, **ep) episodes.append(episode) season['episodes'] = episodes @@ -456,7 +457,8 @@ def last_episode(self): """ if self._last_episode is None: data = yield self.ext + '/last_episode?extended=full' - self._last_episode = data and TVEpisode(show=self.title, **data) + self._last_episode = data and TVEpisode(show=self.title, + show_id=self.trakt, **data) yield self._last_episode @property @@ -467,7 +469,8 @@ def next_episode(self): """ if self._next_episode is None: data = yield self.ext + '/next_episode?extended=full' - self._next_episode = data and TVEpisode(show=self.title, **data) + self._next_episode = data and TVEpisode(show=self.title, + show_id=self.trakt, **data) yield self._next_episode @property diff --git a/trakt/users.py b/trakt/users.py index 175117bb..d1669729 100644 --- a/trakt/users.py +++ b/trakt/users.py @@ -147,7 +147,8 @@ def get_items(self): show_data = item.pop('show') extract_ids(show_data) episode = TVEpisode(show_data['title'], item_data['season'], - item_data['number']) + item_data['number'], + show_id=show_data['trakt']) self._items.append(episode) elif item_type == 'person': self._items.append(Person(item_data['name'], @@ -439,7 +440,8 @@ def watching(self): ep_data = data.pop('episode') extract_ids(ep_data) sh_data = data.pop('show') - ep_data.update(data, show=sh_data.get('title')) + ep_data.update(data, show=sh_data.get('title'), + show_id=sh_data.get('trakt')) yield TVEpisode(**ep_data) @staticmethod