From 0b02f531c1ade7f13cbe46c6ffe9476805ef5bde Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Fri, 21 Feb 2025 12:10:53 -0700 Subject: [PATCH 1/4] Force python 3.12 or greater Signed-off-by: Luis Garcia --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 51917e2..d38ea06 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,9 @@ import sys if __name__ == "__main__": - # Check python version 3.9 or higher - if not (3, 9) <= tuple(map(int, sys.version_info[:2])): - print("This script requires Python 3.9 or higher") + # Check python version 3.12 or higher + if not (3, 12) <= tuple(map(int, sys.version_info[:2])): + print("This script requires Python 3.12 or higher") sys.exit(1) from src.main import main From 998f2b12099178485856baefc331c15e888e354f Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Fri, 21 Feb 2025 14:41:19 -0700 Subject: [PATCH 2/4] Formatting Signed-off-by: Luis Garcia --- src/jellyfin_emby.py | 9 +++++---- src/main.py | 4 +++- src/plex.py | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/jellyfin_emby.py b/src/jellyfin_emby.py index 5b5dd9c..81b2145 100644 --- a/src/jellyfin_emby.py +++ b/src/jellyfin_emby.py @@ -1,6 +1,7 @@ # Functions for Jellyfin and Emby -import traceback, os +import traceback +import os from math import floor from typing import Any, Literal from dotenv import load_dotenv @@ -427,9 +428,9 @@ class JellyfinEmby: if user_name.lower() not in users_watched: users_watched[user_name.lower()] = UserData() - users_watched[user_name.lower()].libraries[ - library_title - ] = library_data + users_watched[user_name.lower()].libraries[library_title] = ( + library_data + ) return users_watched except Exception as e: diff --git a/src/main.py b/src/main.py index 91765b1..5c5765d 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,6 @@ -import os, traceback, json +import os +import traceback +import json from dotenv import load_dotenv from time import sleep, perf_counter diff --git a/src/plex.py b/src/plex.py index 573e908..0260bc1 100644 --- a/src/plex.py +++ b/src/plex.py @@ -1,4 +1,5 @@ -import os, requests +import os +import requests from dotenv import load_dotenv from urllib3.poolmanager import PoolManager @@ -397,9 +398,9 @@ class Plex: if user.title.lower() not in users_watched: users_watched[user.title.lower()] = UserData() - users_watched[user.title.lower()].libraries[ - library.title - ] = library_data + users_watched[user.title.lower()].libraries[library.title] = ( + library_data + ) return users_watched except Exception as e: From de32d59aa1a65df0422f270c4aab7e22bd18e7ed Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Fri, 21 Feb 2025 14:41:42 -0700 Subject: [PATCH 3/4] Better initial library filtering Filter for only tv shows and movie type libraries in plex and jellyfin. Jellyfin no longer require pulling in multiple different items and instead use the actual library category Signed-off-by: Luis Garcia --- src/jellyfin_emby.py | 27 ++++++--------------------- src/plex.py | 7 +++++++ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/jellyfin_emby.py b/src/jellyfin_emby.py index 81b2145..513b4b7 100644 --- a/src/jellyfin_emby.py +++ b/src/jellyfin_emby.py @@ -211,32 +211,17 @@ class JellyfinEmby: for _, user_id in users.items(): user_libraries: dict = self.query(f"/Users/{user_id}/Views", "get") for library in user_libraries["Items"]: - library_id = library["Id"] library_title = library["Name"] + library_type = library.get("CollectionType") - # Get library items to check the type - media_info = self.query( - f"/Users/{user_id}/Items" - + f"?ParentId={library_id}&Filters=IsPlayed&Recursive=True&excludeItemTypes=Folder&limit=100", - "get", - ) - - types = set( - [ - x["Type"] - for x in media_info["Items"] - if x["Type"] in ["Movie", "Series", "Episode"] - ] - ) - all_types = set([x["Type"] for x in media_info["Items"]]) - - if not types: + if library_type not in ["movies", "tvshows"]: logger( - f"{self.server_type}: Skipping Library {library_title} found wanted types: {all_types}", + f"{self.server_type}: Skipping Library {library_title} found type {library_type}", 1, ) - else: - libraries[library_title] = str(types) + continue + + libraries[library_title] = library_type return libraries except Exception as e: diff --git a/src/plex.py b/src/plex.py index 0260bc1..81ef95c 100644 --- a/src/plex.py +++ b/src/plex.py @@ -287,6 +287,13 @@ class Plex: library_title = library.title library_type = library.type + if library_type not in ["movie", "show"]: + logger( + f"Plex: Skipping Library {library_title} found type {library_type}", + 1, + ) + continue + output[library_title] = library_type return output From 38e65f5a17fdb906440505414fe13d379baa915f Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Fri, 21 Feb 2025 14:47:14 -0700 Subject: [PATCH 4/4] vscode: Fix deprecated python debug type Signed-off-by: Luis Garcia --- .vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 60cea81..6d00f83 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,7 +6,7 @@ "configurations": [ { "name": "Python: Main", - "type": "python", + "type": "debugpy", "request": "launch", "program": "main.py", "console": "integratedTerminal", @@ -14,7 +14,7 @@ }, { "name": "Pytest", - "type": "python", + "type": "debugpy", "request": "launch", "module": "pytest", "args": [