mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 07:22:37 -07:00
Add manual trigger for recently added notifications from the info page
This commit is contained in:
parent
4a16ee6865
commit
45f002a797
3 changed files with 54 additions and 8 deletions
|
@ -385,6 +385,20 @@ DOCUMENTATION :: END
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
|
<div class="btn-group">
|
||||||
|
<%
|
||||||
|
if data['media_type'] in ('movie', 'show', 'artist'):
|
||||||
|
full_title = data['title']
|
||||||
|
elif data['media_type'] in ('season', 'album'):
|
||||||
|
full_title = data['parent_title'] + ' - ' + data['title']
|
||||||
|
else:
|
||||||
|
full_title = data['grandparent_title'] + ' - ' + data['title']
|
||||||
|
%>
|
||||||
|
<button class="btn btn-dark" data-toggle="button" aria-pressed="false" autocomplete="off" id="send-recently-added-notification"
|
||||||
|
data-id="${data['rating_key']}" data-title="${full_title}">
|
||||||
|
<i class="fa fa-bell"></i> Recently Added Notification
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
% endif
|
% endif
|
||||||
<div class="btn-group colvis-button-bar"></div>
|
<div class="btn-group colvis-button-bar"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -547,6 +561,14 @@ DOCUMENTATION :: END
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#send-recently-added-notification').on('click', function () {
|
||||||
|
var full_title = $(this).data('title');
|
||||||
|
var msg = 'Are you sure you want to send a recently added notification for the following?<br><br><strong>' + full_title + '</strong>';
|
||||||
|
var url = 'send_manual_on_created';
|
||||||
|
var data = { rating_key: $(this).data('id') }
|
||||||
|
confirmAjaxCall(url, msg, data, false);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
% if data['media_type'] in ('show', 'season', 'artist', 'album'):
|
% if data['media_type'] in ('show', 'season', 'artist', 'album'):
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -68,7 +68,7 @@ def start_threads(num_threads=1):
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
def add_notifier_each(notify_action=None, stream_data=None, timeline_data=None, **kwargs):
|
def add_notifier_each(notify_action=None, stream_data=None, timeline_data=None, manual_trigger=False, **kwargs):
|
||||||
if not notify_action:
|
if not notify_action:
|
||||||
logger.debug(u"PlexPy NotificationHandler :: Notify called but no action received.")
|
logger.debug(u"PlexPy NotificationHandler :: Notify called but no action received.")
|
||||||
return
|
return
|
||||||
|
@ -86,9 +86,10 @@ def add_notifier_each(notify_action=None, stream_data=None, timeline_data=None,
|
||||||
|
|
||||||
if notifiers_enabled:
|
if notifiers_enabled:
|
||||||
# Check if notification conditions are satisfied
|
# Check if notification conditions are satisfied
|
||||||
conditions = notify_conditions(notify_action=notify_action,
|
conditions = manual_trigger or \
|
||||||
stream_data=stream_data,
|
notify_conditions(notify_action=notify_action,
|
||||||
timeline_data=timeline_data)
|
stream_data=stream_data,
|
||||||
|
timeline_data=timeline_data)
|
||||||
|
|
||||||
if notifiers_enabled and conditions:
|
if notifiers_enabled and conditions:
|
||||||
if stream_data or timeline_data:
|
if stream_data or timeline_data:
|
||||||
|
@ -96,6 +97,7 @@ def add_notifier_each(notify_action=None, stream_data=None, timeline_data=None,
|
||||||
parameters = build_media_notify_params(notify_action=notify_action,
|
parameters = build_media_notify_params(notify_action=notify_action,
|
||||||
session=stream_data,
|
session=stream_data,
|
||||||
timeline=timeline_data,
|
timeline=timeline_data,
|
||||||
|
manual_trigger=manual_trigger,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
else:
|
else:
|
||||||
# Build the notification parameters
|
# Build the notification parameters
|
||||||
|
@ -108,7 +110,7 @@ def add_notifier_each(notify_action=None, stream_data=None, timeline_data=None,
|
||||||
|
|
||||||
for notifier in notifiers_enabled:
|
for notifier in notifiers_enabled:
|
||||||
# Check custom user conditions
|
# Check custom user conditions
|
||||||
if notify_custom_conditions(notifier_id=notifier['id'], parameters=parameters):
|
if manual_trigger or notify_custom_conditions(notifier_id=notifier['id'], parameters=parameters):
|
||||||
# Add each notifier to the queue
|
# Add each notifier to the queue
|
||||||
data = {'notifier_id': notifier['id'],
|
data = {'notifier_id': notifier['id'],
|
||||||
'notify_action': notify_action,
|
'notify_action': notify_action,
|
||||||
|
@ -409,7 +411,7 @@ def set_notify_success(notification_id):
|
||||||
monitor_db.upsert(table_name='notify_log', key_dict=keys, value_dict=values)
|
monitor_db.upsert(table_name='notify_log', key_dict=keys, value_dict=values)
|
||||||
|
|
||||||
|
|
||||||
def build_media_notify_params(notify_action=None, session=None, timeline=None, **kwargs):
|
def build_media_notify_params(notify_action=None, session=None, timeline=None, manual_trigger=False, **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','')
|
||||||
|
@ -577,7 +579,8 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
poster_info = get_poster_info(poster_thumb=poster_thumb, poster_key=poster_key, poster_title=poster_title)
|
poster_info = get_poster_info(poster_thumb=poster_thumb, poster_key=poster_key, poster_title=poster_title)
|
||||||
metadata.update(poster_info)
|
metadata.update(poster_info)
|
||||||
|
|
||||||
if plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_GRANDPARENT and metadata['media_type'] in ('show', 'artist'):
|
if ((manual_trigger or plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_GRANDPARENT)
|
||||||
|
and metadata['media_type'] in ('show', 'artist')):
|
||||||
show_name = metadata['title']
|
show_name = metadata['title']
|
||||||
episode_name = ''
|
episode_name = ''
|
||||||
artist_name = metadata['title']
|
artist_name = metadata['title']
|
||||||
|
@ -591,7 +594,8 @@ def build_media_notify_params(notify_action=None, session=None, timeline=None, *
|
||||||
episode_num, episode_num00 = '', ''
|
episode_num, episode_num00 = '', ''
|
||||||
track_num, track_num00 = '', ''
|
track_num, track_num00 = '', ''
|
||||||
|
|
||||||
elif plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_PARENT and metadata['media_type'] in ('season', 'album'):
|
elif ((manual_trigger or plexpy.CONFIG.NOTIFY_GROUP_RECENTLY_ADDED_PARENT)
|
||||||
|
and metadata['media_type'] in ('season', 'album')):
|
||||||
show_name = metadata['parent_title']
|
show_name = metadata['parent_title']
|
||||||
episode_name = ''
|
episode_name = ''
|
||||||
artist_name = metadata['parent_title']
|
artist_name = metadata['parent_title']
|
||||||
|
|
|
@ -3591,6 +3591,26 @@ class WebInterface(object):
|
||||||
logger.warn(u"Unable to retrieve data for get_item_children.")
|
logger.warn(u"Unable to retrieve data for get_item_children.")
|
||||||
return serve_template(templatename="info_children_list.html", data=None, title="Children List")
|
return serve_template(templatename="info_children_list.html", data=None, title="Children List")
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
@cherrypy.tools.json_out()
|
||||||
|
@requireAuth()
|
||||||
|
def send_manual_on_created(self, rating_key='', **kwargs):
|
||||||
|
if rating_key:
|
||||||
|
pms_connect = pmsconnect.PmsConnect()
|
||||||
|
metadata = pms_connect.get_metadata_details(rating_key=rating_key)
|
||||||
|
data = {'timeline_data': metadata, 'notify_action': 'on_created', 'manual_trigger': True}
|
||||||
|
|
||||||
|
if metadata['media_type'] not in ('movie', 'episode', 'track'):
|
||||||
|
children = pms_connect.get_item_children(rating_key=rating_key)
|
||||||
|
child_keys = [child['rating_key'] for child in children['children_list'] if child['rating_key']]
|
||||||
|
data['child_keys'] = child_keys
|
||||||
|
|
||||||
|
plexpy.NOTIFY_QUEUE.put(data)
|
||||||
|
return {'result': 'success', 'message': 'Notification queued.'}
|
||||||
|
|
||||||
|
else:
|
||||||
|
return {'result': 'error', 'message': 'Notification failed.'}
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@requireAuth()
|
@requireAuth()
|
||||||
def pms_image_proxy(self, **kwargs):
|
def pms_image_proxy(self, **kwargs):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue