From 148ea7f35297ae1361d444cecbab72793273ed2f Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Sat, 24 Apr 2021 11:26:31 -0700 Subject: [PATCH 1/2] Fix episode test watched/unwatched name --- tests/test_video.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/test_video.py b/tests/test_video.py index eeb60030..d4419d03 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -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) @@ -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) From c6c9d83bca16b1fd446be347bf4a38cbb71c61a2 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Sat, 24 Apr 2021 11:49:36 -0700 Subject: [PATCH 2/2] Fix getting Season.episode by episode number --- plexapi/video.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plexapi/video.py b/plexapi/video.py index b984f431..541f4134 100644 --- a/plexapi/video.py +++ b/plexapi/video.py @@ -661,10 +661,14 @@ class Season(Video, ArtMixin, PosterMixin): :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):