mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
Fix onDeck handling of TV Shows (#641)
* Fix onDeck handling of TV Shows * Add onDeck for Season, update docstrings * Clarify docstring wording
This commit is contained in:
parent
dfc5aa1eef
commit
db344e9e6b
1 changed files with 15 additions and 2 deletions
|
@ -495,11 +495,14 @@ class Show(Video):
|
|||
return self.findItems(related, 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.
|
||||
|
@ -662,6 +665,16 @@ class Season(Video):
|
|||
""" 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)
|
||||
|
|
Loading…
Reference in a new issue