Lazy load watch command
MODIFY
plextraktsync/cli.py
plextraktsync/cli.py
import click
from plextraktsync.commands.self_update import enable_self_update, self_update
-from plextraktsync.commands.watch import watch
from plextraktsync.factory import factory
CONFIG = factory.config()
@@ -209,6 +208,14 @@ def unmatched():
pass
+@command()
+def watch():
+ """
+ Listen to events from Plex
+ """
+ pass
+
+
cli.add_command(cache)
cli.add_command(clear_collections)
cli.add_command(info)

MODIFY
plextraktsync/commands/watch.py
plextraktsync/commands/watch.py
-import click
-
from plextraktsync.config import Config
from plextraktsync.events import (ActivityNotification, Error,
PlaySessionStateNotification, TimelineEntry)
@@ -85,7 +83,8 @@ def on_activity(self, activity: ActivityNotification):
m = self.find_by_key(activity.key, reload=True)
if not m:
return
- self.logger.info(f"Activity: {m}: Collected: {m.is_collected}, Watched: [Plex: {m.watched_on_plex}, Trakt: {m.watched_on_trakt}]")
+ self.logger.info(
+ f"Activity: {m}: Collected: {m.is_collected}, Watched: [Plex: {m.watched_on_plex}, Trakt: {m.watched_on_trakt}]")
if self.add_collection and not m.is_collected:
self.logger.info(f"Add to collection: {m}")
@@ -139,12 +138,7 @@ def scrobble(self, m: Media, percent: float, event: PlaySessionStateNotification
del self.sessions[event.session_key]
-@click.command()
def watch():
- """
- Listen to events from Plex
- """
-
server = factory.plex_server()
trakt = factory.trakt_api()
plex = factory.plex_api()

Lazy load watch command