Jellyfin: Handle missing paths

Signed-off-by: Luigi311 <git@luigi311.com>
This commit is contained in:
Luigi311
2023-06-28 16:21:07 -06:00
parent 3fa55cb41b
commit ff2e2deb20

View File

@@ -49,8 +49,11 @@ def get_episode_guids(episode):
# Create a dictionary for the episode with its provider IDs and media sources # Create a dictionary for the episode with its provider IDs and media sources
episode_dict = {k.lower(): v for k, v in episode["ProviderIds"].items()} episode_dict = {k.lower(): v for k, v in episode["ProviderIds"].items()}
episode_dict["title"] = episode["Name"] episode_dict["title"] = episode["Name"]
episode_dict["locations"] = tuple(
[x["Path"].split("/")[-1] for x in episode["MediaSources"]] episode_dict["locations"] = (
tuple([x["Path"].split("/")[-1] for x in ["MediaSources"] if "Path" in x])
if "MediaSources" in episode
else tuple()
) )
episode_dict["status"] = { episode_dict["status"] = {
@@ -238,7 +241,11 @@ class Jellyfin:
k.lower(): v for k, v in show["ProviderIds"].items() k.lower(): v for k, v in show["ProviderIds"].items()
} }
show_guids["title"] = show["Name"] show_guids["title"] = show["Name"]
show_guids["locations"] = tuple([show["Path"].split("/")[-1]]) show_guids["locations"] = (
tuple([show["Path"].split("/")[-1]])
if "Path" in show
else tuple()
)
show_guids = frozenset(show_guids.items()) show_guids = frozenset(show_guids.items())
show_identifiers = { show_identifiers = {
"show_guids": show_guids, "show_guids": show_guids,
@@ -550,24 +557,27 @@ class Jellyfin:
if "MediaSources" in jellyfin_video: if "MediaSources" in jellyfin_video:
for movie_location in jellyfin_video["MediaSources"]: for movie_location in jellyfin_video["MediaSources"]:
if ( if "Path" in movie_location:
contains_nested( if (
movie_location["Path"].split("/")[-1], contains_nested(
videos_movies_ids["locations"], movie_location["Path"].split("/")[-1],
) videos_movies_ids["locations"],
is not None )
): is not None
for video in videos: ):
if ( for video in videos:
contains_nested( if (
movie_location["Path"].split("/")[-1], contains_nested(
video["locations"], movie_location["Path"].split("/")[
) -1
is not None ],
): video["locations"],
movie_status = video["status"] )
break is not None
break ):
movie_status = video["status"]
break
break
if not movie_status: if not movie_status:
for ( for (
@@ -697,26 +707,31 @@ class Jellyfin:
for episode_location in jellyfin_episode[ for episode_location in jellyfin_episode[
"MediaSources" "MediaSources"
]: ]:
if ( if "Path" in episode_location:
contains_nested( if (
episode_location["Path"].split("/")[-1], contains_nested(
videos_episodes_ids["locations"], episode_location["Path"].split("/")[
) -1
is not None ],
): videos_episodes_ids["locations"],
for episode in episode_videos: )
if ( is not None
contains_nested( ):
episode_location["Path"].split( for episode in episode_videos:
"/" if (
)[-1], contains_nested(
episode["locations"], episode_location[
) "Path"
is not None ].split("/")[-1],
): episode["locations"],
episode_status = episode["status"] )
break is not None
break ):
episode_status = episode[
"status"
]
break
break
if not episode_status: if not episode_status:
for ( for (