diff --git a/plexpy/activity_handler.py b/plexpy/activity_handler.py index 96f3ed1e..35eb405d 100644 --- a/plexpy/activity_handler.py +++ b/plexpy/activity_handler.py @@ -279,6 +279,7 @@ class ActivityHandler(object): db_session['media_type'] == 'episode' and progress_percent >= plexpy.CONFIG.TV_WATCHED_PERCENT or db_session['media_type'] == 'track' and progress_percent >= plexpy.CONFIG.MUSIC_WATCHED_PERCENT) \ and not any(d['notify_action'] == 'on_watched' for d in notify_states): + logger.debug(u"Tautulli ActivityHandler :: Session %s watched." % str(self.get_session_key())) plexpy.NOTIFY_QUEUE.put({'stream_data': db_session.copy(), 'notify_action': 'on_watched'}) else: diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index cd06fa07..1315df96 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -82,11 +82,18 @@ def add_notifier_each(notifier_id=None, notify_action=None, stream_data=None, ti # Check if any notification agents have notifications enabled for the action notifiers_enabled = notifiers.get_notifiers(notify_action=notify_action) + # Check if the watched notifications has already been sent + if stream_data and notify_action == 'on_watched': + watched_notifiers = [d['notifier_id'] for d in get_notify_state(session=stream_data)] + notifiers_enabled = [n for n in notifiers_enabled if n['id'] not in watched_notifiers] + if notifiers_enabled and not manual_trigger: # Check if notification conditions are satisfied conditions = notify_conditions(notify_action=notify_action, stream_data=stream_data, timeline_data=timeline_data) + else: + conditions = True if notifiers_enabled and (manual_trigger or conditions): if stream_data or timeline_data: @@ -318,13 +325,6 @@ def notify_custom_conditions(notifier_id=None, parameters=None): def notify(notifier_id=None, notify_action=None, stream_data=None, timeline_data=None, parameters=None, **kwargs): - # Double check again if the notification has already been sent - if stream_data and \ - any(d['notifier_id'] == notifier_id and d['notify_action'] == notify_action - for d in get_notify_state(session=stream_data)): - # Return if the notification has already been sent - return - logger.info(u"Tautulli NotificationHandler :: Preparing notifications for notifier_id %s." % notifier_id) notifier_config = notifiers.get_notifier_config(notifier_id=notifier_id)