Merge pull request #228 from luigi311/misc

Misc
This commit is contained in:
Luigi311
2025-02-21 14:54:10 -07:00
committed by GitHub
5 changed files with 31 additions and 35 deletions

4
.vscode/launch.json vendored
View File

@@ -6,7 +6,7 @@
"configurations": [ "configurations": [
{ {
"name": "Python: Main", "name": "Python: Main",
"type": "python", "type": "debugpy",
"request": "launch", "request": "launch",
"program": "main.py", "program": "main.py",
"console": "integratedTerminal", "console": "integratedTerminal",
@@ -14,7 +14,7 @@
}, },
{ {
"name": "Pytest", "name": "Pytest",
"type": "python", "type": "debugpy",
"request": "launch", "request": "launch",
"module": "pytest", "module": "pytest",
"args": [ "args": [

View File

@@ -1,9 +1,9 @@
import sys import sys
if __name__ == "__main__": if __name__ == "__main__":
# Check python version 3.9 or higher # Check python version 3.12 or higher
if not (3, 9) <= tuple(map(int, sys.version_info[:2])): if not (3, 12) <= tuple(map(int, sys.version_info[:2])):
print("This script requires Python 3.9 or higher") print("This script requires Python 3.12 or higher")
sys.exit(1) sys.exit(1)
from src.main import main from src.main import main

View File

@@ -1,6 +1,7 @@
# Functions for Jellyfin and Emby # Functions for Jellyfin and Emby
import traceback, os import traceback
import os
from math import floor from math import floor
from typing import Any, Literal from typing import Any, Literal
from dotenv import load_dotenv from dotenv import load_dotenv
@@ -210,32 +211,17 @@ class JellyfinEmby:
for _, user_id in users.items(): for _, user_id in users.items():
user_libraries: dict = self.query(f"/Users/{user_id}/Views", "get") user_libraries: dict = self.query(f"/Users/{user_id}/Views", "get")
for library in user_libraries["Items"]: for library in user_libraries["Items"]:
library_id = library["Id"]
library_title = library["Name"] library_title = library["Name"]
library_type = library.get("CollectionType")
# Get library items to check the type if library_type not in ["movies", "tvshows"]:
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:
logger( 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, 1,
) )
else: continue
libraries[library_title] = str(types)
libraries[library_title] = library_type
return libraries return libraries
except Exception as e: except Exception as e:
@@ -427,9 +413,9 @@ class JellyfinEmby:
if user_name.lower() not in users_watched: if user_name.lower() not in users_watched:
users_watched[user_name.lower()] = UserData() users_watched[user_name.lower()] = UserData()
users_watched[user_name.lower()].libraries[ users_watched[user_name.lower()].libraries[library_title] = (
library_title library_data
] = library_data )
return users_watched return users_watched
except Exception as e: except Exception as e:

View File

@@ -1,4 +1,6 @@
import os, traceback, json import os
import traceback
import json
from dotenv import load_dotenv from dotenv import load_dotenv
from time import sleep, perf_counter from time import sleep, perf_counter

View File

@@ -1,4 +1,5 @@
import os, requests import os
import requests
from dotenv import load_dotenv from dotenv import load_dotenv
from urllib3.poolmanager import PoolManager from urllib3.poolmanager import PoolManager
@@ -286,6 +287,13 @@ class Plex:
library_title = library.title library_title = library.title
library_type = library.type 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 output[library_title] = library_type
return output return output
@@ -397,9 +405,9 @@ class Plex:
if user.title.lower() not in users_watched: if user.title.lower() not in users_watched:
users_watched[user.title.lower()] = UserData() users_watched[user.title.lower()] = UserData()
users_watched[user.title.lower()].libraries[ users_watched[user.title.lower()].libraries[library.title] = (
library.title library_data
] = library_data )
return users_watched return users_watched
except Exception as e: except Exception as e: