Skip to content
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
10 changes: 7 additions & 3 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,14 @@ def episode(self, title=None, episode=None):
: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):
Expand Down
38 changes: 19 additions & 19 deletions tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -895,25 +914,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)
Expand Down