Do not error if failed to get library watched

This commit is contained in:
Luigi311
2023-02-25 15:03:27 -07:00
parent 45471607c8
commit 96eff65c3e
2 changed files with 14 additions and 15 deletions

View File

@@ -309,7 +309,7 @@ class Jellyfin:
f"Jellyfin: Failed to get watched for {user_name} in library {library_title}, Error: {e}", f"Jellyfin: Failed to get watched for {user_name} in library {library_title}, Error: {e}",
2, 2,
) )
raise Exception(e) return {}
async def get_users_watched( async def get_users_watched(
self, self,

View File

@@ -80,20 +80,19 @@ def get_user_library_watched(user, user_plex, library):
# Get all watched episodes for show # Get all watched episodes for show
episode_guids = {} episode_guids = {}
for episode in show.watched(): for episode in show.watched():
if episode.viewCount > 0: episode_guids_temp = {}
episode_guids_temp = {} for guid in episode.guids:
for guid in episode.guids: # Extract after :// from guid.id
# Extract after :// from guid.id m = re.match(r"(.*)://(.*)", guid.id)
m = re.match(r"(.*)://(.*)", guid.id) guid_source, guid_id = m.group(1).lower(), m.group(2)
guid_source, guid_id = m.group(1).lower(), m.group(2) episode_guids_temp[guid_source] = guid_id
episode_guids_temp[guid_source] = guid_id
episode_guids_temp["locations"] = tuple( episode_guids_temp["locations"] = tuple(
[x.split("/")[-1] for x in episode.locations] [x.split("/")[-1] for x in episode.locations]
) )
if episode.parentTitle not in episode_guids: if episode.parentTitle not in episode_guids:
episode_guids[episode.parentTitle] = [] episode_guids[episode.parentTitle] = []
episode_guids[episode.parentTitle].append(episode_guids_temp) episode_guids[episode.parentTitle].append(episode_guids_temp)
if episode_guids: if episode_guids:
# append show, season, episode # append show, season, episode
@@ -116,7 +115,7 @@ def get_user_library_watched(user, user_plex, library):
f"Plex: Failed to get watched for {user_name} in library {library.title}, Error: {e}", f"Plex: Failed to get watched for {user_name} in library {library.title}, Error: {e}",
2, 2,
) )
raise Exception(e) return {}
def update_user_watched(user, user_plex, library, videos, dryrun): def update_user_watched(user, user_plex, library, videos, dryrun):