mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Merge pull request #730 from JonnyWong16/bugfix/episode_tests
Fix retrieving Season.episode() by episode number
This commit is contained in:
commit
158c5f5633
2 changed files with 26 additions and 22 deletions
|
@ -663,10 +663,14 @@ class Season(Video, ArtMixin, PosterMixin, CollectionMixin):
|
|||
:exc:`~plexapi.exceptions.BadRequest`: If title or episode parameter is missing.
|
||||
"""
|
||||
key = '/library/metadata/%s/children' % self.ratingKey
|
||||
if title is not None:
|
||||
if title is not None and not isinstance(title, int):
|
||||
return self.fetchItem(key, Episode, title__iexact=title)
|
||||
elif episode is not None:
|
||||
return self.fetchItem(key, Episode, parentIndex=self.index, index=episode)
|
||||
elif episode is not None or isinstance(title, int):
|
||||
if isinstance(title, int):
|
||||
index = title
|
||||
else:
|
||||
index = episode
|
||||
return self.fetchItem(key, Episode, parentIndex=self.index, index=index)
|
||||
raise BadRequest('Missing argument: title or episode is required')
|
||||
|
||||
def get(self, title=None, episode=None):
|
||||
|
|
|
@ -868,6 +868,25 @@ def test_video_Episode_attrs(episode):
|
|||
assert part.accessible
|
||||
|
||||
|
||||
def test_video_Episode_watched(tvshows):
|
||||
season = tvshows.get("The 100").season(1)
|
||||
episode = season.episode(1)
|
||||
episode.markWatched()
|
||||
watched = season.watched()
|
||||
assert len(watched) == 1 and watched[0].title == "Pilot"
|
||||
episode.markUnwatched()
|
||||
|
||||
|
||||
def test_video_Episode_unwatched(tvshows):
|
||||
season = tvshows.get("The 100").season(1)
|
||||
episodes = season.episodes()
|
||||
episode = episodes[0]
|
||||
episode.markWatched()
|
||||
unwatched = season.unwatched()
|
||||
assert len(unwatched) == len(episodes) - 1
|
||||
episode.markUnwatched()
|
||||
|
||||
|
||||
def test_video_Episode_mixins_images(episode):
|
||||
#test_mixins.edit_art(episode) # Uploading episode artwork is broken in Plex
|
||||
test_mixins.edit_poster(episode)
|
||||
|
@ -896,25 +915,6 @@ def test_video_Season_history(show):
|
|||
season.markUnwatched()
|
||||
|
||||
|
||||
def test_video_Season_watched(tvshows):
|
||||
season = tvshows.get("The 100").season(1)
|
||||
episode = season.episode(1)
|
||||
episode.markWatched()
|
||||
watched = season.watched()
|
||||
assert len(watched) == 1 and watched[0].title == "Pilot"
|
||||
episode.markUnwatched()
|
||||
|
||||
|
||||
def test_video_Season_unwatched(tvshows):
|
||||
season = tvshows.get("The 100").season(1)
|
||||
episodes = season.episodes()
|
||||
episode = episodes[0]
|
||||
episode.markWatched()
|
||||
unwatched = season.unwatched()
|
||||
assert len(unwatched) == len(episodes) - 1
|
||||
episode.markUnwatched()
|
||||
|
||||
|
||||
def test_video_Season_attrs(show):
|
||||
season = show.season("Season 1")
|
||||
assert utils.is_datetime(season.addedAt)
|
||||
|
|
Loading…
Reference in a new issue