Skip to content

Commit

Permalink
feat: add jellyfin & emby support.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreulavelle committed Sep 22, 2024
1 parent 220a0b5 commit 375302e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/program/settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,23 @@ class PlexLibraryModel(Observable):
url: str = "http://localhost:32400"


class JellyfinLibraryModel(Observable):
enabled: bool = False
api_key: str = ""
url: str = "http://localhost:8096"


class EmbyLibraryModel(Observable):
enabled: bool = False
api_key: str = ""
url: str = "http://localhost:8096"


class UpdatersModel(Observable):
updater_interval: int = 120
plex: PlexLibraryModel = PlexLibraryModel()
jellyfin: JellyfinLibraryModel = JellyfinLibraryModel()
emby: EmbyLibraryModel = EmbyLibraryModel()


# Content Services
Expand Down
11 changes: 7 additions & 4 deletions src/program/updaters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Updater module"""
from program.media.item import MediaItem
from program.updaters.plex import PlexUpdater
from program.updaters.jellyfin import JellyfinUpdater
from program.updaters.emby import EmbyUpdater
from utils.logger import logger


Expand All @@ -9,13 +11,14 @@ def __init__(self):
self.key = "updater"
self.services = {
PlexUpdater: PlexUpdater(),
JellyfinUpdater: JellyfinUpdater(),
EmbyUpdater: EmbyUpdater(),
}
self.initialized = True

def validate(self) -> bool:
"""Validate that at least one updater service is initialized."""
initialized_services = [service for service in self.services.values() if service.initialized]

return len(initialized_services) > 0

def run(self, item: MediaItem):
Expand All @@ -30,9 +33,9 @@ def run(self, item: MediaItem):
except Exception as e:
logger.error(f"{service_cls.__name__} failed to update {item.log_string}: {e}")

# Lets update the attributes of the item and its children, we dont care if the service updated it or not.
for _item in get_items_to_update(item):
_item.set("update_folder", "updated")
# Lets update the attributes of the item and its children, we dont care if the service updated it or not.
for _item in get_items_to_update(item):
_item.set("update_folder", "updated")
yield item

def get_items_to_update(item: MediaItem) -> list[MediaItem]:
Expand Down
4 changes: 2 additions & 2 deletions src/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_log_settings(name, default_color, default_icon):
"DATABASE": (37, "d834eb", "πŸ›’οΈ"),
"DEBRID": (38, "cc3333", "πŸ”—"),
"SYMLINKER": (39, "F9E79F", "πŸ”—"),
"SCRAPER": (40, "D299EA", "πŸ‘»"),
"SCRAPER": (40, "3D5A80", "πŸ‘»"),
"COMPLETED": (41, "FFFFFF", "🟒"),
"CACHE": (42, "527826", "πŸ“œ"),
"NOT_FOUND": (43, "818589", "πŸ€·β€"),
Expand All @@ -55,7 +55,7 @@ def get_log_settings(name, default_color, default_icon):
logger.level(name, no=no, color=color, icon=icon)

# Default log levels
debug_color, debug_icon = get_log_settings("DEBUG", "ff69b4", "🐞")
debug_color, debug_icon = get_log_settings("DEBUG", "98C1D9", "🐞")
info_color, info_icon = get_log_settings("INFO", "818589", "πŸ“°")
warning_color, warning_icon = get_log_settings("WARNING", "ffcc00", "⚠️ ")
critical_color, critical_icon = get_log_settings("CRITICAL", "ff0000", "")
Expand Down

0 comments on commit 375302e

Please sign in to comment.