Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect output from season.watched() and season.unwatched() #677

Closed
gorobotgo opened this issue Mar 1, 2021 · 1 comment · Fixed by #678
Closed

Incorrect output from season.watched() and season.unwatched() #677

gorobotgo opened this issue Mar 1, 2021 · 1 comment · Fixed by #678
Labels

Comments

@gorobotgo
Copy link

Describe the issue
season.getWatched() always returns 0 episodes, season.getUnwatched() always returns the total number of episodes in the season, regardless of watched status.

Code snipppets

account = MyPlexAccount(username, password)
server_1 = account.resource(server_1_name)
conn_1 = server_1.connect()
s1_show = conn_1.library.section(libraryName).get(showName)
s1_seasons = s1_show.seasons()
for season in s1_seasons:
    print ("Season number is " + str(season.seasonNumber))
    unwatchedEps = season.unwatched()
    watchedEps = season.watched()
    allEps = season.episodes()
    print (str(len(unwatchedEps)) + " unwatched episodes in this season, " + str(len(watchedEps)) + " watched, " + str(len(allEps)) + " total")

Expected behavior
For a show with 2 seasons, 21 episodes in season 1, all of which are watched, and 10 episodes in season 2, 9 of which are watched, the expected output is:

Season number is 1
0 unwatched episodes in this season, 21 watched, 21 total
Season number is 2
1 unwatched episodes in this season, 9 watched, 10 total

But instead the output is:

Season number is 1
21 unwatched episodes in this season, 0 watched, 21 total
Season number is 2
10 unwatched episodes in this season, 0 watched, 10 total

Enviroment (please complete the following information):

  • OS: Raspbian Buster
  • Plex version 1.21.4.4079
  • Python Version 3.7.3
  • PlexAPI version 4.4.0
@JonnyWong16
Copy link
Collaborator

Yep, this is a bug. Thanks for the report.

In the meantime you can filter allEps yourself.

for season in s1_seasons:
    print ("Season number is " + str(season.seasonNumber))
    allEps = season.episodes()
    unwatchedEps = [ep for ep in allEps if ep.viewCount == 0]
    watchedEps = [ep for ep in allEps if ep.viewCount > 0]
    print (str(len(unwatchedEps)) + " unwatched episodes in this season, " + str(len(watchedEps)) + " watched, " + str(len(allEps)) + " total")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants