Update match logic to match all conditions
MODIFY
plex_trakt_sync/listener.py
plex_trakt_sync/listener.py
@@ -30,18 +30,13 @@ def event_handler(self, data):
def dispatch(self, event):
for listener in self.event_listeners:
- if not self.is_candidate(event, listener):
+ if not self.match_event(listener, event):
continue
listener["listener"](event)
@staticmethod
- def is_candidate(event, listener):
- if not isinstance(event, listener["event_type"]):
- return False
-
- if listener["filters"]:
- for name, value in listener["filters"].items():
+ def match_filter(event, name, value):
# test event property
if hasattr(event, name) and getattr(event, name) == value:
return True
@@ -50,6 +45,16 @@ def is_candidate(event, listener):
return False
if event[name] not in value:
return False
+ return True
+
+ def match_event(self, listener, event):
+ if not isinstance(event, listener["event_type"]):
+ return False
+
+ if listener["filters"]:
+ for name, value in listener["filters"].items():
+ if not self.match_filter(event, name, value):
+ return False
return True

Update match logic to match all conditions