mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-23 06:25:27 -07:00
Merge 447caa9e9e
into bea82c6640
This commit is contained in:
commit
77af41a611
1 changed files with 13 additions and 6 deletions
|
@ -16,7 +16,7 @@
|
||||||
import time
|
import time
|
||||||
import plexpy
|
import plexpy
|
||||||
|
|
||||||
from plexpy import logger, pmsconnect, activity_processor, threading, notification_handler, helpers
|
from plexpy import logger, pmsconnect, activity_processor, threading, notification_handler, helpers, notifiers
|
||||||
|
|
||||||
|
|
||||||
class ActivityHandler(object):
|
class ActivityHandler(object):
|
||||||
|
@ -201,11 +201,18 @@ class ActivityHandler(object):
|
||||||
self.on_start()
|
self.on_start()
|
||||||
|
|
||||||
# Monitor if the stream has reached the watch percentage for notifications
|
# Monitor if the stream has reached the watch percentage for notifications
|
||||||
# The only purpose of this is for notifications
|
# The only purpose of this is for notifications. Only process if any agents have on_watched toggled.
|
||||||
|
if any(d['on_watched'] == 1 for d in notifiers.available_notification_agents()):
|
||||||
progress_percent = helpers.get_percent(self.timeline['viewOffset'], db_session['duration'])
|
progress_percent = helpers.get_percent(self.timeline['viewOffset'], db_session['duration'])
|
||||||
if progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT and this_state != 'buffering':
|
if progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT and this_state != 'buffering':
|
||||||
threading.Thread(target=notification_handler.notify,
|
# This is cheaper than having to send the request to notify each time.
|
||||||
kwargs=dict(stream_data=db_session, notify_action='watched')).start()
|
notify_states = notification_handler.get_notify_state(db_session)
|
||||||
|
|
||||||
|
# This is a bit hacky but we're unaware of agents here so just check if any watched
|
||||||
|
# notifications are pending and allow it.
|
||||||
|
if any(d['on_watched'] is None for d in notify_states):
|
||||||
|
# Rather not put this on it's own thread so we know it completes before our next event.
|
||||||
|
notification_handler.notify(stream_data=db_session, notify_action='watched')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# We don't have this session in our table yet, start a new one.
|
# We don't have this session in our table yet, start a new one.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue