Skip to content

Commit

Permalink
Merge pull request #228 from luigi311/misc
Browse files Browse the repository at this point in the history
Misc
  • Loading branch information
luigi311 authored Feb 21, 2025
2 parents e589935 + 38e65f5 commit 8f4a2e2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"configurations": [
{
"name": "Python: Main",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "main.py",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Pytest",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"args": [
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
36 changes: 11 additions & 25 deletions src/jellyfin_emby.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -210,32 +211,17 @@ def get_libraries(self) -> dict[str, str]:
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:
Expand Down Expand Up @@ -427,9 +413,9 @@ def get_watched(
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:
Expand Down
4 changes: 3 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
16 changes: 12 additions & 4 deletions src/plex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, requests
import os
import requests
from dotenv import load_dotenv

from urllib3.poolmanager import PoolManager
Expand Down Expand Up @@ -286,6 +287,13 @@ def get_libraries(self) -> dict[str, str]:
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
Expand Down Expand Up @@ -397,9 +405,9 @@ def get_watched(self, users, sync_libraries) -> dict[str, UserData]:
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:
Expand Down

0 comments on commit 8f4a2e2

Please sign in to comment.