mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
A bit of script notifier cleanup
This commit is contained in:
parent
fbc527010a
commit
076dc94292
1 changed files with 32 additions and 60 deletions
|
@ -616,6 +616,7 @@ def send_notification(agent_id, subject, body, notify_action, **kwargs):
|
||||||
else:
|
else:
|
||||||
logger.debug(u"PlexPy Notifiers :: Notification requested but no agent id received.")
|
logger.debug(u"PlexPy Notifiers :: Notification requested but no agent id received.")
|
||||||
|
|
||||||
|
|
||||||
class PrettyMetadata(object):
|
class PrettyMetadata(object):
|
||||||
def __init__(self, metadata):
|
def __init__(self, metadata):
|
||||||
self.metadata = metadata
|
self.metadata = metadata
|
||||||
|
@ -683,6 +684,7 @@ class PrettyMetadata(object):
|
||||||
self.plex_url = self.metadata['plex_url']
|
self.plex_url = self.metadata['plex_url']
|
||||||
return self.plex_url
|
return self.plex_url
|
||||||
|
|
||||||
|
|
||||||
class GROWL(object):
|
class GROWL(object):
|
||||||
"""
|
"""
|
||||||
Growl notifications, for OS X.
|
Growl notifications, for OS X.
|
||||||
|
@ -2114,6 +2116,21 @@ class Scripts(object):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
self.script_exts = ('.bat', '.cmd', '.exe', '.php', '.pl', '.ps1', '.py', '.pyw', '.rb', '.sh')
|
self.script_exts = ('.bat', '.cmd', '.exe', '.php', '.pl', '.ps1', '.py', '.pyw', '.rb', '.sh')
|
||||||
self.script_folder = plexpy.CONFIG.SCRIPTS_FOLDER
|
self.script_folder = plexpy.CONFIG.SCRIPTS_FOLDER
|
||||||
|
self.scripts = {'play': plexpy.CONFIG.SCRIPTS_ON_PLAY_SCRIPT,
|
||||||
|
'stop': plexpy.CONFIG.SCRIPTS_ON_STOP_SCRIPT,
|
||||||
|
'pause': plexpy.CONFIG.SCRIPTS_ON_PAUSE_SCRIPT,
|
||||||
|
'resume': plexpy.CONFIG.SCRIPTS_ON_RESUME_SCRIPT,
|
||||||
|
'watched': plexpy.CONFIG.SCRIPTS_ON_WATCHED_SCRIPT,
|
||||||
|
'buffer': plexpy.CONFIG.SCRIPTS_ON_BUFFER_SCRIPT,
|
||||||
|
'created': plexpy.CONFIG.SCRIPTS_ON_CREATED_SCRIPT,
|
||||||
|
'intdown': plexpy.CONFIG.SCRIPTS_ON_INTDOWN_SCRIPT,
|
||||||
|
'intup': plexpy.CONFIG.SCRIPTS_ON_INTUP_SCRIPT,
|
||||||
|
'extdown': plexpy.CONFIG.SCRIPTS_ON_EXTDOWN_SCRIPT,
|
||||||
|
'extup': plexpy.CONFIG.SCRIPTS_ON_EXTUP_SCRIPT,
|
||||||
|
'pmsupdate': plexpy.CONFIG.SCRIPTS_ON_PMSUPDATE_SCRIPT,
|
||||||
|
'concurrent': plexpy.CONFIG.SCRIPTS_ON_CONCURRENT_SCRIPT,
|
||||||
|
'newdevice': plexpy.CONFIG.SCRIPTS_ON_NEWDEVICE_SCRIPT
|
||||||
|
}
|
||||||
|
|
||||||
def conf(self, options):
|
def conf(self, options):
|
||||||
return cherrypy.config['config'].get('Scripts', options)
|
return cherrypy.config['config'].get('Scripts', options)
|
||||||
|
@ -2160,52 +2177,7 @@ class Scripts(object):
|
||||||
if not self.script_folder:
|
if not self.script_folder:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Make sure we use the correct script..
|
script = self.scripts.get(notify_action, kwargs.get('script', ''))
|
||||||
if notify_action == 'play':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_PLAY_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'stop':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_STOP_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'pause':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_PAUSE_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'resume':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_RESUME_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'watched':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_WATCHED_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'buffer':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_BUFFER_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'created':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_CREATED_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'intdown':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_INTDOWN_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'intup':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_INTUP_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'extdown':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_EXTDOWN_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'extup':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_EXTUP_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'pmsupdate':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_PMSUPDATE_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'concurrent':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_CONCURRENT_SCRIPT
|
|
||||||
|
|
||||||
elif notify_action == 'newdevice':
|
|
||||||
script = plexpy.CONFIG.SCRIPTS_ON_NEWDEVICE_SCRIPT
|
|
||||||
|
|
||||||
else:
|
|
||||||
# For manual scripts
|
|
||||||
script = kwargs.get('script', '')
|
|
||||||
|
|
||||||
# Don't try to run the script if the action does not have one
|
# Don't try to run the script if the action does not have one
|
||||||
if notify_action and not script:
|
if notify_action and not script:
|
||||||
|
@ -2297,98 +2269,98 @@ class Scripts(object):
|
||||||
'input_type': 'text',
|
'input_type': 'text',
|
||||||
},
|
},
|
||||||
{'label': 'Playback Start',
|
{'label': 'Playback Start',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_PLAY_SCRIPT,
|
'value': self.scripts['play'],
|
||||||
'name': 'scripts_on_play_script',
|
'name': 'scripts_on_play_script',
|
||||||
'description': 'Choose the script for on play.',
|
'description': 'Choose the script for on play.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Playback Stop',
|
{'label': 'Playback Stop',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_STOP_SCRIPT,
|
'value': self.scripts['stop'],
|
||||||
'name': 'scripts_on_stop_script',
|
'name': 'scripts_on_stop_script',
|
||||||
'description': 'Choose the script for on stop.',
|
'description': 'Choose the script for on stop.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Playback Pause',
|
{'label': 'Playback Pause',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_PAUSE_SCRIPT,
|
'value': self.scripts['pause'],
|
||||||
'name': 'scripts_on_pause_script',
|
'name': 'scripts_on_pause_script',
|
||||||
'description': 'Choose the script for on pause.',
|
'description': 'Choose the script for on pause.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Playback Resume',
|
{'label': 'Playback Resume',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_RESUME_SCRIPT,
|
'value': self.scripts['resume'],
|
||||||
'name': 'scripts_on_resume_script',
|
'name': 'scripts_on_resume_script',
|
||||||
'description': 'Choose the script for on resume.',
|
'description': 'Choose the script for on resume.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Watched',
|
{'label': 'Watched',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_WATCHED_SCRIPT,
|
'value': self.scripts['watched'],
|
||||||
'name': 'scripts_on_watched_script',
|
'name': 'scripts_on_watched_script',
|
||||||
'description': 'Choose the script for on watched.',
|
'description': 'Choose the script for on watched.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Buffer Warnings',
|
{'label': 'Buffer Warnings',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_BUFFER_SCRIPT,
|
'value': self.scripts['buffer'],
|
||||||
'name': 'scripts_on_buffer_script',
|
'name': 'scripts_on_buffer_script',
|
||||||
'description': 'Choose the script for buffer warnings.',
|
'description': 'Choose the script for buffer warnings.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Recently Added',
|
{'label': 'Recently Added',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_CREATED_SCRIPT,
|
'value': self.scripts['created'],
|
||||||
'name': 'scripts_on_created_script',
|
'name': 'scripts_on_created_script',
|
||||||
'description': 'Choose the script for recently added.',
|
'description': 'Choose the script for recently added.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Plex Server Down',
|
{'label': 'Plex Server Down',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_INTDOWN_SCRIPT,
|
'value': self.scripts['intdown'],
|
||||||
'name': 'scripts_on_intdown_script',
|
'name': 'scripts_on_intdown_script',
|
||||||
'description': 'Choose the script for Plex server down.',
|
'description': 'Choose the script for Plex server down.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Plex Server Back Up',
|
{'label': 'Plex Server Back Up',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_INTUP_SCRIPT,
|
'value': self.scripts['intup'],
|
||||||
'name': 'scripts_on_intup_script',
|
'name': 'scripts_on_intup_script',
|
||||||
'description': 'Choose the script for Plex server back up.',
|
'description': 'Choose the script for Plex server back up.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Plex Remote Access Down',
|
{'label': 'Plex Remote Access Down',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_EXTDOWN_SCRIPT,
|
'value': self.scripts['extdown'],
|
||||||
'name': 'scripts_on_extdown_script',
|
'name': 'scripts_on_extdown_script',
|
||||||
'description': 'Choose the script for Plex remote access down.',
|
'description': 'Choose the script for Plex remote access down.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Plex Remote Access Back Up',
|
{'label': 'Plex Remote Access Back Up',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_EXTUP_SCRIPT,
|
'value': self.scripts['extup'],
|
||||||
'name': 'scripts_on_extup_script',
|
'name': 'scripts_on_extup_script',
|
||||||
'description': 'Choose the script for Plex remote access back up.',
|
'description': 'Choose the script for Plex remote access back up.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'Plex Update Available',
|
{'label': 'Plex Update Available',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_PMSUPDATE_SCRIPT,
|
'value': self.scripts['pmsupdate'],
|
||||||
'name': 'scripts_on_pmsupdate_script',
|
'name': 'scripts_on_pmsupdate_script',
|
||||||
'description': 'Choose the script for Plex update available.',
|
'description': 'Choose the script for Plex update available.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'User Concurrent Streams',
|
{'label': 'User Concurrent Streams',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_CONCURRENT_SCRIPT,
|
'value': self.scripts['concurrent'],
|
||||||
'name': 'scripts_on_concurrent_script',
|
'name': 'scripts_on_concurrent_script',
|
||||||
'description': 'Choose the script for user concurrent streams.',
|
'description': 'Choose the script for user concurrent streams.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
'select_options': self.list_scripts()
|
'select_options': self.list_scripts()
|
||||||
},
|
},
|
||||||
{'label': 'User New Device',
|
{'label': 'User New Device',
|
||||||
'value': plexpy.CONFIG.SCRIPTS_ON_NEWDEVICE_SCRIPT,
|
'value': self.scripts['newdevice'],
|
||||||
'name': 'scripts_on_newdevice_script',
|
'name': 'scripts_on_newdevice_script',
|
||||||
'description': 'Choose the script for user new device.',
|
'description': 'Choose the script for user new device.',
|
||||||
'input_type': 'select',
|
'input_type': 'select',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue