From d30e03b7021ea35ff00c1a1c1273e2bb8f149898 Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Mon, 15 Jul 2024 03:01:53 -0600 Subject: [PATCH 1/3] Jellyfin: Skip partial on version lower than 10.9 --- requirements.txt | Bin 57 -> 150 bytes src/jellyfin_emby.py | 109 ++++++++++++++++++++++++------------------- 2 files changed, 61 insertions(+), 48 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1a8abf38a6d6a05e118366f7e8b31b8d7816dae1..ba302df70d60108bbc864df05023a202a1919db9 100644 GIT binary patch literal 150 zcmXYq%L;=~3`Ebm;HM})an*&(?)(K&QK?wp*q^V?y_JwjV9q4xZ=|5)Ep6x+q)$~y zj7NaOgPfk4gG}4Yx_>Vbky>Kp%Sy{fd6!CaRbpVbbRf>RZLZC7CN}9JYPr98MEYqs F!(6Gk7dHR^ literal 57 zcmWH@Nv&`U@U*ox(K9sFGw0 str: + def info(self, version=False) -> str: try: query_string = "/System/Info/Public" response = self.query(query_string, "get") if response: + # Return version only if requested + if version: + return response['Version'] + return f"{self.server_type} {response['ServerName']}: {response['Version']}" else: return None @@ -561,28 +566,32 @@ def update_user_watched( jellyfin_video.get("Name"), ) else: - msg = f"{self.server_type}: {jellyfin_video.get('Name')} as partially watched for {floor(movie_status['time'] / 60_000)} minutes for {user_name} in {library}" - - if not dryrun: - logger(msg, 5) - playback_position_payload = { - "PlaybackPositionTicks": movie_status["time"] - * 10_000, - } - self.query( - f"/Users/{user_id}/Items/{jellyfin_video_id}/UserData", - "post", - json=playback_position_payload, - ) + # Handle partially watched movies not supported in jellyfin < 10.9.0 + if self.server_type == "Jellyfin" and self.version < version.parse("10.9.0"): + logger(f"{self.server_type}: Skipping movie {jellyfin_video.get('Name')} as partially watched not supported in Jellyfin < 10.9.0", 4) else: - logger(msg, 6) + msg = f"{self.server_type}: {jellyfin_video.get('Name')} as partially watched for {floor(movie_status['time'] / 60_000)} minutes for {user_name} in {library}" + + if not dryrun: + logger(msg, 5) + playback_position_payload = { + "PlaybackPositionTicks": movie_status["time"] + * 10_000, + } + self.query( + f"/Users/{user_id}/Items/{jellyfin_video_id}/UserData", + "post", + json=playback_position_payload, + ) + else: + logger(msg, 6) - log_marked( - user_name, - library, - jellyfin_video.get("Name"), - duration=floor(movie_status["time"] / 60_000), - ) + log_marked( + user_name, + library, + jellyfin_video.get("Name"), + duration=floor(movie_status["time"] / 60_000), + ) else: logger( f"{self.server_type}: Skipping movie {jellyfin_video.get('Name')} as it is not in mark list for {user_name}", @@ -690,34 +699,38 @@ def update_user_watched( jellyfin_episode.get("Name"), ) else: - msg = ( - f"{self.server_type}: {jellyfin_episode['SeriesName']} {jellyfin_episode['SeasonName']} Episode {jellyfin_episode.get('IndexNumber')} {jellyfin_episode.get('Name')}" - + f" as partially watched for {floor(episode_status['time'] / 60_000)} minutes for {user_name} in {library}" - ) - - if not dryrun: - logger(msg, 5) - playback_position_payload = { - "PlaybackPositionTicks": episode_status[ - "time" - ] - * 10_000, - } - self.query( - f"/Users/{user_id}/Items/{jellyfin_episode_id}/UserData", - "post", - json=playback_position_payload, - ) + # Handle partially watched episodes not supported in jellyfin < 10.9.0 + if self.server_type == "Jellyfin" and self.version < version.parse("10.9.0"): + logger(f"{self.server_type}: Skipping episode {jellyfin_episode.get('Name')} as partially watched not supported in Jellyfin < 10.9.0", 4) else: - logger(msg, 6) + msg = ( + f"{self.server_type}: {jellyfin_episode['SeriesName']} {jellyfin_episode['SeasonName']} Episode {jellyfin_episode.get('IndexNumber')} {jellyfin_episode.get('Name')}" + + f" as partially watched for {floor(episode_status['time'] / 60_000)} minutes for {user_name} in {library}" + ) - log_marked( - user_name, - library, - jellyfin_episode.get("SeriesName"), - jellyfin_episode.get("Name"), - duration=floor(episode_status["time"] / 60_000), - ) + if not dryrun: + logger(msg, 5) + playback_position_payload = { + "PlaybackPositionTicks": episode_status[ + "time" + ] + * 10_000, + } + self.query( + f"/Users/{user_id}/Items/{jellyfin_episode_id}/UserData", + "post", + json=playback_position_payload, + ) + else: + logger(msg, 6) + + log_marked( + user_name, + library, + jellyfin_episode.get("SeriesName"), + jellyfin_episode.get("Name"), + duration=floor(episode_status["time"] / 60_000), + ) else: logger( f"{self.server_type}: Skipping episode {jellyfin_episode.get('Name')} as it is not in mark list for {user_name}", From bd75d865ba2edd5c3153c2b3919d2d5442262c21 Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Mon, 15 Jul 2024 03:03:44 -0600 Subject: [PATCH 2/3] Update PlexAPI and requests --- requirements.txt | Bin 150 -> 152 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/requirements.txt b/requirements.txt index ba302df70d60108bbc864df05023a202a1919db9..c5a3509915cbbb1e3ba09c1d1628fbed70cfc666 100644 GIT binary patch delta 20 bcmbQnID>J51G6E6=|o3=He&`}1}+8wG+hJR delta 18 ZcmbQiIE`_F1EcvwXMZ*W23`g(1^_ME1E~N2 From 99c339c405d158ec68c7458c27e08b0c0c9ce412 Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Mon, 15 Jul 2024 03:28:59 -0600 Subject: [PATCH 3/3] CI: Plex remove https --- test/ci_emby.env | 2 +- test/ci_guids.env | 2 +- test/ci_jellyfin.env | 2 +- test/ci_locations.env | 2 +- test/ci_plex.env | 2 +- test/ci_write.env | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/ci_emby.env b/test/ci_emby.env index 73c7af5..cd91107 100644 --- a/test/ci_emby.env +++ b/test/ci_emby.env @@ -62,7 +62,7 @@ WHITELIST_USERS = "jellyplex_watched" ## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers -PLEX_BASEURL = "https://localhost:32400" +PLEX_BASEURL = "http://localhost:32400" ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ ## Comma seperated list for multiple servers diff --git a/test/ci_guids.env b/test/ci_guids.env index 485d8e8..0a6a519 100644 --- a/test/ci_guids.env +++ b/test/ci_guids.env @@ -62,7 +62,7 @@ WHITELIST_USERS = "jellyplex_watched" ## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers -PLEX_BASEURL = "https://localhost:32400" +PLEX_BASEURL = "http://localhost:32400" ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ ## Comma seperated list for multiple servers diff --git a/test/ci_jellyfin.env b/test/ci_jellyfin.env index 4202f37..06818b4 100644 --- a/test/ci_jellyfin.env +++ b/test/ci_jellyfin.env @@ -62,7 +62,7 @@ WHITELIST_USERS = "jellyplex_watched" ## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers -PLEX_BASEURL = "https://localhost:32400" +PLEX_BASEURL = "http://localhost:32400" ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ ## Comma seperated list for multiple servers diff --git a/test/ci_locations.env b/test/ci_locations.env index bc1bedf..88b6992 100644 --- a/test/ci_locations.env +++ b/test/ci_locations.env @@ -62,7 +62,7 @@ WHITELIST_USERS = "jellyplex_watched" ## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers -PLEX_BASEURL = "https://localhost:32400" +PLEX_BASEURL = "http://localhost:32400" ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ ## Comma seperated list for multiple servers diff --git a/test/ci_plex.env b/test/ci_plex.env index 97d01dc..54b24e5 100644 --- a/test/ci_plex.env +++ b/test/ci_plex.env @@ -62,7 +62,7 @@ WHITELIST_USERS = "jellyplex_watched" ## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers -PLEX_BASEURL = "https://localhost:32400" +PLEX_BASEURL = "http://localhost:32400" ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ ## Comma seperated list for multiple servers diff --git a/test/ci_write.env b/test/ci_write.env index 5e229f0..8d364d0 100644 --- a/test/ci_write.env +++ b/test/ci_write.env @@ -62,7 +62,7 @@ WHITELIST_USERS = "jellyplex_watched" ## Recommended to use token as it is faster to connect as it is direct to the server instead of going through the plex servers ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly ## Comma seperated list for multiple servers -PLEX_BASEURL = "https://localhost:32400" +PLEX_BASEURL = "http://localhost:32400" ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ ## Comma seperated list for multiple servers