Use season number instead of season name

Using season name is not reliable as it can vary between servers
and can be overridden by the user.

Signed-off-by: Luigi311 <git@luigi311.com>
pull/125/head
Luigi311 2023-12-10 10:41:59 -07:00
parent 2d00d8cb3e
commit 117932e272
2 changed files with 12 additions and 11 deletions

View File

@ -331,8 +331,9 @@ class Jellyfin:
if len(seasons["Items"]) > 0: if len(seasons["Items"]) > 0:
for season in seasons["Items"]: for season in seasons["Items"]:
season_identifiers = dict(seasons["Identifiers"]) season_identifiers = dict(seasons["Identifiers"])
season_identifiers["season_id"] = season["Id"] season_identifiers["season_index"] = season[
season_identifiers["season_name"] = season["Name"] "IndexNumber"
]
watched_task = asyncio.ensure_future( watched_task = asyncio.ensure_future(
self.query( self.query(
f"/Shows/{season_identifiers['show_id']}/Episodes" f"/Shows/{season_identifiers['show_id']}/Episodes"
@ -390,18 +391,18 @@ class Jellyfin:
] = {} ] = {}
if ( if (
season_dict["Identifiers"]["season_name"] season_dict["Identifiers"]["season_index"]
not in user_watched[user_name][library_title][ not in user_watched[user_name][library_title][
season_dict["Identifiers"]["show_guids"] season_dict["Identifiers"]["show_guids"]
] ]
): ):
user_watched[user_name][library_title][ user_watched[user_name][library_title][
season_dict["Identifiers"]["show_guids"] season_dict["Identifiers"]["show_guids"]
][season_dict["Identifiers"]["season_name"]] = [] ][season_dict["Identifiers"]["season_index"]] = []
user_watched[user_name][library_title][ user_watched[user_name][library_title][
season_dict["Identifiers"]["show_guids"] season_dict["Identifiers"]["show_guids"]
][season_dict["Identifiers"]["season_name"]] = season_dict[ ][season_dict["Identifiers"]["season_index"]] = season_dict[
"Episodes" "Episodes"
] ]
logger( logger(

View File

@ -105,17 +105,17 @@ def get_user_library_watched_show(show):
for episode in show.episodes(): for episode in show.episodes():
if episode in watched: if episode in watched:
if episode.parentTitle not in episode_guids: if episode.parentIndex not in episode_guids:
episode_guids[episode.parentTitle] = [] episode_guids[episode.parentIndex] = []
episode_guids[episode.parentTitle].append( episode_guids[episode.parentIndex].append(
get_episode_guids(episode, show, completed=True) get_episode_guids(episode, show, completed=True)
) )
elif episode.viewOffset > 0: elif episode.viewOffset > 0:
if episode.parentTitle not in episode_guids: if episode.parentIndex not in episode_guids:
episode_guids[episode.parentTitle] = [] episode_guids[episode.parentIndex] = []
episode_guids[episode.parentTitle].append( episode_guids[episode.parentIndex].append(
get_episode_guids(episode, show, completed=False) get_episode_guids(episode, show, completed=False)
) )