mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 21:03:21 -07:00
Allow the buffer warnings to be completely disabled by setting buffer threshold to 0.
Fix bug with buffer warnings where notification would trigger continuously after first trigger. Fix bug where custom avatar URL would get reset on every user refresh.
This commit is contained in:
parent
699f481308
commit
ad79d860db
7 changed files with 54 additions and 25 deletions
|
@ -388,7 +388,7 @@ def dbcheck():
|
|||
'user_id INTEGER DEFAULT NULL UNIQUE, username TEXT NOT NULL UNIQUE, '
|
||||
'friendly_name TEXT, thumb TEXT, email TEXT, is_home_user INTEGER DEFAULT NULL, '
|
||||
'is_allow_sync INTEGER DEFAULT NULL, is_restricted INTEGER DEFAULT NULL, do_notify INTEGER DEFAULT 1, '
|
||||
'keep_history INTEGER DEFAULT 1)'
|
||||
'keep_history INTEGER DEFAULT 1, custom_avatar_url TEXT)'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
|
@ -534,29 +534,29 @@ def dbcheck():
|
|||
'on_pause INTEGER, on_resume INTEGER, on_buffer INTEGER)'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
# Upgrade users table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT do_notify from users')
|
||||
except sqlite3.OperationalError:
|
||||
logger.debug(u"Altering database. Updating database table sessions.")
|
||||
logger.debug(u"Altering database. Updating database table users.")
|
||||
c_db.execute(
|
||||
'ALTER TABLE users ADD COLUMN do_notify INTEGER DEFAULT 1'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
# Upgrade users table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT keep_history from users')
|
||||
except sqlite3.OperationalError:
|
||||
logger.debug(u"Altering database. Updating database table sessions.")
|
||||
logger.debug(u"Altering database. Updating database table users.")
|
||||
c_db.execute(
|
||||
'ALTER TABLE users ADD COLUMN keep_history INTEGER DEFAULT 1'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
# Upgrade notify_log table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT on_pause from notify_log')
|
||||
except sqlite3.OperationalError:
|
||||
logger.debug(u"Altering database. Updating database table sessions.")
|
||||
logger.debug(u"Altering database. Updating database table notify_log.")
|
||||
c_db.execute(
|
||||
'ALTER TABLE notify_log ADD COLUMN on_pause INTEGER'
|
||||
)
|
||||
|
@ -579,6 +579,15 @@ def dbcheck():
|
|||
'ALTER TABLE sessions ADD COLUMN buffer_last_triggered INTEGER'
|
||||
)
|
||||
|
||||
# Upgrade users table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT custom_avatar_url from users')
|
||||
except sqlite3.OperationalError:
|
||||
logger.debug(u"Altering database. Updating database table users.")
|
||||
c_db.execute(
|
||||
'ALTER TABLE users ADD COLUMN custom_avatar_url TEXT'
|
||||
)
|
||||
|
||||
conn_db.commit()
|
||||
c_db.close()
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class DataFactory(object):
|
|||
data_tables = datatables.DataTables()
|
||||
|
||||
columns = ['users.user_id as user_id',
|
||||
'users.thumb as thumb',
|
||||
'users.custom_avatar_url as thumb',
|
||||
'(case when users.friendly_name is null then users.username else \
|
||||
users.friendly_name end) as friendly_name',
|
||||
'MAX(session_history.started) as last_seen',
|
||||
|
@ -256,7 +256,7 @@ class DataFactory(object):
|
|||
monitor_db = database.MonitorDatabase()
|
||||
|
||||
control_value_dict = {"user_id": user_id}
|
||||
new_value_dict = {"thumb": profile_url}
|
||||
new_value_dict = {"custom_avatar_url": profile_url}
|
||||
try:
|
||||
monitor_db.upsert('users', new_value_dict, control_value_dict)
|
||||
except Exception, e:
|
||||
|
@ -268,7 +268,7 @@ class DataFactory(object):
|
|||
monitor_db = database.MonitorDatabase()
|
||||
|
||||
control_value_dict = {"username": user}
|
||||
new_value_dict = {"thumb": profile_url}
|
||||
new_value_dict = {"custom_avatar_url": profile_url}
|
||||
try:
|
||||
monitor_db.upsert('users', new_value_dict, control_value_dict)
|
||||
except Exception, e:
|
||||
|
@ -279,7 +279,7 @@ class DataFactory(object):
|
|||
monitor_db = database.MonitorDatabase()
|
||||
query = 'select username, ' \
|
||||
'(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
|
||||
'do_notify, keep_history, thumb ' \
|
||||
'do_notify, keep_history, custom_avatar_url as thumb ' \
|
||||
'FROM users WHERE user_id = ?'
|
||||
result = monitor_db.select(query, args=[user_id])
|
||||
if result:
|
||||
|
@ -303,7 +303,7 @@ class DataFactory(object):
|
|||
monitor_db = database.MonitorDatabase()
|
||||
query = 'select user_id, ' \
|
||||
'(CASE WHEN friendly_name IS NULL THEN username ELSE friendly_name END),' \
|
||||
'do_notify, keep_history, thumb ' \
|
||||
'do_notify, keep_history, custom_avatar_url as thumb ' \
|
||||
'FROM users WHERE username = ?'
|
||||
result = monitor_db.select(query, args=[user])
|
||||
if result:
|
||||
|
@ -347,7 +347,7 @@ class DataFactory(object):
|
|||
|
||||
if user:
|
||||
query = 'SELECT user_id, username, friendly_name, email, ' \
|
||||
'thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'custom_avatar_url as thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'FROM users ' \
|
||||
'WHERE username = ? ' \
|
||||
'UNION ALL ' \
|
||||
|
@ -359,7 +359,7 @@ class DataFactory(object):
|
|||
result = monitor_db.select(query, args=[user, user])
|
||||
elif user_id:
|
||||
query = 'SELECT user_id, username, friendly_name, email, ' \
|
||||
'thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'custom_avatar_url as thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'FROM users ' \
|
||||
'WHERE user_id = ? ' \
|
||||
'UNION ALL ' \
|
||||
|
@ -402,7 +402,7 @@ class DataFactory(object):
|
|||
# Refresh users
|
||||
plextv.refresh_users()
|
||||
query = 'SELECT user_id, username, friendly_name, email, ' \
|
||||
'thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'custom_avatar_url as thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'FROM users ' \
|
||||
'WHERE username = ? ' \
|
||||
'UNION ALL ' \
|
||||
|
@ -416,7 +416,7 @@ class DataFactory(object):
|
|||
# Refresh users
|
||||
plextv.refresh_users()
|
||||
query = 'SELECT user_id, username, friendly_name, email, ' \
|
||||
'thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'custom_avatar_url as thumb, is_home_user, is_allow_sync, is_restricted, do_notify ' \
|
||||
'FROM users ' \
|
||||
'WHERE user_id = ? ' \
|
||||
'UNION ALL ' \
|
||||
|
@ -566,7 +566,7 @@ class DataFactory(object):
|
|||
'users.friendly_name end) as friendly_name,' \
|
||||
'COUNT(session_history.id) as total_plays, ' \
|
||||
'MAX(session_history.started) as last_watch, ' \
|
||||
'users.thumb, ' \
|
||||
'users.custom_avatar_url as thumb, ' \
|
||||
'users.user_id ' \
|
||||
'FROM session_history ' \
|
||||
'JOIN session_history_metadata ON session_history.id = session_history_metadata.id ' \
|
||||
|
|
|
@ -72,7 +72,7 @@ def check_active_sessions():
|
|||
monitor_db.action('UPDATE sessions SET paused_counter = ? '
|
||||
'WHERE session_key = ? AND rating_key = ?',
|
||||
[paused_counter, stream['session_key'], stream['rating_key']])
|
||||
if session['state'] == 'buffering':
|
||||
if session['state'] == 'buffering' and plexpy.CONFIG.BUFFER_THRESHOLD > 0:
|
||||
# The stream is buffering so we need to increment the buffer_count
|
||||
# We're going just increment on every monitor ping,
|
||||
# would be difficult to keep track otherwise
|
||||
|
@ -107,6 +107,12 @@ def check_active_sessions():
|
|||
plexpy.CONFIG.BUFFER_WAIT:
|
||||
logger.info(u"PlexPy Monitor :: User '%s' has triggered multiple buffer warnings."
|
||||
% stream['user'])
|
||||
# Set the buffer trigger time
|
||||
monitor_db.action('UPDATE sessions '
|
||||
'SET buffer_last_triggered = strftime("%s","now") '
|
||||
'WHERE session_key = ? AND rating_key = ?',
|
||||
[stream['session_key'], stream['rating_key']])
|
||||
|
||||
threading.Thread(target=notification_handler.notify,
|
||||
kwargs=dict(stream_data=stream, notify_action='buffer')).start()
|
||||
|
||||
|
|
|
@ -37,6 +37,15 @@ def refresh_users():
|
|||
"is_restricted": item['is_restricted']
|
||||
}
|
||||
|
||||
# Check if we've set a custom avatar if so don't overwrite it.
|
||||
avatar_urls = monitor_db.select('SELECT thumb, custom_avatar_url '
|
||||
'FROM users WHERE user_id = ?',
|
||||
[item['user_id']])
|
||||
|
||||
if not avatar_urls[0]['custom_avatar_url'] or \
|
||||
avatar_urls[0]['custom_avatar_url'] == avatar_urls[0]['thumb']:
|
||||
new_value_dict['custom_avatar_url'] = item['thumb']
|
||||
|
||||
monitor_db.upsert('users', new_value_dict, control_value_dict)
|
||||
|
||||
logger.info("Users list refreshed.")
|
||||
|
|
|
@ -186,6 +186,11 @@ class WebInterface(object):
|
|||
keep_history = kwargs.get('keep_history')
|
||||
else:
|
||||
keep_history = 0
|
||||
if 'thumb' in kwargs:
|
||||
custom_avatar = kwargs['thumb']
|
||||
else:
|
||||
custom_avatar = ''
|
||||
|
||||
if user_id:
|
||||
try:
|
||||
data_factory = datafactory.DataFactory()
|
||||
|
@ -194,7 +199,7 @@ class WebInterface(object):
|
|||
do_notify=do_notify,
|
||||
keep_history=keep_history)
|
||||
data_factory.set_user_profile_url(user_id=user_id,
|
||||
profile_url=kwargs['thumb'])
|
||||
profile_url=custom_avatar)
|
||||
|
||||
status_message = "Successfully updated user."
|
||||
return status_message
|
||||
|
@ -209,7 +214,7 @@ class WebInterface(object):
|
|||
do_notify=do_notify,
|
||||
keep_history=keep_history)
|
||||
data_factory.set_user_profile_url(user=user,
|
||||
profile_url=kwargs['thumb'])
|
||||
profile_url=custom_avatar)
|
||||
|
||||
status_message = "Successfully updated user."
|
||||
return status_message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue