mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Some more cleanup
This commit is contained in:
parent
d8cc76c7d7
commit
303ccce8b4
4 changed files with 27 additions and 148 deletions
|
@ -326,7 +326,7 @@ def check_server_updates():
|
||||||
if download_info['update_available']:
|
if download_info['update_available']:
|
||||||
logger.info(u"PlexPy Monitor :: PMS update available version: %s", download_info['version'])
|
logger.info(u"PlexPy Monitor :: PMS update available version: %s", download_info['version'])
|
||||||
|
|
||||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_pmsupdate'})
|
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_pmsupdate', 'pms_download_info': download_info})
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.info(u"PlexPy Monitor :: No PMS update available.")
|
logger.info(u"PlexPy Monitor :: No PMS update available.")
|
|
@ -149,7 +149,8 @@ def notify(notifier_id=None, notify_action=None, stream_data=None, timeline_data
|
||||||
**kwargs)
|
**kwargs)
|
||||||
else:
|
else:
|
||||||
# Build the notification parameters
|
# Build the notification parameters
|
||||||
parameters, metadata = build_server_notify_params(notify_action=notify_action)
|
parameters, metadata = build_server_notify_params(notify_action=notify_action,
|
||||||
|
**kwargs)
|
||||||
|
|
||||||
if not parameters:
|
if not parameters:
|
||||||
logger.error(u"PlexPy NotificationHandler :: Failed to build notification parameters.")
|
logger.error(u"PlexPy NotificationHandler :: Failed to build notification parameters.")
|
||||||
|
@ -266,11 +267,9 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
child_metadata = grandchild_metadata = []
|
child_metadata = grandchild_metadata = []
|
||||||
if 'child_keys' in kwargs:
|
for key in kwargs.pop('child_keys', []):
|
||||||
for key in kwargs['child_keys']:
|
|
||||||
child_metadata.append(pms_connect.get_metadata_details(rating_key=key)['metadata'])
|
child_metadata.append(pms_connect.get_metadata_details(rating_key=key)['metadata'])
|
||||||
if 'grandchild_keys' in kwargs:
|
for key in kwargs.pop('grandchild_keys', []):
|
||||||
for key in kwargs['grandchild_keys']:
|
|
||||||
grandchild_metadata.append(pms_connect.get_metadata_details(rating_key=key)['metadata'])
|
grandchild_metadata.append(pms_connect.get_metadata_details(rating_key=key)['metadata'])
|
||||||
|
|
||||||
current_activity = pms_connect.get_current_activity()
|
current_activity = pms_connect.get_current_activity()
|
||||||
|
@ -427,7 +426,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
season_num = metadata['media_index'].zfill(1)
|
season_num = metadata['media_index'].zfill(1)
|
||||||
season_num00 = metadata['media_index'].zfill(2)
|
season_num00 = metadata['media_index'].zfill(2)
|
||||||
|
|
||||||
num, num00 = format_group_keys([helpers.cast_to_int(d['media_index'])
|
num, num00 = format_group_index([helpers.cast_to_int(d['media_index'])
|
||||||
for d in child_metadata if d['parent_rating_key'] == rating_key])
|
for d in child_metadata if d['parent_rating_key'] == rating_key])
|
||||||
episode_num, episode_num00 = num, num00
|
episode_num, episode_num00 = num, num00
|
||||||
track_num, track_num00 = num, num00
|
track_num, track_num00 = num, num00
|
||||||
|
@ -439,11 +438,11 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
album_name = ''
|
album_name = ''
|
||||||
track_name = ''
|
track_name = ''
|
||||||
|
|
||||||
num, num00 = format_group_keys([helpers.cast_to_int(d['media_index'])
|
num, num00 = format_group_index([helpers.cast_to_int(d['media_index'])
|
||||||
for d in child_metadata if d['parent_rating_key'] == rating_key])
|
for d in child_metadata if d['parent_rating_key'] == rating_key])
|
||||||
season_num, season_num00 = num, num00
|
season_num, season_num00 = num, num00
|
||||||
|
|
||||||
num, num00 = format_group_keys([helpers.cast_to_int(d['media_index'])
|
num, num00 = format_group_index([helpers.cast_to_int(d['media_index'])
|
||||||
for d in grandchild_metadata if d['grandparent_rating_key'] == rating_key])
|
for d in grandchild_metadata if d['grandparent_rating_key'] == rating_key])
|
||||||
episode_num, episode_num00 = num, num00
|
episode_num, episode_num00 = num, num00
|
||||||
track_num, track_num00 = num, num00
|
track_num, track_num00 = num, num00
|
||||||
|
@ -551,7 +550,7 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
return available_params, metadata
|
return available_params, metadata
|
||||||
|
|
||||||
|
|
||||||
def build_server_notify_params(notify_action=None):
|
def build_server_notify_params(notify_action=None, **kwargs):
|
||||||
# Get time formats
|
# Get time formats
|
||||||
date_format = plexpy.CONFIG.DATE_FORMAT.replace('Do','')
|
date_format = plexpy.CONFIG.DATE_FORMAT.replace('Do','')
|
||||||
time_format = plexpy.CONFIG.TIME_FORMAT.replace('Do','')
|
time_format = plexpy.CONFIG.TIME_FORMAT.replace('Do','')
|
||||||
|
@ -563,9 +562,7 @@ def build_server_notify_params(notify_action=None):
|
||||||
plex_tv = plextv.PlexTV()
|
plex_tv = plextv.PlexTV()
|
||||||
server_times = plex_tv.get_server_times()
|
server_times = plex_tv.get_server_times()
|
||||||
|
|
||||||
update_status = {}
|
pms_download_info = kwargs.pop('pms_download_info', {})
|
||||||
if notify_action == 'pmsupdate':
|
|
||||||
update_status = plex_tv.get_plex_downloads()
|
|
||||||
|
|
||||||
if server_times:
|
if server_times:
|
||||||
updated_at = server_times['updated_at']
|
updated_at = server_times['updated_at']
|
||||||
|
@ -581,19 +578,20 @@ def build_server_notify_params(notify_action=None):
|
||||||
'action': notify_action.split('on_')[-1].title(),
|
'action': notify_action.split('on_')[-1].title(),
|
||||||
'datestamp': arrow.now().format(date_format),
|
'datestamp': arrow.now().format(date_format),
|
||||||
'timestamp': arrow.now().format(time_format),
|
'timestamp': arrow.now().format(time_format),
|
||||||
# Update parameters
|
# Plex Media Server update parameters
|
||||||
'update_version': update_status.get('version',''),
|
'update_version': pms_download_info.get('version',''),
|
||||||
'update_url': update_status.get('download_url',''),
|
'update_url': pms_download_info.get('download_url',''),
|
||||||
'update_release_date': arrow.get(update_status.get('release_date','')).format(date_format)
|
'update_release_date': arrow.get(pms_download_info.get('release_date','')).format(date_format)
|
||||||
if update_status.get('release_date','') else '',
|
if pms_download_info.get('release_date','') else '',
|
||||||
'update_channel': 'Plex Pass' if plexpy.CONFIG.PMS_UPDATE_CHANNEL == 'plexpass' else 'Public',
|
'update_channel': 'Plex Pass' if plexpy.CONFIG.PMS_UPDATE_CHANNEL == 'plexpass' else 'Public',
|
||||||
'update_platform': update_status.get('platform',''),
|
'update_platform': pms_download_info.get('platform',''),
|
||||||
'update_distro': update_status.get('distro',''),
|
'update_distro': pms_download_info.get('distro',''),
|
||||||
'update_distro_build': update_status.get('build',''),
|
'update_distro_build': pms_download_info.get('build',''),
|
||||||
'update_requirements': update_status.get('requirements',''),
|
'update_requirements': pms_download_info.get('requirements',''),
|
||||||
'update_extra_info': update_status.get('extra_info',''),
|
'update_extra_info': pms_download_info.get('extra_info',''),
|
||||||
'update_changelog_added': update_status.get('changelog_added',''),
|
'update_changelog_added': pms_download_info.get('changelog_added',''),
|
||||||
'update_changelog_fixed': update_status.get('changelog_fixed','')}
|
'update_changelog_fixed': pms_download_info.get('changelog_fixed',''),
|
||||||
|
}
|
||||||
|
|
||||||
return available_params, None
|
return available_params, None
|
||||||
|
|
||||||
|
@ -685,7 +683,8 @@ def strip_tag(data, agent_id=None):
|
||||||
whitelist = {}
|
whitelist = {}
|
||||||
return bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True)
|
return bleach.clean(data, tags=whitelist.keys(), attributes=whitelist, strip=True)
|
||||||
|
|
||||||
def format_group_keys(group_keys):
|
|
||||||
|
def format_group_index(group_keys):
|
||||||
num = []
|
num = []
|
||||||
num00 = []
|
num00 = []
|
||||||
|
|
||||||
|
|
|
@ -2024,97 +2024,6 @@ class SCRIPTS(Notifier):
|
||||||
'name': 'scripts_timeout',
|
'name': 'scripts_timeout',
|
||||||
'description': 'The number of seconds to wait before killing the script. 0 to disable timeout.',
|
'description': 'The number of seconds to wait before killing the script. 0 to disable timeout.',
|
||||||
'input_type': 'number'
|
'input_type': 'number'
|
||||||
# },
|
|
||||||
#{'label': 'Playback Stop',
|
|
||||||
# 'value': self.scripts['stop'],
|
|
||||||
# 'name': 'scripts_on_stop_script',
|
|
||||||
# 'description': 'Choose the script for on stop.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Playback Pause',
|
|
||||||
# 'value': self.scripts['pause'],
|
|
||||||
# 'name': 'scripts_on_pause_script',
|
|
||||||
# 'description': 'Choose the script for on pause.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Playback Resume',
|
|
||||||
# 'value': self.scripts['resume'],
|
|
||||||
# 'name': 'scripts_on_resume_script',
|
|
||||||
# 'description': 'Choose the script for on resume.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Watched',
|
|
||||||
# 'value': self.scripts['watched'],
|
|
||||||
# 'name': 'scripts_on_watched_script',
|
|
||||||
# 'description': 'Choose the script for on watched.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Buffer Warnings',
|
|
||||||
# 'value': self.scripts['buffer'],
|
|
||||||
# 'name': 'scripts_on_buffer_script',
|
|
||||||
# 'description': 'Choose the script for buffer warnings.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Recently Added',
|
|
||||||
# 'value': self.scripts['created'],
|
|
||||||
# 'name': 'scripts_on_created_script',
|
|
||||||
# 'description': 'Choose the script for recently added.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Plex Server Down',
|
|
||||||
# 'value': self.scripts['intdown'],
|
|
||||||
# 'name': 'scripts_on_intdown_script',
|
|
||||||
# 'description': 'Choose the script for Plex server down.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Plex Server Back Up',
|
|
||||||
# 'value': self.scripts['intup'],
|
|
||||||
# 'name': 'scripts_on_intup_script',
|
|
||||||
# 'description': 'Choose the script for Plex server back up.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Plex Remote Access Down',
|
|
||||||
# 'value': self.scripts['extdown'],
|
|
||||||
# 'name': 'scripts_on_extdown_script',
|
|
||||||
# 'description': 'Choose the script for Plex remote access down.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Plex Remote Access Back Up',
|
|
||||||
# 'value': self.scripts['extup'],
|
|
||||||
# 'name': 'scripts_on_extup_script',
|
|
||||||
# 'description': 'Choose the script for Plex remote access back up.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'Plex Update Available',
|
|
||||||
# 'value': self.scripts['pmsupdate'],
|
|
||||||
# 'name': 'scripts_on_pmsupdate_script',
|
|
||||||
# 'description': 'Choose the script for Plex update available.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'User Concurrent Streams',
|
|
||||||
# 'value': self.scripts['concurrent'],
|
|
||||||
# 'name': 'scripts_on_concurrent_script',
|
|
||||||
# 'description': 'Choose the script for user concurrent streams.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
# },
|
|
||||||
#{'label': 'User New Device',
|
|
||||||
# 'value': self.scripts['newdevice'],
|
|
||||||
# 'name': 'scripts_on_newdevice_script',
|
|
||||||
# 'description': 'Choose the script for user new device.',
|
|
||||||
# 'input_type': 'select',
|
|
||||||
# 'select_options': self.list_scripts()
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -2575,35 +2575,6 @@ class WebInterface(object):
|
||||||
"notify_concurrent_by_ip": checked(plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP),
|
"notify_concurrent_by_ip": checked(plexpy.CONFIG.NOTIFY_CONCURRENT_BY_IP),
|
||||||
"notify_concurrent_threshold": plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD,
|
"notify_concurrent_threshold": plexpy.CONFIG.NOTIFY_CONCURRENT_THRESHOLD,
|
||||||
"notify_watched_percent": plexpy.CONFIG.NOTIFY_WATCHED_PERCENT,
|
"notify_watched_percent": plexpy.CONFIG.NOTIFY_WATCHED_PERCENT,
|
||||||
"notify_on_start_subject_text": plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT,
|
|
||||||
"notify_on_start_body_text": plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT,
|
|
||||||
"notify_on_stop_subject_text": plexpy.CONFIG.NOTIFY_ON_STOP_SUBJECT_TEXT,
|
|
||||||
"notify_on_stop_body_text": plexpy.CONFIG.NOTIFY_ON_STOP_BODY_TEXT,
|
|
||||||
"notify_on_pause_subject_text": plexpy.CONFIG.NOTIFY_ON_PAUSE_SUBJECT_TEXT,
|
|
||||||
"notify_on_pause_body_text": plexpy.CONFIG.NOTIFY_ON_PAUSE_BODY_TEXT,
|
|
||||||
"notify_on_resume_subject_text": plexpy.CONFIG.NOTIFY_ON_RESUME_SUBJECT_TEXT,
|
|
||||||
"notify_on_resume_body_text": plexpy.CONFIG.NOTIFY_ON_RESUME_BODY_TEXT,
|
|
||||||
"notify_on_buffer_subject_text": plexpy.CONFIG.NOTIFY_ON_BUFFER_SUBJECT_TEXT,
|
|
||||||
"notify_on_buffer_body_text": plexpy.CONFIG.NOTIFY_ON_BUFFER_BODY_TEXT,
|
|
||||||
"notify_on_watched_subject_text": plexpy.CONFIG.NOTIFY_ON_WATCHED_SUBJECT_TEXT,
|
|
||||||
"notify_on_watched_body_text": plexpy.CONFIG.NOTIFY_ON_WATCHED_BODY_TEXT,
|
|
||||||
"notify_on_created_subject_text": plexpy.CONFIG.NOTIFY_ON_CREATED_SUBJECT_TEXT,
|
|
||||||
"notify_on_created_body_text": plexpy.CONFIG.NOTIFY_ON_CREATED_BODY_TEXT,
|
|
||||||
"notify_on_extdown_subject_text": plexpy.CONFIG.NOTIFY_ON_EXTDOWN_SUBJECT_TEXT,
|
|
||||||
"notify_on_extdown_body_text": plexpy.CONFIG.NOTIFY_ON_EXTDOWN_BODY_TEXT,
|
|
||||||
"notify_on_intdown_subject_text": plexpy.CONFIG.NOTIFY_ON_INTDOWN_SUBJECT_TEXT,
|
|
||||||
"notify_on_intdown_body_text": plexpy.CONFIG.NOTIFY_ON_INTDOWN_BODY_TEXT,
|
|
||||||
"notify_on_extup_subject_text": plexpy.CONFIG.NOTIFY_ON_EXTUP_SUBJECT_TEXT,
|
|
||||||
"notify_on_extup_body_text": plexpy.CONFIG.NOTIFY_ON_EXTUP_BODY_TEXT,
|
|
||||||
"notify_on_intup_subject_text": plexpy.CONFIG.NOTIFY_ON_INTUP_SUBJECT_TEXT,
|
|
||||||
"notify_on_intup_body_text": plexpy.CONFIG.NOTIFY_ON_INTUP_BODY_TEXT,
|
|
||||||
"notify_on_pmsupdate_subject_text": plexpy.CONFIG.NOTIFY_ON_PMSUPDATE_SUBJECT_TEXT,
|
|
||||||
"notify_on_pmsupdate_body_text": plexpy.CONFIG.NOTIFY_ON_PMSUPDATE_BODY_TEXT,
|
|
||||||
"notify_on_concurrent_subject_text": plexpy.CONFIG.NOTIFY_ON_CONCURRENT_SUBJECT_TEXT,
|
|
||||||
"notify_on_concurrent_body_text": plexpy.CONFIG.NOTIFY_ON_CONCURRENT_BODY_TEXT,
|
|
||||||
"notify_on_newdevice_subject_text": plexpy.CONFIG.NOTIFY_ON_NEWDEVICE_SUBJECT_TEXT,
|
|
||||||
"notify_on_newdevice_body_text": plexpy.CONFIG.NOTIFY_ON_NEWDEVICE_BODY_TEXT,
|
|
||||||
"notify_scripts_args_text": plexpy.CONFIG.NOTIFY_SCRIPTS_ARGS_TEXT,
|
|
||||||
"home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS),
|
"home_sections": json.dumps(plexpy.CONFIG.HOME_SECTIONS),
|
||||||
"home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH,
|
"home_stats_length": plexpy.CONFIG.HOME_STATS_LENGTH,
|
||||||
"home_stats_type": checked(plexpy.CONFIG.HOME_STATS_TYPE),
|
"home_stats_type": checked(plexpy.CONFIG.HOME_STATS_TYPE),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue