Add logger to WatchStateUpdater
import click
+from plex_trakt_sync.logging import logging
from plex_trakt_sync.config import Config
from plex_trakt_sync.events import PlaySessionStateNotification, ActivityNotification
from plex_trakt_sync.factory import factory
@@ -44,6 +45,7 @@ def __init__(self, plex: PlexApi, trakt: TraktApi, mf: MediaFactory, config: Con
self.plex = plex
self.trakt = trakt
self.mf = mf
+ self.logger = logging.getLogger("PlexTraktSync.WatchStateUpdater")
self.scrobblers = ScrobblerCollection(trakt)
if config["watch"]["username_filter"]:
self.username_filter = config["PLEX_USERNAME"]
@@ -65,7 +67,7 @@ def on_activity(self, activity: ActivityNotification):
m = self.find_by_key(activity.key, reload=True)
if not m:
return
- print(f"Activity: {m}: Watched: Plex: {m.watched_on_plex}, Trakt: {m.watched_on_trakt}")
+ self.logger.info(f"Activity: {m}: Watched: Plex: {m.watched_on_plex}, Trakt: {m.watched_on_trakt}")
def on_play(self, event: PlaySessionStateNotification):
if not self.can_scrobble(event):
@@ -78,7 +80,7 @@ def on_play(self, event: PlaySessionStateNotification):
movie = m.plex.item
percent = m.plex.watch_progress(event.view_offset)
- print(f"{movie}: {percent:.6F}% Watched: {movie.isWatched}, LastViewed: {movie.lastViewedAt}")
+ self.logger.info(f"{movie}: {percent:.6F}% Watched: {movie.isWatched}, LastViewed: {movie.lastViewedAt}")
self.scrobble(m, percent, event)
def can_scrobble(self, event: PlaySessionStateNotification):
