diff --git a/data/interfaces/default/css/plexwatch.css b/data/interfaces/default/css/plexwatch.css index 836e36a6..5999ec2a 100644 --- a/data/interfaces/default/css/plexwatch.css +++ b/data/interfaces/default/css/plexwatch.css @@ -1288,10 +1288,10 @@ input[type="color"], margin-top: 5px; color: #fff; border: 0px solid #444; - background: #333; + background: #555; height: 24px; padding: 2px 5px 2px 12px; - background-color: #3a3a3a; + background-color: #555; border-radius: 14.5px; transition: background-color .3s; } diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 64d92572..05d28c58 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -265,7 +265,7 @@
Enable IP Logging - +

Enable this to attempt to log the IP address of the user.

@@ -304,6 +304,10 @@ You can set custom formatted text for each type of notification. Click here for a list of available parameters which can be used.

+

+ You can also add tags to exclude certain text depending on the media type. Click + here to view usage information. +


+ @@ -651,7 +698,6 @@ <%def name="javascriptIncludes()"> - diff --git a/plexpy/notification_handler.py b/plexpy/notification_handler.py index 34dc6bc1..0c6cb32f 100644 --- a/plexpy/notification_handler.py +++ b/plexpy/notification_handler.py @@ -153,6 +153,7 @@ def set_notify_state(session, state, agent_info): def build_notify_text(session, state): from plexpy import pmsconnect, helpers + import re # Get the server name pms_connect = pmsconnect.PmsConnect() @@ -167,12 +168,59 @@ def build_notify_text(session, state): logger.error(u"PlexPy Notifier :: Unable to retrieve metadata for rating_key %s" % str(session['rating_key'])) return [] + # TODO: There must be a better way to do this. Laziness. + # Check for exclusion tags + if session['media_type'] == 'episode': + on_start_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT)) + on_start_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT)) + on_stop_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT)) + on_stop_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT)) + on_watched_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT)) + on_watched_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT)) + elif session['media_type'] == 'movie': + on_start_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT)) + on_start_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT)) + on_stop_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT)) + on_stop_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT)) + on_watched_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT)) + on_watched_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT)) + elif session['media_type'] == 'track': + on_start_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT)) + on_start_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT)) + on_stop_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT)) + on_stop_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT)) + on_watched_subject = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT)) + on_watched_body = strip_tag(re.sub('[^>]+.|[^>]+.', '', + plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT)) + else: + on_start_subject = plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT + on_start_body = plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT + on_stop_subject = plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT + on_stop_body = plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT + on_watched_subject = plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT + on_watched_body = plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT + # Create a title if session['media_type'] == 'episode': - full_title = '%s - %s (%sx%s)' % (session['grandparent_title'], - session['title'], - item_metadata['parent_index'], - item_metadata['index']) + full_title = '%s - %s' % (session['grandparent_title'], + session['title']) elif session['media_type'] == 'track': full_title = '%s - %s' % (session['grandparent_title'], session['title']) @@ -202,6 +250,8 @@ def build_notify_text(session, state): 'user': session['friendly_name'], 'player': session['player'], 'title': full_title, + 'show_name': item_metadata['grandparent_title'], + 'episode_name': item_metadata['title'], 'platform': session['platform'], 'media_type': session['media_type'], 'transcode_decision': transcode_decision, @@ -226,14 +276,14 @@ def build_notify_text(session, state): session['player'], full_title) - if plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT and plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT: + if on_start_subject and on_start_body: try: - subject_text = plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT.format(**available_params) + subject_text = on_start_subject.format(**available_params) except: logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using default.") try: - body_text = plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT.format(**available_params) + body_text = on_start_body.format(**available_params) except: logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using default.") @@ -246,14 +296,14 @@ def build_notify_text(session, state): session['player'], full_title) - if plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT and plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT: + if on_stop_subject and on_stop_body: try: - subject_text = plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT.format(**available_params) + subject_text = on_stop_subject.format(**available_params) except: logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using default.") try: - body_text = plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT.format(**available_params) + body_text = on_stop_body.format(**available_params) except: logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using default.") @@ -266,14 +316,14 @@ def build_notify_text(session, state): session['player'], full_title) - if plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT and plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT: + if on_watched_subject and on_watched_body: try: - subject_text = plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT.format(**available_params) + subject_text = on_watched_subject.format(**available_params) except: logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using default.") try: - body_text = plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT.format(**available_params) + body_text = on_watched_body.format(**available_params) except: logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using default.") @@ -282,3 +332,9 @@ def build_notify_text(session, state): return [subject_text, body_text] else: return None + +def strip_tag(data): + import re + + p = re.compile(r'<.*?>') + return p.sub('', data) \ No newline at end of file