aboutsummaryrefslogtreecommitdiff
path: root/jellystack_lib.py
diff options
context:
space:
mode:
Diffstat (limited to 'jellystack_lib.py')
-rw-r--r--jellystack_lib.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/jellystack_lib.py b/jellystack_lib.py
index 5a96e26..5c5c132 100644
--- a/jellystack_lib.py
+++ b/jellystack_lib.py
@@ -83,6 +83,7 @@ def is_like_id(input_id):
def watched_episodes_for_show(client, library_id_or_name, show_id_or_name, season_id = -1, verbose = False):
"""
Given the show_id_or_name (show_id from the user's view in jellyfin, or exact name), return a list of the episode count watched and total episode count. If season_id is not defined (-1), then do it for all seasons. The episode-watched number is dependent on who logged in to jellyfin.
+ Season_id may also be string "sum" which will just produce a single 100/110 fraction in the output string.
If you cannot find the exact name to use, pass verbose=True to see what it is comparing against.
WARNING: Seasons are zero-indexed, but specials (if present in your library) are number zero!
Improve: research if admin user can look at other users' views.
@@ -128,7 +129,7 @@ def watched_episodes_for_show(client, library_id_or_name, show_id_or_name, seaso
# get season count
seasons = client.jellyfin.get_seasons(view_series_id)
season_count = seasons["TotalRecordCount"]
- if season_id != -1:
+ if season_id != -1 and season_id.isdigit():
# a specific season
return _watched_episodes_for_season(client, seasons["Items"][season_id]["Id"], season_id)
else:
@@ -138,6 +139,15 @@ def watched_episodes_for_show(client, library_id_or_name, show_id_or_name, seaso
while x < season_count:
response.append(_watched_episodes_for_season(client, seasons["Items"][x]["Id"], x))
x += 1
+ if season_id == "sum":
+ sumx = 0
+ sumy = 0
+ for i in response:
+ x, y = i.split("/")
+ sumx += int(x)
+ sumy += int(y)
+ return f"{sumx}/{sumy}"
+ else:
return response
def _watched_episodes_for_season(client, view_season_id, season_index):
bgstack15