Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add show_id to TVEpisode #6

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 6 additions & 3 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
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