Skip sessions tracking if not available
@@ -67,7 +67,7 @@ def __init__(
self.username_filter = config["PLEX_USERNAME"]
else:
self.username_filter = None
- self.sessions = SessionCollection(plex)
+ self.sessions = SessionCollection(plex) if self.username_filter else None
@cached_property
def scrobblers(self):
@@ -95,6 +95,7 @@ def find_by_key(self, key: str, reload=False):
def on_error(self, error: Error):
self.logger.error(error.msg)
self.scrobblers.clear()
+ if self.sessions:
self.sessions.clear()
def on_activity(self, activity: ActivityNotification):
@@ -158,6 +159,7 @@ def scrobble(self, m: Media, percent: float, event: PlaySessionStateNotification
if state == "stopped":
value = self.scrobblers[tm].stop(percent)
del self.scrobblers[tm]
+ if self.sessions:
del self.sessions[event.session_key]
return value
