Use find_by_key in on_play
@@ -34,21 +34,16 @@ def find_by_key(self, key: str):
return m
def on_play(self, event: PlaySessionStateNotification):
- pm = self.plex.fetch_item(event.key)
- print(f"Found {pm}")
- if not pm:
- return
-
- tm = self.trakt.find_by_media(pm)
- if not tm:
+ m = self.find_by_key(event.key)
+ if not m:
return
- movie = pm.item
- percent = pm.watch_progress(event.view_offset)
+ movie = m.plex.item
+ percent = m.plex.watch_progress(event.view_offset)
print(f"{movie}: {percent:.6F}% Watched: {movie.isWatched}, LastViewed: {movie.lastViewedAt}")
- self.scrobble(tm, percent, event.state)
+ self.scrobble(m.trakt, percent, event.state)
def scrobble(self, tm, percent, state):
if state == "playing":
