diff --git a/plextraktsync/config/Config.py b/plextraktsync/config/Config.py index c5cfdf3ea6..f0874fc59c 100644 --- a/plextraktsync/config/Config.py +++ b/plextraktsync/config/Config.py @@ -88,12 +88,6 @@ def http_cache(self): return HttpCacheConfig(**cache) - @property - def sync(self): - from plextraktsync.config.SyncConfig import SyncConfig - - return SyncConfig(self) - def initialize(self): """ Config load order: diff --git a/plextraktsync/config/PlexServerConfig.py b/plextraktsync/config/PlexServerConfig.py index 2dd9bc7c18..394ab8355c 100644 --- a/plextraktsync/config/PlexServerConfig.py +++ b/plextraktsync/config/PlexServerConfig.py @@ -14,9 +14,17 @@ class PlexServerConfig: urls: list[str] # The machineIdentifier value of this server id: str = None + config: dict = None def asdict(self): data = asdict(self) del data["name"] return data + + @property + def sync_config(self): + if self.config is None or "sync" not in self.config or self.config["sync"] is None: + return {} + + return self.config["sync"] diff --git a/plextraktsync/config/SyncConfig.py b/plextraktsync/config/SyncConfig.py index ef97d44d98..556d6fb615 100644 --- a/plextraktsync/config/SyncConfig.py +++ b/plextraktsync/config/SyncConfig.py @@ -5,11 +5,13 @@ if TYPE_CHECKING: from plextraktsync.config.Config import Config + from plextraktsync.config.PlexServerConfig import PlexServerConfig class SyncConfig: - def __init__(self, config: Config): + def __init__(self, config: Config, server_config: PlexServerConfig): self.config = dict(config["sync"]) + self.server_config = server_config.sync_config def __getitem__(self, key): return self.config[key] @@ -18,6 +20,9 @@ def __contains__(self, key): return key in self.config def get(self, section, key): + if section in self.server_config and key in self.server_config[section]: + return self.server_config[section][key] + return self[key] if key in self else self[section][key] @cached_property diff --git a/plextraktsync/sync.py b/plextraktsync/sync.py index 33c0ecfa15..f02c545ee9 100644 --- a/plextraktsync/sync.py +++ b/plextraktsync/sync.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from typing import Iterable - from plextraktsync.config.Config import Config + from plextraktsync.config.SyncConfig import SyncConfig from plextraktsync.media import Media from plextraktsync.plex.PlexApi import PlexApi from plextraktsync.trakt.TraktApi import TraktApi @@ -19,8 +19,8 @@ class Sync: - def __init__(self, config: Config, plex: PlexApi, trakt: TraktApi): - self.config = config.sync + def __init__(self, config: SyncConfig, plex: PlexApi, trakt: TraktApi): + self.config = config self.plex = plex self.trakt = trakt diff --git a/plextraktsync/util/Factory.py b/plextraktsync/util/Factory.py index 828de328fe..7489a8ebb0 100644 --- a/plextraktsync/util/Factory.py +++ b/plextraktsync/util/Factory.py @@ -130,11 +130,10 @@ def session(self): def sync(self): from plextraktsync.sync import Sync - config = self.config plex = self.plex_api trakt = self.trakt_api - return Sync(config, plex, trakt) + return Sync(self.sync_config, plex, trakt) @cached_property def progressbar(self): @@ -284,6 +283,12 @@ def invalidate_plex_cache(key, value): return config + @property + def sync_config(self): + from plextraktsync.config.SyncConfig import SyncConfig + + return SyncConfig(self.config, self.server_config) + @cached_property def queue(self): from plextraktsync.queue.BackgroundTask import BackgroundTask