Merge pull request #182 from luigi311/dev

Jellyfin: Skip partial on version lower than 10.9
This commit is contained in:
Luigi311
2024-07-15 03:36:40 -06:00
committed by GitHub
8 changed files with 67 additions and 54 deletions

Binary file not shown.

View File

@@ -4,6 +4,7 @@ import traceback, os
from math import floor from math import floor
from dotenv import load_dotenv from dotenv import load_dotenv
import requests import requests
from packaging import version
from src.functions import ( from src.functions import (
logger, logger,
@@ -25,7 +26,6 @@ load_dotenv(override=True)
generate_guids = str_to_bool(os.getenv("GENERATE_GUIDS", "True")) generate_guids = str_to_bool(os.getenv("GENERATE_GUIDS", "True"))
generate_locations = str_to_bool(os.getenv("GENERATE_LOCATIONS", "True")) generate_locations = str_to_bool(os.getenv("GENERATE_LOCATIONS", "True"))
def get_guids(server_type, item): def get_guids(server_type, item):
if item.get("Name"): if item.get("Name"):
guids = {"title": item.get("Name")} guids = {"title": item.get("Name")}
@@ -125,6 +125,7 @@ class JellyfinEmby:
raise Exception(f"{self.server_type} token not set") raise Exception(f"{self.server_type} token not set")
self.session = requests.Session() self.session = requests.Session()
self.version = version.parse(self.info(version=True))
self.users = self.get_users() self.users = self.get_users()
def query(self, query, query_type, identifiers=None, json=None): def query(self, query, query_type, identifiers=None, json=None):
@@ -177,13 +178,17 @@ class JellyfinEmby:
) )
raise Exception(e) raise Exception(e)
def info(self) -> str: def info(self, version=False) -> str:
try: try:
query_string = "/System/Info/Public" query_string = "/System/Info/Public"
response = self.query(query_string, "get") response = self.query(query_string, "get")
if response: if response:
# Return version only if requested
if version:
return response['Version']
return f"{self.server_type} {response['ServerName']}: {response['Version']}" return f"{self.server_type} {response['ServerName']}: {response['Version']}"
else: else:
return None return None
@@ -560,6 +565,10 @@ class JellyfinEmby:
library, library,
jellyfin_video.get("Name"), jellyfin_video.get("Name"),
) )
else:
# 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: 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}" 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}"
@@ -689,6 +698,10 @@ class JellyfinEmby:
jellyfin_episode.get("SeriesName"), jellyfin_episode.get("SeriesName"),
jellyfin_episode.get("Name"), jellyfin_episode.get("Name"),
) )
else:
# 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: else:
msg = ( msg = (
f"{self.server_type}: {jellyfin_episode['SeriesName']} {jellyfin_episode['SeasonName']} Episode {jellyfin_episode.get('IndexNumber')} {jellyfin_episode.get('Name')}" f"{self.server_type}: {jellyfin_episode['SeriesName']} {jellyfin_episode['SeasonName']} Episode {jellyfin_episode.get('IndexNumber')} {jellyfin_episode.get('Name')}"

View File

@@ -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 ## 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 ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly
## Comma seperated list for multiple servers ## 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/ ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
## Comma seperated list for multiple servers ## Comma seperated list for multiple servers

View File

@@ -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 ## 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 ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly
## Comma seperated list for multiple servers ## 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/ ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
## Comma seperated list for multiple servers ## Comma seperated list for multiple servers

View File

@@ -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 ## 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 ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly
## Comma seperated list for multiple servers ## 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/ ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
## Comma seperated list for multiple servers ## Comma seperated list for multiple servers

View File

@@ -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 ## 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 ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly
## Comma seperated list for multiple servers ## 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/ ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
## Comma seperated list for multiple servers ## Comma seperated list for multiple servers

View File

@@ -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 ## 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 ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly
## Comma seperated list for multiple servers ## 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/ ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
## Comma seperated list for multiple servers ## Comma seperated list for multiple servers

View File

@@ -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 ## 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 ## URL of the plex server, use hostname or IP address if the hostname is not resolving correctly
## Comma seperated list for multiple servers ## 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/ ## Plex token https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
## Comma seperated list for multiple servers ## Comma seperated list for multiple servers