diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index c15be036..23d74bc0 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -502,6 +502,12 @@ available_notification_agents = notifiers.available_notification_agents()

Disable to prevent consecutive notifications (i.e. both watched & stopped notifications).

+
+ +

Endable to only get one notification for recently added Episodes or Tracks. Movies are unaffected.

+

Custom Notification Messages

diff --git a/plexpy/config.py b/plexpy/config.py index ad6f9445..99f68c2c 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -138,6 +138,7 @@ _CONFIG_DEFINITIONS = { 'NMA_ON_WATCHED': (int, 'NMA', 0), 'NMA_ON_CREATED': (int, 'NMA', 0), 'NOTIFY_CONSECUTIVE': (int, 'Monitoring', 1), + 'NOTIFY_RECENTLY_ADDED_GRANDPARENT': (int, 'Monitoring', 0), 'NOTIFY_WATCHED_PERCENT': (int, 'Monitoring', 85), 'NOTIFY_ON_START_SUBJECT_TEXT': (str, 'Monitoring', 'PlexPy ({server_name})'), 'NOTIFY_ON_START_BODY_TEXT': (str, 'Monitoring', '{user} ({player}) started playing {title}.'), diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 57085b09..ce8692c0 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -172,13 +172,26 @@ def notify_timeline(timeline_data=None, notify_action=None): if timeline_data and notify_action: for agent in notifiers.available_notification_agents(): if agent['on_created'] and notify_action == 'created': - # Build and send notification - notify_strings = build_notify_text(session=timeline_data, state=notify_action) - notifiers.send_notification(config_id=agent['id'], - subject=notify_strings[0], - body=notify_strings[1]) - # Set the notification state in the db - set_notify_state(session=timeline_data, state=notify_action, agent_info=agent) + if plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT \ + and (timeline_data['media_type'] == 'movie' or timeline_data['media_type'] == 'show' \ + or timeline_data['media_type'] == 'artist'): + # Build and send notification + notify_strings = build_notify_text(session=timeline_data, state=notify_action) + notifiers.send_notification(config_id=agent['id'], + subject=notify_strings[0], + body=notify_strings[1]) + # Set the notification state in the db + set_notify_state(session=timeline_data, state=notify_action, agent_info=agent) + elif not plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT \ + and (timeline_data['media_type'] == 'movie' or timeline_data['media_type'] == 'episode' \ + or timeline_data['media_type'] == 'track'): + # Build and send notification + notify_strings = build_notify_text(session=timeline_data, state=notify_action) + notifiers.send_notification(config_id=agent['id'], + subject=notify_strings[0], + body=notify_strings[1]) + # Set the notification state in the db + set_notify_state(session=timeline_data, state=notify_action, agent_info=agent) else: logger.debug(u"PlexPy Notifier :: Notify timeline called but incomplete data received.") diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 96cfe329..267e9477 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -442,6 +442,7 @@ class WebInterface(object): "logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL, "pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE), "notify_consecutive": checked(plexpy.CONFIG.NOTIFY_CONSECUTIVE), + "notify_recently_added_grandparent": checked(plexpy.CONFIG.NOTIFY_RECENTLY_ADDED_GRANDPARENT), "notify_watched_percent": plexpy.CONFIG.NOTIFY_WATCHED_PERCENT, "notify_on_start_subject_text": plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT, "notify_on_start_body_text": plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT, @@ -481,7 +482,7 @@ class WebInterface(object): "tv_notify_on_stop", "movie_notify_on_stop", "music_notify_on_stop", "tv_notify_on_pause", "movie_notify_on_pause", "music_notify_on_pause", "refresh_users_on_startup", "ip_logging_enable", "video_logging_enable", "music_logging_enable", "pms_is_remote", "home_stats_type", - "group_history_tables", "notify_consecutive" + "group_history_tables", "notify_consecutive", "notify_recently_added_grandparent" ] for checked_config in checked_configs: if checked_config not in kwargs: