Skip to content

Commit f9a09ae

Browse files
authored
Merge pull request #678 from JonnyWong16/bugfix/season_watched
Fix season watched/unwatched
2 parents 7cfa2f2 + bdec69e commit f9a09ae

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

plexapi/video.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,11 @@ def show(self):
678678

679679
def watched(self):
680680
""" Returns list of watched :class:`~plexapi.video.Episode` objects. """
681-
return self.episodes(watched=True)
681+
return self.episodes(viewCount__gt=0)
682682

683683
def unwatched(self):
684684
""" Returns list of unwatched :class:`~plexapi.video.Episode` objects. """
685-
return self.episodes(watched=False)
685+
return self.episodes(viewCount=0)
686686

687687
def download(self, savepath=None, keep_original_name=False, **kwargs):
688688
""" Download video files to specified directory.

tests/test_video.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,17 +611,21 @@ def test_video_Show_history(show):
611611

612612
def test_video_Show_watched(tvshows):
613613
show = tvshows.get("The 100")
614-
show.episodes()[0].markWatched()
614+
episode = show.episodes()[0]
615+
episode.markWatched()
615616
watched = show.watched()
616617
assert len(watched) == 1 and watched[0].title == "Pilot"
618+
episode.markUnwatched()
617619

618620

619621
def test_video_Show_unwatched(tvshows):
620622
show = tvshows.get("The 100")
621623
episodes = show.episodes()
622-
episodes[0].markWatched()
624+
episode = episodes[0]
625+
episode.markWatched()
623626
unwatched = show.unwatched()
624627
assert len(unwatched) == len(episodes) - 1
628+
episode.markUnwatched()
625629

626630

627631
def test_video_Show_settings(show):
@@ -885,6 +889,25 @@ def test_video_Season_history(show):
885889
season.markUnwatched()
886890

887891

892+
def test_video_Season_watched(tvshows):
893+
season = tvshows.get("The 100").season(1)
894+
episode = season.episode(1)
895+
episode.markWatched()
896+
watched = season.watched()
897+
assert len(watched) == 1 and watched[0].title == "Pilot"
898+
episode.markUnwatched()
899+
900+
901+
def test_video_Season_unwatched(tvshows):
902+
season = tvshows.get("The 100").season(1)
903+
episodes = season.episodes()
904+
episode = episodes[0]
905+
episode.markWatched()
906+
unwatched = season.unwatched()
907+
assert len(unwatched) == len(episodes) - 1
908+
episode.markUnwatched()
909+
910+
888911
def test_video_Season_attrs(show):
889912
season = show.season("Season 1")
890913
assert utils.is_datetime(season.addedAt)

0 commit comments

Comments
 (0)