Skip to content

Commit

Permalink
Merge pull request #90 from luigi311/dev
Browse files Browse the repository at this point in the history
Fix missing paths and providers
  • Loading branch information
luigi311 authored Jul 1, 2023
2 parents 89c4f15 + 81e9678 commit ce1b922
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 51 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
runs-on: ubuntu-latest
needs: pytest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile.alpine
Expand Down
4 changes: 2 additions & 2 deletions src/black_white.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup_black_white_lists(
blacklist_library,
blacklist_library_type,
blacklist_users,
"White",
"Black",
library_mapping,
user_mapping,
)
Expand All @@ -24,7 +24,7 @@ def setup_black_white_lists(
whitelist_library,
whitelist_library_type,
whitelist_users,
"Black",
"White",
library_mapping,
user_mapping,
)
Expand Down
117 changes: 68 additions & 49 deletions src/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ def get_episode_guids(episode):
# 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["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"] = {
Expand Down Expand Up @@ -238,7 +241,11 @@ async def get_user_library_watched(
k.lower(): v for k, v in show["ProviderIds"].items()
}
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_identifiers = {
"show_guids": show_guids,
Expand Down Expand Up @@ -550,24 +557,27 @@ async def update_user_watched(

if "MediaSources" in jellyfin_video:
for movie_location in jellyfin_video["MediaSources"]:
if (
contains_nested(
movie_location["Path"].split("/")[-1],
videos_movies_ids["locations"],
)
is not None
):
for video in videos:
if (
contains_nested(
movie_location["Path"].split("/")[-1],
video["locations"],
)
is not None
):
movie_status = video["status"]
break
break
if "Path" in movie_location:
if (
contains_nested(
movie_location["Path"].split("/")[-1],
videos_movies_ids["locations"],
)
is not None
):
for video in videos:
if (
contains_nested(
movie_location["Path"].split("/")[
-1
],
video["locations"],
)
is not None
):
movie_status = video["status"]
break
break

if not movie_status:
for (
Expand Down Expand Up @@ -697,26 +707,31 @@ async def update_user_watched(
for episode_location in jellyfin_episode[
"MediaSources"
]:
if (
contains_nested(
episode_location["Path"].split("/")[-1],
videos_episodes_ids["locations"],
)
is not None
):
for episode in episode_videos:
if (
contains_nested(
episode_location["Path"].split(
"/"
)[-1],
episode["locations"],
)
is not None
):
episode_status = episode["status"]
break
break
if "Path" in episode_location:
if (
contains_nested(
episode_location["Path"].split("/")[
-1
],
videos_episodes_ids["locations"],
)
is not None
):
for episode in episode_videos:
if (
contains_nested(
episode_location[
"Path"
].split("/")[-1],
episode["locations"],
)
is not None
):
episode_status = episode[
"status"
]
break
break

if not episode_status:
for (
Expand All @@ -735,15 +750,19 @@ async def update_user_watched(
):
for episode in episode_videos:
if (
episode_provider_id.lower()
in episode[
episode_provider_source.lower()
]
episode_provider_source.lower()
in episode
):
episode_status = episode[
"status"
]
break
if (
episode_provider_id.lower()
in episode[
episode_provider_source.lower()
]
):
episode_status = episode[
"status"
]
break
break

if episode_status:
Expand Down

0 comments on commit ce1b922

Please sign in to comment.