Jellyfin: Remove episode filter as it doesnt exist in jellyfin

pull/174/head
Luis Garcia 2024-06-02 22:07:58 -06:00
parent 7119956ec7
commit 1a7178e32d
2 changed files with 66 additions and 73 deletions

View File

@ -184,7 +184,7 @@ class JellyfinEmby:
response = self.query(query_string, "get")
if response:
return f"{response['ServerName']}: {response['Version']}"
return f"{self.server_type} {response['ServerName']}: {response['Version']}"
else:
return None
@ -229,19 +229,23 @@ class JellyfinEmby:
f"/Users/{user_id}/Items"
+ f"?ParentId={library_id}&Filters=IsPlayed&IncludeItemTypes=Movie&Recursive=True&Fields=ItemCounts,ProviderIds,MediaSources",
"get",
)
).get("Items", [])
in_progress = self.query(
f"/Users/{user_id}/Items"
+ f"?ParentId={library_id}&Filters=IsResumable&IncludeItemTypes=Movie&Recursive=True&Fields=ItemCounts,ProviderIds,MediaSources",
"get",
)
).get("Items", [])
for movie in watched["Items"] + in_progress["Items"]:
if "MediaSources" in movie and movie["MediaSources"] != {}:
for movie in watched + in_progress:
# Skip if theres no user data which means the movie has not been watched
if "UserData" not in movie:
continue
# Skip if theres no media tied to the movie
if "MediaSources" not in movie or movie["MediaSources"] == {}:
continue
# Skip if not watched or watched less than a minute
if (
movie["UserData"]["Played"] == True
@ -272,21 +276,18 @@ class JellyfinEmby:
f"/Users/{user_id}/Items"
+ f"?ParentId={library_id}&isPlaceHolder=false&IncludeItemTypes=Series&Recursive=True&Fields=ProviderIds,Path,RecursiveItemCount",
"get",
)
).get("Items", [])
# Filter the list of shows to only include those that have been partially or fully watched
watched_shows_filtered = []
for show in watched_shows["Items"]:
if not "UserData" in show:
for show in watched_shows:
if "UserData" not in show:
continue
if "PlayedPercentage" in show["UserData"]:
if show["UserData"]["PlayedPercentage"] > 0:
watched_shows_filtered.append(show)
# Create a list of tasks to retrieve the episodes
watched_episodes = []
# Retrieve the watched/partially watched list of episodes of each watched show
for show in watched_shows_filtered:
logger(
@ -308,50 +309,42 @@ class JellyfinEmby:
show_guids = frozenset(show_guids.items())
watched_task = self.query(
show_episodes = self.query(
f"/Shows/{show['Id']}/Episodes"
+ f"?userId={user_id}&isPlaceHolder=false&Filters=IsPlayed&Fields=ProviderIds,MediaSources",
+ f"?userId={user_id}&isPlaceHolder=false&Fields=ProviderIds,MediaSources",
"get",
)
).get("Items", [])
in_progress_task = self.query(
f"/Shows/{show['Id']}/Episodes"
+ f"?userId={user_id}&isPlaceHolder=false&Filters=IsResumable&Fields=ProviderIds,MediaSources",
"get",
)
watched_episodes.append(watched_task)
watched_episodes.append(in_progress_task)
# Iterate through the watched episodes
for episodes in watched_episodes:
# If has any watched episodes
if len(episodes["Items"]) > 0:
# Iterate through the episodes
# Create a list to store the episodes
episodes_list = []
for episode in episodes["Items"]:
mark_episodes_list = []
for episode in show_episodes:
if "UserData" not in episode:
continue
if (
"MediaSources" in episode
and episode["MediaSources"] != {}
"MediaSources" not in episode
or episode["MediaSources"] == {}
):
continue
# If watched or watched more than a minute
if (
episode["UserData"]["Played"] == True
or episode["UserData"]["PlaybackPositionTicks"]
> 600000000
or episode["UserData"]["PlaybackPositionTicks"] > 600000000
):
episode_guids = get_guids(
self.server_type, episode
)
episodes_list.append(episode_guids)
episode_guids = get_guids(self.server_type, episode)
mark_episodes_list.append(episode_guids)
if mark_episodes_list:
# Add the show dictionary to the user's watched list
if show_guids not in user_watched[user_name][library_title]:
user_watched[user_name][library_title][show_guids] = []
user_watched[user_name][library_title][
show_guids
] = episodes_list
for episode in episodes_list:
] = mark_episodes_list
for episode in mark_episodes_list:
logger(
f"{self.server_type}: Added {episode} to {user_name} {show_display_name} watched list",
1,

View File

@ -452,7 +452,7 @@ class Plex:
raise Exception(e)
def info(self) -> str:
return f"{self.plex.friendlyName}: {self.plex.version}"
return f"Plex {self.plex.friendlyName}: {self.plex.version}"
def get_users(self):
try: