Skip to content

Commit

Permalink
Use season number instead of season name
Browse files Browse the repository at this point in the history
Using season name is not reliable as it can vary between servers
and can be overridden by the user.

Signed-off-by: Luigi311 <[email protected]>
  • Loading branch information
luigi311 committed Dec 10, 2023
1 parent 2d00d8c commit 117932e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,9 @@ async def get_user_library_watched(
if len(seasons["Items"]) > 0:
for season in seasons["Items"]:
season_identifiers = dict(seasons["Identifiers"])
season_identifiers["season_id"] = season["Id"]
season_identifiers["season_name"] = season["Name"]
season_identifiers["season_index"] = season[
"IndexNumber"
]
watched_task = asyncio.ensure_future(
self.query(
f"/Shows/{season_identifiers['show_id']}/Episodes"
Expand Down Expand Up @@ -390,18 +391,18 @@ async def get_user_library_watched(
] = {}

if (
season_dict["Identifiers"]["season_name"]
season_dict["Identifiers"]["season_index"]
not in user_watched[user_name][library_title][
season_dict["Identifiers"]["show_guids"]
]
):
user_watched[user_name][library_title][
season_dict["Identifiers"]["show_guids"]
][season_dict["Identifiers"]["season_name"]] = []
][season_dict["Identifiers"]["season_index"]] = []

user_watched[user_name][library_title][
season_dict["Identifiers"]["show_guids"]
][season_dict["Identifiers"]["season_name"]] = season_dict[
][season_dict["Identifiers"]["season_index"]] = season_dict[
"Episodes"
]
logger(
Expand Down
12 changes: 6 additions & 6 deletions src/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ def get_user_library_watched_show(show):

for episode in show.episodes():
if episode in watched:
if episode.parentTitle not in episode_guids:
episode_guids[episode.parentTitle] = []
if episode.parentIndex not in episode_guids:
episode_guids[episode.parentIndex] = []

episode_guids[episode.parentTitle].append(
episode_guids[episode.parentIndex].append(
get_episode_guids(episode, show, completed=True)
)
elif episode.viewOffset > 0:
if episode.parentTitle not in episode_guids:
episode_guids[episode.parentTitle] = []
if episode.parentIndex not in episode_guids:
episode_guids[episode.parentIndex] = []

episode_guids[episode.parentTitle].append(
episode_guids[episode.parentIndex].append(
get_episode_guids(episode, show, completed=False)
)

Expand Down

0 comments on commit 117932e

Please sign in to comment.