mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-22 06:13:25 -07:00
Merge f3f031bd9c
into f7bc208fd1
This commit is contained in:
commit
dd9cfd555e
6 changed files with 53 additions and 31 deletions
|
@ -38,6 +38,7 @@
|
||||||
type: "post",
|
type: "post",
|
||||||
data: function ( d ) {
|
data: function ( d ) {
|
||||||
return { 'json_data': JSON.stringify( d ),
|
return { 'json_data': JSON.stringify( d ),
|
||||||
|
'grouping': false,
|
||||||
'start_date': '${data}'
|
'start_date': '${data}'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,6 +496,12 @@ available_notification_agents = notifiers.available_notification_agents()
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">Set the progress percentage of when a watched notification should be triggered. Minimum 50, Maximum 95.</p>
|
<p class="help-block">Set the progress percentage of when a watched notification should be triggered. Minimum 50, Maximum 95.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="notify_consecutive" id="notify_consecutive" value="1" ${config['notify_consecutive']}> Allow Consecutive Notifications
|
||||||
|
</label>
|
||||||
|
<p class="help-block">Disable to prevent consecutive notifications (i.e. both watched & stopped notifications).</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="padded-header">
|
<div class="padded-header">
|
||||||
<h3>Custom Notification Messages</h3>
|
<h3>Custom Notification Messages</h3>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# This file is part of PlexPy.
|
# This file is part of PlexPy.
|
||||||
#
|
#
|
||||||
# PlexPy is free software: you can redistribute it and/or modify
|
# PlexPy is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
import time
|
import time
|
||||||
import plexpy
|
import plexpy
|
||||||
|
|
||||||
from plexpy import logger, pmsconnect, activity_processor, threading, notification_handler
|
from plexpy import logger, pmsconnect, activity_processor, threading, notification_handler, helpers
|
||||||
|
|
||||||
|
|
||||||
class ActivityHandler(object):
|
class ActivityHandler(object):
|
||||||
|
@ -83,8 +83,10 @@ class ActivityHandler(object):
|
||||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||||
|
|
||||||
# Fire off notifications
|
# Fire off notifications
|
||||||
threading.Thread(target=notification_handler.notify,
|
progress_percent = helpers.get_percent(self.timeline['viewOffset'], db_session['duration'])
|
||||||
kwargs=dict(stream_data=db_session, notify_action='stop')).start()
|
if plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < plexpy.CONFIG.NOTIFY_WATCHED_PERCENT:
|
||||||
|
threading.Thread(target=notification_handler.notify,
|
||||||
|
kwargs=dict(stream_data=db_session, notify_action='stop')).start()
|
||||||
|
|
||||||
# Write it to the history table
|
# Write it to the history table
|
||||||
monitor_proc = activity_processor.ActivityProcessor()
|
monitor_proc = activity_processor.ActivityProcessor()
|
||||||
|
@ -110,8 +112,10 @@ class ActivityHandler(object):
|
||||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||||
|
|
||||||
# Fire off notifications
|
# Fire off notifications
|
||||||
threading.Thread(target=notification_handler.notify,
|
progress_percent = helpers.get_percent(self.timeline['viewOffset'], db_session['duration'])
|
||||||
kwargs=dict(stream_data=db_session, notify_action='pause')).start()
|
if plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < 99:
|
||||||
|
threading.Thread(target=notification_handler.notify,
|
||||||
|
kwargs=dict(stream_data=db_session, notify_action='pause')).start()
|
||||||
|
|
||||||
def on_resume(self):
|
def on_resume(self):
|
||||||
if self.is_valid_session():
|
if self.is_valid_session():
|
||||||
|
@ -130,8 +134,10 @@ class ActivityHandler(object):
|
||||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||||
|
|
||||||
# Fire off notifications
|
# Fire off notifications
|
||||||
threading.Thread(target=notification_handler.notify,
|
progress_percent = helpers.get_percent(self.timeline['viewOffset'], db_session['duration'])
|
||||||
kwargs=dict(stream_data=db_session, notify_action='resume')).start()
|
if plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < 99:
|
||||||
|
threading.Thread(target=notification_handler.notify,
|
||||||
|
kwargs=dict(stream_data=db_session, notify_action='resume')).start()
|
||||||
|
|
||||||
def on_buffer(self):
|
def on_buffer(self):
|
||||||
if self.is_valid_session():
|
if self.is_valid_session():
|
||||||
|
@ -165,8 +171,6 @@ class ActivityHandler(object):
|
||||||
# This function receives events from our websocket connection
|
# This function receives events from our websocket connection
|
||||||
def process(self):
|
def process(self):
|
||||||
if self.is_valid_session():
|
if self.is_valid_session():
|
||||||
from plexpy import helpers
|
|
||||||
|
|
||||||
ap = activity_processor.ActivityProcessor()
|
ap = activity_processor.ActivityProcessor()
|
||||||
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
db_session = ap.get_session_by_key(session_key=self.get_session_key())
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# This file is part of PlexPy.
|
# This file is part of PlexPy.
|
||||||
#
|
#
|
||||||
# PlexPy is free software: you can redistribute it and/or modify
|
# PlexPy is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -48,6 +48,12 @@ def check_active_sessions(ws_request=False):
|
||||||
for stream in db_streams:
|
for stream in db_streams:
|
||||||
if any(d['session_key'] == str(stream['session_key']) and d['rating_key'] == str(stream['rating_key'])
|
if any(d['session_key'] == str(stream['session_key']) and d['rating_key'] == str(stream['rating_key'])
|
||||||
for d in media_container):
|
for d in media_container):
|
||||||
|
|
||||||
|
if stream['view_offset'] and stream['duration']:
|
||||||
|
progress_percent = helpers.get_percent(stream['view_offset'], stream['duration'])
|
||||||
|
else:
|
||||||
|
progress_percent = None
|
||||||
|
|
||||||
# The user's session is still active
|
# The user's session is still active
|
||||||
for session in media_container:
|
for session in media_container:
|
||||||
if session['session_key'] == str(stream['session_key']) and \
|
if session['session_key'] == str(stream['session_key']) and \
|
||||||
|
@ -55,13 +61,15 @@ def check_active_sessions(ws_request=False):
|
||||||
# The user is still playing the same media item
|
# The user is still playing the same media item
|
||||||
# Here we can check the play states
|
# Here we can check the play states
|
||||||
if session['state'] != stream['state']:
|
if session['state'] != stream['state']:
|
||||||
if session['state'] == 'paused':
|
if session['state'] == 'paused' \
|
||||||
|
and (plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < 99):
|
||||||
# Push any notifications -
|
# Push any notifications -
|
||||||
# Push it on it's own thread so we don't hold up our db actions
|
# Push it on it's own thread so we don't hold up our db actions
|
||||||
threading.Thread(target=notification_handler.notify,
|
threading.Thread(target=notification_handler.notify,
|
||||||
kwargs=dict(stream_data=stream, notify_action='pause')).start()
|
kwargs=dict(stream_data=stream, notify_action='pause')).start()
|
||||||
|
|
||||||
if session['state'] == 'playing' and stream['state'] == 'paused':
|
if session['state'] == 'playing' and stream['state'] == 'paused' \
|
||||||
|
and (plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < 99):
|
||||||
# Push any notifications -
|
# Push any notifications -
|
||||||
# Push it on it's own thread so we don't hold up our db actions
|
# Push it on it's own thread so we don't hold up our db actions
|
||||||
threading.Thread(target=notification_handler.notify,
|
threading.Thread(target=notification_handler.notify,
|
||||||
|
@ -126,13 +134,11 @@ def check_active_sessions(ws_request=False):
|
||||||
# Check if the user has reached the offset in the media we defined as the "watched" percent
|
# Check if the user has reached the offset in the media we defined as the "watched" percent
|
||||||
# Don't trigger if state is buffer as some clients push the progress to the end when
|
# Don't trigger if state is buffer as some clients push the progress to the end when
|
||||||
# buffering on start.
|
# buffering on start.
|
||||||
if session['view_offset'] and session['duration'] and session['state'] != 'buffering':
|
if progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT and session['state'] != 'buffering':
|
||||||
if helpers.get_percent(session['view_offset'],
|
# Push any notifications -
|
||||||
session['duration']) > plexpy.CONFIG.NOTIFY_WATCHED_PERCENT:
|
# Push it on it's own thread so we don't hold up our db actions
|
||||||
# Push any notifications -
|
threading.Thread(target=notification_handler.notify,
|
||||||
# Push it on it's own thread so we don't hold up our db actions
|
kwargs=dict(stream_data=stream, notify_action='watched')).start()
|
||||||
threading.Thread(target=notification_handler.notify,
|
|
||||||
kwargs=dict(stream_data=stream, notify_action='watched')).start()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# The user has stopped playing a stream
|
# The user has stopped playing a stream
|
||||||
|
@ -141,18 +147,21 @@ def check_active_sessions(ws_request=False):
|
||||||
monitor_db.action('DELETE FROM sessions WHERE session_key = ? AND rating_key = ?',
|
monitor_db.action('DELETE FROM sessions WHERE session_key = ? AND rating_key = ?',
|
||||||
[stream['session_key'], stream['rating_key']])
|
[stream['session_key'], stream['rating_key']])
|
||||||
|
|
||||||
# Check if the user has reached the offset in the media we defined as the "watched" percent
|
|
||||||
if stream['view_offset'] and stream['duration']:
|
if stream['view_offset'] and stream['duration']:
|
||||||
if helpers.get_percent(stream['view_offset'],
|
progress_percent = helpers.get_percent(stream['view_offset'], stream['duration'])
|
||||||
stream['duration']) > plexpy.CONFIG.NOTIFY_WATCHED_PERCENT:
|
else:
|
||||||
# Push any notifications -
|
progress_percent = None
|
||||||
# Push it on it's own thread so we don't hold up our db actions
|
|
||||||
threading.Thread(target=notification_handler.notify,
|
|
||||||
kwargs=dict(stream_data=stream, notify_action='watched')).start()
|
|
||||||
|
|
||||||
# Push any notifications - Push it on it's own thread so we don't hold up our db actions
|
# Check if the user has reached the offset in the media we defined as the "watched" percent
|
||||||
threading.Thread(target=notification_handler.notify,
|
if plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent >= plexpy.CONFIG.NOTIFY_WATCHED_PERCENT:
|
||||||
kwargs=dict(stream_data=stream, notify_action='stop')).start()
|
# Push any notifications -
|
||||||
|
# Push it on it's own thread so we don't hold up our db actions
|
||||||
|
threading.Thread(target=notification_handler.notify,
|
||||||
|
kwargs=dict(stream_data=stream, notify_action='watched')).start()
|
||||||
|
if plexpy.CONFIG.NOTIFY_CONSECUTIVE or progress_percent < plexpy.CONFIG.NOTIFY_WATCHED_PERCENT:
|
||||||
|
# Push any notifications - Push it on it's own thread so we don't hold up our db actions
|
||||||
|
threading.Thread(target=notification_handler.notify,
|
||||||
|
kwargs=dict(stream_data=stream, notify_action='stop')).start()
|
||||||
|
|
||||||
# Write the item history on playback stop
|
# Write the item history on playback stop
|
||||||
monitor_process.write_session_history(session=stream)
|
monitor_process.write_session_history(session=stream)
|
||||||
|
|
|
@ -122,6 +122,7 @@ _CONFIG_DEFINITIONS = {
|
||||||
'NMA_ON_RESUME': (int, 'NMA', 0),
|
'NMA_ON_RESUME': (int, 'NMA', 0),
|
||||||
'NMA_ON_BUFFER': (int, 'NMA', 0),
|
'NMA_ON_BUFFER': (int, 'NMA', 0),
|
||||||
'NMA_ON_WATCHED': (int, 'NMA', 0),
|
'NMA_ON_WATCHED': (int, 'NMA', 0),
|
||||||
|
'NOTIFY_CONSECUTIVE': (int, 'Monitoring', 1),
|
||||||
'NOTIFY_WATCHED_PERCENT': (int, 'Monitoring', 85),
|
'NOTIFY_WATCHED_PERCENT': (int, 'Monitoring', 85),
|
||||||
'NOTIFY_ON_START_SUBJECT_TEXT': (str, 'Monitoring', 'PlexPy ({server_name})'),
|
'NOTIFY_ON_START_SUBJECT_TEXT': (str, 'Monitoring', 'PlexPy ({server_name})'),
|
||||||
'NOTIFY_ON_START_BODY_TEXT': (str, 'Monitoring', '{user} ({player}) started playing {title}.'),
|
'NOTIFY_ON_START_BODY_TEXT': (str, 'Monitoring', '{user} ({player}) started playing {title}.'),
|
||||||
|
|
|
@ -439,6 +439,7 @@ class WebInterface(object):
|
||||||
"music_logging_enable": checked(plexpy.CONFIG.MUSIC_LOGGING_ENABLE),
|
"music_logging_enable": checked(plexpy.CONFIG.MUSIC_LOGGING_ENABLE),
|
||||||
"logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL,
|
"logging_ignore_interval": plexpy.CONFIG.LOGGING_IGNORE_INTERVAL,
|
||||||
"pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE),
|
"pms_is_remote": checked(plexpy.CONFIG.PMS_IS_REMOTE),
|
||||||
|
"notify_consecutive": checked(plexpy.CONFIG.NOTIFY_CONSECUTIVE),
|
||||||
"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_subject_text": plexpy.CONFIG.NOTIFY_ON_START_SUBJECT_TEXT,
|
||||||
"notify_on_start_body_text": plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT,
|
"notify_on_start_body_text": plexpy.CONFIG.NOTIFY_ON_START_BODY_TEXT,
|
||||||
|
@ -476,7 +477,7 @@ class WebInterface(object):
|
||||||
"tv_notify_on_stop", "movie_notify_on_stop", "music_notify_on_stop",
|
"tv_notify_on_stop", "movie_notify_on_stop", "music_notify_on_stop",
|
||||||
"tv_notify_on_pause", "movie_notify_on_pause", "music_notify_on_pause", "refresh_users_on_startup",
|
"tv_notify_on_pause", "movie_notify_on_pause", "music_notify_on_pause", "refresh_users_on_startup",
|
||||||
"ip_logging_enable", "video_logging_enable", "music_logging_enable", "pms_is_remote", "home_stats_type",
|
"ip_logging_enable", "video_logging_enable", "music_logging_enable", "pms_is_remote", "home_stats_type",
|
||||||
"group_history_tables"
|
"group_history_tables", "notify_consecutive"
|
||||||
]
|
]
|
||||||
for checked_config in checked_configs:
|
for checked_config in checked_configs:
|
||||||
if checked_config not in kwargs:
|
if checked_config not in kwargs:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue