mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
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:
parent
06558a7437
commit
0916370a9d
4 changed files with 57 additions and 15 deletions
|
@ -262,7 +262,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<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>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
|
|
|
@ -13,11 +13,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# 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 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue