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

Fix onDeck handling of TV Shows #641

Merged
merged 3 commits into from
Jan 24, 2021
Merged
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
17 changes: 15 additions & 2 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,14 @@ def hubs(self):
return self.findItems(item, library.Hub)

def onDeck(self):
""" Returns shows On Deck :class:`~plexapi.video.Video` object.
""" Returns show's On Deck :class:`~plexapi.video.Video` object or `None`.
If show is unwatched, return will likely be the first episode.
"""
data = self._server.query(self._details_key)
return self.findItems([item for item in data.iter('OnDeck')][0])[0]
episode = next(data.iter('OnDeck'), None)
if episode:
return self.findItems(episode)[0]
return None

def season(self, title=None, season=None):
""" Returns the season with the specified title or number.
Expand Down Expand Up @@ -650,6 +653,16 @@ def get(self, title=None, episode=None):
""" Alias to :func:`~plexapi.video.Season.episode`. """
return self.episode(title, episode)

def onDeck(self):
""" Returns season's On Deck :class:`~plexapi.video.Video` object or `None`.
Will only return a match if the show's On Deck episode is in this season.
"""
data = self._server.query(self._details_key)
episode = next(data.iter('OnDeck'), None)
if episode:
return self.findItems(episode)[0]
return None

def show(self):
""" Return the season's :class:`~plexapi.video.Show`. """
return self.fetchItem(self.parentRatingKey)
Expand Down