diff --git a/data/interfaces/default/notifier_text_preview.html b/data/interfaces/default/notifier_text_preview.html index 31f944fb..26cba29f 100644 --- a/data/interfaces/default/notifier_text_preview.html +++ b/data/interfaces/default/notifier_text_preview.html @@ -1,4 +1,3 @@ -% if text: -% endif \ No newline at end of file + \ No newline at end of file diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 91c425e2..91bec821 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -580,7 +580,7 @@ def build_notify_text(subject='', body='', notify_action=None, parameters=None, elif media_type == 'track': pattern = re.compile(all_tags.replace('.*?', '|'), re.IGNORECASE | re.DOTALL) else: - pattern = None + pattern = re.compile(all_tags, re.IGNORECASE | re.DOTALL) if pattern: # Remove the unwanted tags and strip any unmatch tags too. diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index d74bfb56..16cd67cf 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -170,105 +170,120 @@ def available_notification_actions(): 'description': 'Trigger a notification when a stream is started.', 'subject': 'PlexPy ({server_name})', 'body': '{user} ({player}) started playing {title}.', - 'icon': 'fa-play' + 'icon': 'fa-play', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'Playback Stop', 'name': 'on_stop', 'description': 'Trigger a notification when a stream is stopped.', 'subject': 'PlexPy ({server_name})', 'body': '{user} ({player}) has stopped {title}.', - 'icon': 'fa-stop' + 'icon': 'fa-stop', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'Playback Pause', 'name': 'on_pause', 'description': 'Trigger a notification when a stream is puased.', 'subject': 'PlexPy ({server_name})', 'body': '{user} ({player}) has paused {title}.', - 'icon': 'fa-pause' + 'icon': 'fa-pause', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'Playback Resume', 'name': 'on_resume', 'description': 'Trigger a notification when a stream is resumed.', 'subject': 'PlexPy ({server_name})', 'body': '{user} ({player}) has resumed {title}.', - 'icon': 'fa-play' + 'icon': 'fa-play', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'Watched', 'name': 'on_watched', 'description': 'Trigger a notification when a video stream reaches the specified watch percentage.', 'subject': 'PlexPy ({server_name})', 'body': '{user} ({player}) has watched {title}.', - 'icon': 'fa-eye' + 'icon': 'fa-eye', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'Buffer Warning', 'name': 'on_buffer', 'description': 'Trigger a notification when a stream exceeds the specified buffer threshold.', 'subject': 'PlexPy ({server_name})', 'body': '{user} ({player}) is buffering {title}.', - 'icon': 'fa-spinner' + 'icon': 'fa-spinner', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'User Concurrent Streams', 'name': 'on_concurrent', 'description': 'Trigger a notification when a user exceeds the concurrent stream threshold.', 'subject': 'PlexPy ({server_name})', 'body': '{user} has {user_streams} concurrent streams.', - 'icon': 'fa-arrow-circle-o-right' + 'icon': 'fa-arrow-circle-o-right', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'User New Device', 'name': 'on_newdevice', 'description': 'Trigger a notification when a user streams from a new device.', 'subject': 'PlexPy ({server_name})', 'body': '{user} is streaming from a new device: {player}.', - 'icon': 'fa-desktop' + 'icon': 'fa-desktop', + 'media_types': ('movie', 'episode', 'track') }, {'label': 'Recently Added', 'name': 'on_created', 'description': 'Trigger a notification when a media item is added to the Plex Media Server.', 'subject': 'PlexPy ({server_name})', 'body': '{title} was recently added to Plex.', - 'icon': 'fa-download' + 'icon': 'fa-download', + 'media_types': ('movie', 'show', 'season', 'episode', 'artist', 'album', 'track') }, {'label': 'Plex Server Down', 'name': 'on_intdown', 'description': 'Trigger a notification when the Plex Media Server cannot be reached internally.', 'subject': 'PlexPy ({server_name})', 'body': 'The Plex Media Server is down.', - 'icon': 'fa-server' + 'icon': 'fa-server', + 'media_types': ('server',) }, {'label': 'Plex Server Back Up', 'name': 'on_intup', 'description': 'Trigger a notification when the Plex Media Server can be reached internally after being down.', 'subject': 'PlexPy ({server_name})', 'body': 'The Plex Media Server is back up.', - 'icon': 'fa-server' + 'icon': 'fa-server', + 'media_types': ('server',) }, {'label': 'Plex Remote Access Down', 'name': 'on_extdown', 'description': 'Trigger a notification when the Plex Media Server cannot be reached externally.', 'subject': 'PlexPy ({server_name})', 'body': 'The Plex Media Server remote access is down.', - 'icon': 'fa-server' + 'icon': 'fa-server', + 'media_types': ('server',) }, {'label': 'Plex Remote Access Back Up', 'name': 'on_extup', 'description': 'Trigger a notification when the Plex Media Server can be reached externally after being down.', 'subject': 'PlexPy ({server_name})', 'body': 'The Plex Media Server remote access is back up.', - 'icon': 'fa-server' + 'icon': 'fa-server', + 'media_types': ('server',) }, {'label': 'Plex Update Available', 'name': 'on_pmsupdate', 'description': 'Trigger a notification when an update for the Plex Media Server is available.', 'subject': 'PlexPy ({server_name})', 'body': 'An update is available for the Plex Media Server (version {update_version}).', - 'icon': 'fa-refresh' + 'icon': 'fa-refresh', + 'media_types': ('server',) }, {'label': 'PlexPy Update Available', 'name': 'on_plexpyupdate', 'description': 'Trigger a notification when an update for the PlexPy is available.', 'subject': 'PlexPy ({server_name})', 'body': 'An update is available for PlexPy (version {plexpy_update_version}).', - 'icon': 'fa-refresh' + 'icon': 'fa-refresh', + 'media_types': ('server',) } ] diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 608b9f79..7cf29930 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2993,8 +2993,10 @@ class WebInterface(object): agent_id = int(agent_id) text = [] + media_types = next((a['media_types'] for a in notifiers.available_notification_actions() + if a['name'] == notify_action), ()) - for media_type in ('movie', 'show', 'season', 'episode', 'artist', 'album', 'track'): + for media_type in media_types: test_subject, test_body = notification_handler.build_notify_text(subject=subject, body=body, notify_action=notify_action,