mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Clean up scripts
This commit is contained in:
parent
e321479712
commit
3d6f89d309
5 changed files with 33 additions and 54 deletions
|
@ -80,38 +80,29 @@ from plexpy import helpers
|
|||
<p class="help-block">Set a custom body.</p>
|
||||
</div>
|
||||
%if agent['name'] == 'Scripts':
|
||||
<div class="form-group">
|
||||
<label for="test_script">Script path</label>
|
||||
<select class="form-control" id="test_script" name="test_script" >
|
||||
% for key, value in sorted(data[1]['select_options'].iteritems()):
|
||||
<option value="${key}">${value}</option>
|
||||
% endfor
|
||||
</select>
|
||||
<p class="help-block">Pick your script</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="test_script_action">Script action</label>
|
||||
<select class="form-control" id="test_script_action" name="test_script_action">
|
||||
<option value=""></option>
|
||||
<option value="buffer">Buffer warning</option>
|
||||
<option value="watched">Watched</option>
|
||||
<option value="play">Playback start</option>
|
||||
<option value="pause">Playback stopp</option>
|
||||
<option value="resume">Playback resume</option>
|
||||
<option value="stop">Playback stop</option>
|
||||
<option value="extdown">Plex Server Remote Down</option>
|
||||
<option value="extup">Plex Server Remote Up</option>
|
||||
<option value="intdown">Plex Server Down</option>
|
||||
<option value="intup">Plex Server Up</option>
|
||||
<option value="pause">Playback pause</option>
|
||||
<option value="resume">Playback resume</option>
|
||||
<option value="watched">Watched</option>
|
||||
<option value="buffer">Buffer warnings</option>
|
||||
<option value="created">Recently added</option>
|
||||
<option value="extdown">Plex remote access down</option>
|
||||
<option value="intdown">Plex server down</option>
|
||||
<option value="extup">Plex remote access back up</option>
|
||||
<option value="intup">Plex server back up</option>
|
||||
</select>
|
||||
<p class="help-block">Pick your action</p>
|
||||
<p class="help-block">Choose a notification action.</p>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="test_script_args">Script args</label>
|
||||
<input class="form-control" type="text" id="test_script_args" name="test_script_args" value="">
|
||||
<p class="help-block">Set a custom script args: -zomg --x.</p>
|
||||
<p class="help-block">Set custom script arguments: -zomg --x.</p>
|
||||
</div>
|
||||
% endif
|
||||
<div class="form-group">
|
||||
|
@ -185,7 +176,6 @@ from plexpy import helpers
|
|||
subject: $('#test_subject').val(),
|
||||
body: $('#test_body').val(),
|
||||
notify_action: $('#test_script_action').val(),
|
||||
script: $('#test_script').val(),
|
||||
script_args: $('#test_script_args').val() },
|
||||
cache: false,
|
||||
async: true,
|
||||
|
@ -196,13 +186,7 @@ from plexpy import helpers
|
|||
});
|
||||
});
|
||||
|
||||
$('#pushbullet_apikey, #pushover_apitoken').on('change', function () {
|
||||
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
||||
reloadModal();
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#scripts_folder').on('change', function () {
|
||||
$('#pushbullet_apikey, #pushover_apitoken, #scripts_folder').on('change', function () {
|
||||
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
||||
reloadModal();
|
||||
return false;
|
||||
|
|
|
@ -1014,6 +1014,14 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>{streams}</strong></td>
|
||||
<td>The number of concurrent streams.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{action}</strong></td>
|
||||
<td>The action that triggered the notification.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{user}</strong></td>
|
||||
<td>The username of the person streaming.</td>
|
||||
|
@ -1126,14 +1134,6 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
<td><strong>{transcode_audio_channels}</strong></td>
|
||||
<td>The audio channels of the transcoded media.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{streams}</strong></td>
|
||||
<td>The number of concurrent streams.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>{action}</strong></td>
|
||||
<td>The action that trigged the notification.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="notification-params">
|
||||
|
|
|
@ -516,6 +516,8 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
|
||||
available_params = {'server_name': server_name,
|
||||
'server_uptime': server_uptime,
|
||||
'streams': stream_count,
|
||||
'action': state,
|
||||
'user': user,
|
||||
'platform': platform,
|
||||
'player': player,
|
||||
|
@ -564,9 +566,7 @@ def build_notify_text(session=None, timeline=None, state=None):
|
|||
'summary': metadata['summary'],
|
||||
'tagline': metadata['tagline'],
|
||||
'rating': metadata['rating'],
|
||||
'duration': duration,
|
||||
'action': state,
|
||||
'streams': stream_count
|
||||
'duration': duration
|
||||
}
|
||||
|
||||
# Default subject text
|
||||
|
@ -780,6 +780,7 @@ def build_server_notify_text(state=None):
|
|||
on_extup_body = plexpy.CONFIG.NOTIFY_ON_EXTUP_BODY_TEXT
|
||||
on_intup_subject = plexpy.CONFIG.NOTIFY_ON_INTUP_SUBJECT_TEXT
|
||||
on_intup_body = plexpy.CONFIG.NOTIFY_ON_INTUP_BODY_TEXT
|
||||
script_args_text = plexpy.CONFIG.NOTIFY_SCRIPTS_ARGS_TEXT
|
||||
|
||||
available_params = {'server_name': server_name,
|
||||
'server_uptime': server_uptime,
|
||||
|
@ -790,7 +791,6 @@ def build_server_notify_text(state=None):
|
|||
|
||||
# Default scripts args
|
||||
script_args = []
|
||||
script_args_text = plexpy.CONFIG.NOTIFY_SCRIPTS_ARGS_TEXT
|
||||
|
||||
# Regex to match {param} but not "{param}"
|
||||
params_to_quote = re.compile(r'(?<!\")([\{][^}]+[\}])(?!\"\})')
|
||||
|
|
|
@ -1762,9 +1762,9 @@ class Scripts(object):
|
|||
notify_action(string): 'play'
|
||||
script_args(list): ["python2", '-p', '-zomg']
|
||||
"""
|
||||
logger.debug(u'Trying to run notify script subject: %s message: %s, action: %s script_args: %s' %
|
||||
logger.debug(u"PlexPy Notifiers :: Trying to run notify script, subject: %s, message: %s, action: %s, script_args: %s" %
|
||||
(subject, message, notify_action, script_args))
|
||||
|
||||
|
||||
prefix = ''
|
||||
script = kwargs.get('script', '') # for manual scripts
|
||||
|
||||
|
@ -1808,7 +1808,7 @@ class Scripts(object):
|
|||
# Dont try to run the script
|
||||
# if the action does not have one
|
||||
if not script:
|
||||
logger.debug(u'%s has no script, exiting..' % notify_action)
|
||||
logger.debug(u"PlexPy Notifiers :: Action %s has no script, exiting..." % notify_action)
|
||||
return
|
||||
|
||||
name, ext = os.path.splitext(script)
|
||||
|
@ -1847,7 +1847,7 @@ class Scripts(object):
|
|||
|
||||
script.extend(script_args)
|
||||
|
||||
logger.debug(u'Full script is %s' % script)
|
||||
logger.debug(u"PlexPy Notifiers :: Full script is: %s" % ' '.join(script))
|
||||
|
||||
try:
|
||||
p = subprocess.Popen(script, stdin=subprocess.PIPE,
|
||||
|
@ -1860,14 +1860,16 @@ class Scripts(object):
|
|||
|
||||
if out and status:
|
||||
out = out.strip()
|
||||
logger.debug(u'%s returned %s' % (script, out))
|
||||
logger.debug(u"PlexPy Notifiers :: Script returned %s" % out)
|
||||
|
||||
if error:
|
||||
error = error.strip()
|
||||
logger.error(u'%s' % error)
|
||||
logger.error(u"PlexPy Notifiers :: Script error: %s" % error)
|
||||
else:
|
||||
logger.info(u"PlexPy Notifiers :: Script notification sent.")
|
||||
|
||||
except OSError as out:
|
||||
logger.error(u'Failed to run %s error %s' % (script, out))
|
||||
except OSError as e:
|
||||
logger.error(u"PlexPy Notifiers :: Failed to run script: %s" % e)
|
||||
|
||||
def return_config_options(self):
|
||||
config_option = [{'label': 'Script folder',
|
||||
|
|
|
@ -663,7 +663,6 @@ class WebInterface(object):
|
|||
@cherrypy.expose
|
||||
def test_notifier(self, config_id=None, subject='PlexPy', body='Test notification', **kwargs):
|
||||
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||
print kwargs
|
||||
|
||||
if config_id.isdigit():
|
||||
agents = notifiers.available_notification_agents()
|
||||
|
@ -1422,12 +1421,6 @@ class WebInterface(object):
|
|||
return serve_template(templatename="notification_triggers_modal.html", title="Notification Triggers",
|
||||
data=this_agent)
|
||||
|
||||
@cherrypy.expose
|
||||
def testScripts(self, *args, **kwargs):
|
||||
''' Used for manual testing for now cba with adding buttion '''
|
||||
script = notifiers.Scripts()
|
||||
return script.test(*args, **kwargs)
|
||||
|
||||
@cherrypy.expose
|
||||
def delete_history_rows(self, row_id, **kwargs):
|
||||
data_factory = datafactory.DataFactory()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue