Add on_delete listener to watcher
from plextraktsync.config import Config
from plextraktsync.events import (ActivityNotification, Error,
- PlaySessionStateNotification)
+ PlaySessionStateNotification, TimelineEntry)
from plextraktsync.factory import factory
from plextraktsync.listener import WebSocketListener
from plextraktsync.logging import logging
@@ -85,6 +85,14 @@ def on_activity(self, activity: ActivityNotification):
return
self.logger.info(f"Activity: {m}: Watched: Plex: {m.watched_on_plex}, Trakt: {m.watched_on_trakt}")
+ def on_delete(self, event: TimelineEntry):
+ m = self.find_by_key(event.item_id)
+ if not m:
+ return
+
+ movie = m.plex.item
+ self.logger.info(f"Deleted {event.title}: {movie}")
+
def on_play(self, event: PlaySessionStateNotification):
if not self.can_scrobble(event):
return
@@ -137,6 +145,7 @@ def watch():
ws.on(PlaySessionStateNotification, updater.on_play, state=["playing", "stopped", "paused"])
ws.on(ActivityNotification, updater.on_activity, type="library.refresh.items", event=["ended"], progress=100)
+ ws.on(TimelineEntry, updater.on_delete, state=9, metadata_state="deleted")
ws.on(Error, updater.on_error)
print("Listening for events!")
