Lazy init ScrobblerCollection
MODIFY
plextraktsync/commands/watch.py
plextraktsync/commands/watch.py
from plextraktsync.config import Config
+from plextraktsync.decorators.cached_property import cached_property
from plextraktsync.events import (ActivityNotification, Error,
PlaySessionStateNotification, TimelineEntry)
from plextraktsync.factory import factory
@@ -46,7 +47,7 @@ def __init__(self, plex: PlexApi, trakt: TraktApi, mf: MediaFactory, config: Con
self.trakt = trakt
self.mf = mf
self.logger = logging.getLogger("PlexTraktSync.WatchStateUpdater")
- self.scrobblers = ScrobblerCollection(trakt, config["watch"]["scrobble_threshold"])
+ self.threshold = config["watch"]["scrobble_threshold"]
self.remove_collection = config["watch"]["remove_collection"]
self.add_collection = config["watch"]["add_collection"]
if config["watch"]["username_filter"]:
@@ -59,6 +60,10 @@ def __init__(self, plex: PlexApi, trakt: TraktApi, mf: MediaFactory, config: Con
self.username_filter = None
self.sessions = SessionCollection(plex)
+ @cached_property
+ def scrobblers(self):
+ return ScrobblerCollection(self.trakt, self.threshold)
+
def find_by_key(self, key: str, reload=False):
pm = self.plex.fetch_item(key)
if reload:

Lazy init ScrobblerCollection