From 10495809e770f2adf8c77b7cc9be77a966de0a5c Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Mon, 1 Mar 2021 17:54:19 -0800 Subject: [PATCH 1/2] Fix season watched and unwatched --- plexapi/video.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plexapi/video.py b/plexapi/video.py index 563969ff8..e215a2f65 100644 --- a/plexapi/video.py +++ b/plexapi/video.py @@ -678,11 +678,11 @@ def show(self): def watched(self): """ Returns list of watched :class:`~plexapi.video.Episode` objects. """ - return self.episodes(watched=True) + return self.episodes(viewCount__gt=0) def unwatched(self): """ Returns list of unwatched :class:`~plexapi.video.Episode` objects. """ - return self.episodes(watched=False) + return self.episodes(viewCount=0) def download(self, savepath=None, keep_original_name=False, **kwargs): """ Download video files to specified directory. From bdec69e4a2c8871e79c2ccc3d167a2f28696267e Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Mon, 1 Mar 2021 17:54:43 -0800 Subject: [PATCH 2/2] Update show/season watched/unwatched tests --- tests/test_video.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/test_video.py b/tests/test_video.py index c537473f3..1573dafcf 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -611,17 +611,21 @@ def test_video_Show_history(show): def test_video_Show_watched(tvshows): show = tvshows.get("The 100") - show.episodes()[0].markWatched() + episode = show.episodes()[0] + episode.markWatched() watched = show.watched() assert len(watched) == 1 and watched[0].title == "Pilot" + episode.markUnwatched() def test_video_Show_unwatched(tvshows): show = tvshows.get("The 100") episodes = show.episodes() - episodes[0].markWatched() + episode = episodes[0] + episode.markWatched() unwatched = show.unwatched() assert len(unwatched) == len(episodes) - 1 + episode.markUnwatched() def test_video_Show_settings(show): @@ -885,6 +889,25 @@ 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)