Skip to content

Commit

Permalink
add show_id to TVEpisode
Browse files Browse the repository at this point in the history
  • Loading branch information
simonc56 committed Oct 25, 2022
1 parent f6875ea commit fe343b0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion trakt/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion trakt/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down
14 changes: 9 additions & 5 deletions trakt/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -588,7 +591,8 @@ def _build(self, data):
# only try to build our episodes if we got a list of episodes, not a
# dict of season data
if isinstance(data, list):
self._episodes = [TVEpisode(show=self.show, **ep) for ep in data]
self._episodes = [TVEpisode(show=self.show, show_id=self.trakt,
**ep) for ep in data]
else:
for key, val in data.items():
try:
Expand Down Expand Up @@ -644,7 +648,7 @@ def _episode_getter(self, episode):
episode_extension = '/episodes/{}?extended=full'.format(episode)
try:
data = yield self.ext + episode_extension
yield TVEpisode(show=self.show, **data)
yield TVEpisode(show=self.show, show_id=self.trakt, **data)
except NotFoundException:
yield None

Expand Down
6 changes: 4 additions & 2 deletions trakt/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fe343b0

Please sign in to comment.