mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Multithreaded notification queue
This commit is contained in:
parent
82f4c99025
commit
08a8b5fee0
5 changed files with 38 additions and 58 deletions
|
@ -48,8 +48,7 @@ def check_active_sessions(ws_request=False):
|
|||
if int_ping_count >= 3:
|
||||
logger.info(u"PlexPy Monitor :: The Plex Media Server is back up.")
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
notify_action='on_intup'))
|
||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intup'})
|
||||
|
||||
int_ping_count = 0
|
||||
|
||||
|
@ -70,14 +69,12 @@ def check_active_sessions(ws_request=False):
|
|||
if session['state'] == 'paused':
|
||||
logger.debug(u"PlexPy Monitor :: Session %s has been paused." % stream['session_key'])
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
stream_data=stream, notify_action='on_pause'))
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_pause'})
|
||||
|
||||
if session['state'] == 'playing' and stream['state'] == 'paused':
|
||||
logger.debug(u"PlexPy Monitor :: Session %s has been resumed." % stream['session_key'])
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
stream_data=stream, notify_action='on_resume'))
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_resume'})
|
||||
|
||||
if stream['state'] == 'paused' and not ws_request:
|
||||
# The stream is still paused so we need to increment the paused_counter
|
||||
|
@ -115,8 +112,7 @@ def check_active_sessions(ws_request=False):
|
|||
'WHERE session_key = ? AND rating_key = ?',
|
||||
[stream['session_key'], stream['rating_key']])
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
stream_data=stream, notify_action='on_buffer'))
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_buffer'})
|
||||
|
||||
else:
|
||||
# Subsequent buffer notifications after wait time
|
||||
|
@ -130,8 +126,7 @@ def check_active_sessions(ws_request=False):
|
|||
'WHERE session_key = ? AND rating_key = ?',
|
||||
[stream['session_key'], stream['rating_key']])
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
stream_data=stream, notify_action='on_buffer'))
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_buffer'})
|
||||
|
||||
logger.debug(u"PlexPy Monitor :: Session %s is buffering. Count is now %s. Last triggered %s."
|
||||
% (stream['session_key'],
|
||||
|
@ -146,8 +141,7 @@ def check_active_sessions(ws_request=False):
|
|||
notify_states = notification_handler.get_notify_state(session=session)
|
||||
if progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT \
|
||||
and not any(d['notify_action'] == 'on_watched' for d in notify_states):
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
stream_data=stream, notify_action='on_watched'))
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_watched'})
|
||||
|
||||
else:
|
||||
# The user has stopped playing a stream
|
||||
|
@ -165,11 +159,9 @@ def check_active_sessions(ws_request=False):
|
|||
notify_states = notification_handler.get_notify_state(session=stream)
|
||||
if progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT \
|
||||
and not any(d['notify_action'] == 'on_watched' for d in notify_states):
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
stream_data=stream, notify_action='on_watched'))
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_watched'})
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
stream_data=stream, notify_action='on_stop'))
|
||||
plexpy.NOTIFY_QUEUE.put({'stream_data': stream, 'notify_action': 'on_stop'})
|
||||
|
||||
# Write the item history on playback stop
|
||||
success = monitor_process.write_session_history(session=stream)
|
||||
|
@ -221,8 +213,7 @@ def check_active_sessions(ws_request=False):
|
|||
% str(int_ping_count))
|
||||
|
||||
if int_ping_count == 3:
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
notify_action='on_intdown'))
|
||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_intdown'})
|
||||
|
||||
|
||||
def check_recently_added():
|
||||
|
@ -275,8 +266,7 @@ def check_recently_added():
|
|||
if 0 < time_threshold - int(item['added_at']) <= time_interval:
|
||||
logger.debug(u"PlexPy Monitor :: Library item %s has been added to Plex." % str(item['rating_key']))
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
timeline_data=item, notify_action='on_created'))
|
||||
plexpy.NOTIFY_QUEUE.put({'timeline_data': item, 'notify_action': 'on_created'})
|
||||
|
||||
else:
|
||||
item = max(metadata, key=lambda x:x['added_at'])
|
||||
|
@ -294,8 +284,7 @@ def check_recently_added():
|
|||
logger.debug(u"PlexPy Monitor :: Library item %s has been added to Plex." % str(item['rating_key']))
|
||||
|
||||
# Check if any notification agents have notifications enabled
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
timeline_data=item, notify_action='on_created'))
|
||||
plexpy.NOTIFY_QUEUE.put({'timeline_data': item, 'notify_action': 'on_created'})
|
||||
|
||||
|
||||
def check_server_response():
|
||||
|
@ -327,14 +316,12 @@ def check_server_response():
|
|||
if ext_ping_count >= 3:
|
||||
logger.info(u"PlexPy Monitor :: Plex remote access is back up.")
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
notify_action='on_extup'))
|
||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_extup'})
|
||||
|
||||
ext_ping_count = 0
|
||||
|
||||
if ext_ping_count == 3:
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
notify_action='on_extdown'))
|
||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_extdown'})
|
||||
|
||||
|
||||
def check_server_updates():
|
||||
|
@ -351,8 +338,7 @@ def check_server_updates():
|
|||
if download_info['update_available']:
|
||||
logger.info(u"PlexPy Monitor :: PMS update available version: %s", download_info['version'])
|
||||
|
||||
plexpy.NOTIFY_QUEUE.put(notification_handler.add_to_queue(
|
||||
notify_action='on_pmsupdate'))
|
||||
plexpy.NOTIFY_QUEUE.put({'notify_action': 'on_pmsupdate'})
|
||||
|
||||
else:
|
||||
logger.info(u"PlexPy Monitor :: No PMS update available.")
|
Loading…
Add table
Add a link
Reference in a new issue