Move ScrobblerCollection to trakt module
MODIFY
plextraktsync/commands/watch.py
plextraktsync/commands/watch.py
from __future__ import annotations
-from collections import UserDict
from typing import TYPE_CHECKING
from plextraktsync.decorators.cached_property import cached_property
from plextraktsync.events import (ActivityNotification, Error,
PlaySessionStateNotification, TimelineEntry)
from plextraktsync.factory import factory, logging
-from plextraktsync.trakt.ScrobblerProxy import ScrobblerProxy
if TYPE_CHECKING:
- from typing import Union
-
- from trakt.movies import Movie
- from trakt.tv import TVEpisode
from plextraktsync.config import Config
from plextraktsync.media import Media, MediaFactory
from plextraktsync.trakt.TraktApi import TraktApi
-class ScrobblerCollection(UserDict):
- def __init__(self, trakt: TraktApi, threshold=80):
- super().__init__()
- self.trakt = trakt
- self.threshold = threshold
-
- def __missing__(self, media: Union[Movie, TVEpisode]):
- scrobbler = media.scrobble(0, None, None)
- proxy = ScrobblerProxy(scrobbler, self.threshold)
- self[media] = proxy
-
- return proxy
-
-
class SessionCollection(dict):
def __init__(self, plex: PlexApi):
super().__init__()
@@ -129,6 +109,8 @@ def __init__(
@cached_property
def scrobblers(self):
+ from plextraktsync.trakt.ScrobblerCollection import ScrobblerCollection
+
return ScrobblerCollection(self.trakt, self.threshold)
def find_by_key(self, key: str, reload=False):

ADD
plextraktsync/trakt/ScrobblerCollection.py
+from __future__ import annotations
+
+from collections import UserDict
+from typing import TYPE_CHECKING
+
+from plextraktsync.trakt.ScrobblerProxy import ScrobblerProxy
+
+if TYPE_CHECKING:
+ from typing import Union
+
+ from plexapi.video import Movie
+ from trakt.tv import TVEpisode
+
+ from plextraktsync.trakt.TraktApi import TraktApi
+
+
+class ScrobblerCollection(UserDict):
+ def __init__(self, trakt: TraktApi, threshold=80):
+ super().__init__()
+ self.trakt = trakt
+ self.threshold = threshold
+
+ def __missing__(self, media: Union[Movie, TVEpisode]):
+ scrobbler = media.scrobble(0, None, None)
+ proxy = ScrobblerProxy(scrobbler, self.threshold)
+ self[media] = proxy
+
+ return proxy

Move ScrobblerCollection to trakt module