-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add concurrency, fix shows * Run prettier on default_settings.json * Better logging, added item_ids and extended info endpoint for shows --------- Co-authored-by: Gaisberg <None>
- Loading branch information
Showing
19 changed files
with
671 additions
and
581 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"""Program main module""" | ||
import os | ||
from typing import Optional | ||
from pydantic import BaseModel, HttpUrl, Field | ||
from program.symlink import Symlinker | ||
from utils.logger import logger, get_data_path | ||
from utils.settings import settings_manager | ||
from program.media import MediaItemContainer | ||
from program.libraries.plex import Library as Plex | ||
from program.debrid.realdebrid import Debrid as RealDebrid | ||
from program.content import Content | ||
from program.scrapers import Scraping | ||
|
||
|
||
# Pydantic models for configuration | ||
class PlexConfig(BaseModel): | ||
user: str | ||
token: str | ||
address: HttpUrl | ||
watchlist: Optional[HttpUrl] = None | ||
|
||
|
||
class MdblistConfig(BaseModel): | ||
lists: list[str] = Field(default_factory=list) | ||
api_key: str | ||
update_interval: int = 80 | ||
|
||
|
||
class OverseerrConfig(BaseModel): | ||
url: HttpUrl | ||
api_key: str | ||
|
||
|
||
class RealDebridConfig(BaseModel): | ||
api_key: str | ||
|
||
|
||
class TorrentioConfig(BaseModel): | ||
filter: str | ||
|
||
|
||
class Settings(BaseModel): | ||
version: str | ||
debug: bool | ||
service_mode: bool | ||
log: bool | ||
menu_on_startup: bool | ||
plex: PlexConfig | ||
mdblist: MdblistConfig | ||
overseerr: OverseerrConfig | ||
scraper_torrentio: TorrentioConfig | ||
realdebrid: RealDebridConfig | ||
|
||
|
||
class Program: | ||
"""Program class""" | ||
|
||
def __init__(self): | ||
self.settings = settings_manager.get_all() | ||
self.media_items = MediaItemContainer(items=[]) | ||
self.data_path = get_data_path() | ||
self.media_items.load(os.path.join(self.data_path, "media.pkl")) | ||
self.threads = [ | ||
Content(self.media_items), # Content must be first | ||
Plex(self.media_items), | ||
RealDebrid(self.media_items), | ||
Symlinker(self.media_items), | ||
Scraping(self.media_items), | ||
] | ||
logger.info("Iceberg initialized") | ||
|
||
def start(self): | ||
for thread in self.threads: | ||
thread.start() | ||
|
||
def stop(self): | ||
for thread in self.threads: | ||
thread.stop() | ||
self.media_items.save(os.path.join(self.data_path, "media.pkl")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import threading | ||
import time | ||
|
||
from utils.logger import logger | ||
from .mdblist import Mdblist | ||
from .overseerr import Overseerr | ||
from .plex_watchlist import PlexWatchlist | ||
|
||
|
||
class Content(threading.Thread): | ||
def __init__(self, media_items): | ||
super().__init__(name="Content") | ||
self.services = [ | ||
Mdblist(media_items), | ||
Overseerr(media_items), | ||
PlexWatchlist(media_items), | ||
] | ||
self.valid = False | ||
self.running = False | ||
while not self.validate(): | ||
logger.error( | ||
"You have no content services enabled, please enable at least one!" | ||
) | ||
time.sleep(5) | ||
|
||
for service in self.services: | ||
if service.initialized: | ||
service.run() | ||
|
||
def validate(self): | ||
return any(service.initialized for service in self.services) | ||
|
||
def run(self) -> None: | ||
while self.running: | ||
for service in self.services: | ||
if service.initialized: | ||
service.run() | ||
|
||
def start(self) -> None: | ||
self.running = True | ||
super().start() | ||
|
||
def stop(self) -> None: | ||
self.running = False | ||
super().join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.