diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 2fe8cf49..dcf3d6bc 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -262,7 +262,7 @@
- +

The interval (in seconds) PlexPy will wait for a video item to be active before logging it. 0 to disable.

diff --git a/plexpy/monitor.py b/plexpy/monitor.py index 57f92d7d..eddf2d48 100644 --- a/plexpy/monitor.py +++ b/plexpy/monitor.py @@ -13,11 +13,7 @@ # You should have received a copy of the GNU General Public License # along with PlexPy. If not, see . -from plexpy import logger, helpers, plexwatch, pmsconnect, notification_handler, config, log_reader, common - -from xml.dom import minidom -from httplib import HTTPSConnection -from httplib import HTTPConnection +from plexpy import logger, helpers, pmsconnect, notification_handler, config, log_reader, common import os import sqlite3 @@ -439,6 +435,13 @@ class MonitorProcessing(object): def notify(stream_data=None, notify_action=None): if stream_data and notify_action: + # Get the server name + pms_connect = pmsconnect.PmsConnect() + server_name = pms_connect.get_server_pref(pref='FriendlyName') + + # Build the notification heading + notify_header = 'PleyPy (%s)' % server_name + # Build media item title if stream_data['media_type'] == 'episode' or stream_data['media_type'] == 'track': item_title = '%s - %s' % (stream_data['grandparent_title'], stream_data['title']) @@ -457,17 +460,17 @@ def notify(stream_data=None, notify_action=None): if plexpy.CONFIG.MOVIE_NOTIFY_ON_START and notify_action == 'play': message = '%s (%s) started playing %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif plexpy.CONFIG.MOVIE_NOTIFY_ON_PAUSE and notify_action == 'pause': message = '%s (%s) has paused %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif plexpy.CONFIG.MOVIE_NOTIFY_ON_STOP and notify_action == 'stop': message = '%s (%s) stopped playing %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif stream_data['media_type'] == 'episode': if plexpy.CONFIG.TV_NOTIFY_ENABLE: @@ -475,17 +478,17 @@ def notify(stream_data=None, notify_action=None): if plexpy.CONFIG.TV_NOTIFY_ON_START and notify_action == 'play': message = '%s (%s) started playing %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif plexpy.CONFIG.TV_NOTIFY_ON_PAUSE and notify_action == 'pause': message = '%s (%s) has paused %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif plexpy.CONFIG.TV_NOTIFY_ON_STOP and notify_action == 'stop': message = '%s (%s) stopped playing %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif stream_data['media_type'] == 'track': if plexpy.CONFIG.MUSIC_NOTIFY_ENABLE: @@ -493,17 +496,17 @@ def notify(stream_data=None, notify_action=None): if plexpy.CONFIG.MUSIC_NOTIFY_ON_START and notify_action == 'play': message = '%s (%s) started playing %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif plexpy.CONFIG.MUSIC_NOTIFY_ON_PAUSE and notify_action == 'pause': message = '%s (%s) has paused %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif plexpy.CONFIG.MUSIC_NOTIFY_ON_STOP and notify_action == 'stop': message = '%s (%s) stopped playing %s.' % \ (stream_data['friendly_name'], stream_data['player'], item_title) - notification_handler.push_nofitications(message, 'PlexPy', common.notify_strings[1]) + notification_handler.push_nofitications(message, notify_header, common.notify_strings[1]) elif stream_data['media_type'] == 'clip': pass diff --git a/plexpy/pmsconnect.py b/plexpy/pmsconnect.py index c1ff5915..d63591e6 100644 --- a/plexpy/pmsconnect.py +++ b/plexpy/pmsconnect.py @@ -866,6 +866,34 @@ class PmsConnect(object): return server_identity + """ + Return a specified server preference. + + Parameters required: pref { name of preference } + + Output: string + """ + def get_server_pref(self, pref=None): + if pref: + prefs = self.get_server_prefs(output_format='xml') + + try: + xml_head = prefs.getElementsByTagName('Setting') + except: + logger.warn("Unable to parse XML for get_local_server_name.") + return '' + + pref_value = 'None' + for a in xml_head: + if helpers.get_xml_attr(a, 'id') == pref: + pref_value = helpers.get_xml_attr(a, 'value') + break + + return pref_value + else: + logger.debug(u"Server preferences queried but no parameter received.") + return None + """ Return image data as array. Array contains the image content type and image binary diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 9c6043a5..ebb239a2 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -982,3 +982,14 @@ class WebInterface(object): return result else: logger.warn('Unable to retrieve data.') + + @cherrypy.expose + def get_server_pref(self, pref=None, **kwargs): + + pms_connect = pmsconnect.PmsConnect() + result = pms_connect.get_server_pref(pref=pref) + + if result: + return result + else: + logger.warn('Unable to retrieve data.')