Return the name of the server with the notification.

Remove some unnecessary includes.
Fix validation on logging_ignore_interval which wouldn't allow anything less than 30
This commit is contained in:
Tim 2015-07-12 15:32:20 +02:00
parent 06558a7437
commit 0916370a9d
4 changed files with 57 additions and 15 deletions

View file

@ -262,7 +262,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="monitoring_interval">Ignore Interval</label> <label for="monitoring_interval">Ignore Interval</label>
<input type="text" data-parsley-type="integer" id="logging_ignore_interval" name="logging_ignore_interval" value="${config['logging_ignore_interval']}" size="5" data-parsley-min="30" data-parsley-trigger="change" required> <input type="text" data-parsley-type="integer" id="logging_ignore_interval" name="logging_ignore_interval" value="${config['logging_ignore_interval']}" size="5" data-parsley-min="0" data-parsley-trigger="change" required>
<p class="help-block">The interval (in seconds) PlexPy will wait for a video item to be active before logging it. 0 to disable.</p> <p class="help-block">The interval (in seconds) PlexPy will wait for a video item to be active before logging it. 0 to disable.</p>
</div> </div>
<div class="checkbox"> <div class="checkbox">

View file

@ -13,11 +13,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>. # along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
from plexpy import logger, helpers, plexwatch, pmsconnect, notification_handler, config, log_reader, common from plexpy import logger, helpers, pmsconnect, notification_handler, config, log_reader, common
from xml.dom import minidom
from httplib import HTTPSConnection
from httplib import HTTPConnection
import os import os
import sqlite3 import sqlite3
@ -439,6 +435,13 @@ class MonitorProcessing(object):
def notify(stream_data=None, notify_action=None): def notify(stream_data=None, notify_action=None):
if stream_data and notify_action: 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 # Build media item title
if stream_data['media_type'] == 'episode' or stream_data['media_type'] == 'track': if stream_data['media_type'] == 'episode' or stream_data['media_type'] == 'track':
item_title = '%s - %s' % (stream_data['grandparent_title'], stream_data['title']) 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': if plexpy.CONFIG.MOVIE_NOTIFY_ON_START and notify_action == 'play':
message = '%s (%s) started playing %s.' % \ message = '%s (%s) started playing %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif plexpy.CONFIG.MOVIE_NOTIFY_ON_PAUSE and notify_action == 'pause':
message = '%s (%s) has paused %s.' % \ message = '%s (%s) has paused %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif plexpy.CONFIG.MOVIE_NOTIFY_ON_STOP and notify_action == 'stop':
message = '%s (%s) stopped playing %s.' % \ message = '%s (%s) stopped playing %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif stream_data['media_type'] == 'episode':
if plexpy.CONFIG.TV_NOTIFY_ENABLE: 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': if plexpy.CONFIG.TV_NOTIFY_ON_START and notify_action == 'play':
message = '%s (%s) started playing %s.' % \ message = '%s (%s) started playing %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif plexpy.CONFIG.TV_NOTIFY_ON_PAUSE and notify_action == 'pause':
message = '%s (%s) has paused %s.' % \ message = '%s (%s) has paused %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif plexpy.CONFIG.TV_NOTIFY_ON_STOP and notify_action == 'stop':
message = '%s (%s) stopped playing %s.' % \ message = '%s (%s) stopped playing %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif stream_data['media_type'] == 'track':
if plexpy.CONFIG.MUSIC_NOTIFY_ENABLE: 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': if plexpy.CONFIG.MUSIC_NOTIFY_ON_START and notify_action == 'play':
message = '%s (%s) started playing %s.' % \ message = '%s (%s) started playing %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif plexpy.CONFIG.MUSIC_NOTIFY_ON_PAUSE and notify_action == 'pause':
message = '%s (%s) has paused %s.' % \ message = '%s (%s) has paused %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif plexpy.CONFIG.MUSIC_NOTIFY_ON_STOP and notify_action == 'stop':
message = '%s (%s) stopped playing %s.' % \ message = '%s (%s) stopped playing %s.' % \
(stream_data['friendly_name'], stream_data['player'], item_title) (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': elif stream_data['media_type'] == 'clip':
pass pass

View file

@ -866,6 +866,34 @@ class PmsConnect(object):
return server_identity 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. Return image data as array.
Array contains the image content type and image binary Array contains the image content type and image binary

View file

@ -982,3 +982,14 @@ class WebInterface(object):
return result return result
else: else:
logger.warn('Unable to retrieve data.') 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.')