mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 15:32:38 -07:00
Store websocket rating key to compare against when mismatched with sessions XML (Fixes Tautulli/Tautulli-Issues#174)
This commit is contained in:
parent
9b42bb240a
commit
eae842b09a
3 changed files with 15 additions and 1 deletions
|
@ -1156,6 +1156,15 @@ def dbcheck():
|
|||
'ALTER TABLE sessions ADD COLUMN relayed INTEGER'
|
||||
)
|
||||
|
||||
# Upgrade sessions table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT rating_key_websocket FROM sessions')
|
||||
except sqlite3.OperationalError:
|
||||
logger.debug(u"Altering database. Updating database table sessions.")
|
||||
c_db.execute(
|
||||
'ALTER TABLE sessions ADD COLUMN rating_key_websocket TEXT'
|
||||
)
|
||||
|
||||
# Upgrade session_history table from earlier versions
|
||||
try:
|
||||
c_db.execute('SELECT reference_id FROM session_history')
|
||||
|
|
|
@ -69,6 +69,7 @@ class ActivityHandler(object):
|
|||
# Get it from the websocket data
|
||||
if not session['rating_key']:
|
||||
session['rating_key'] = self.get_rating_key()
|
||||
session['rating_key_websocket'] = self.get_rating_key()
|
||||
return session
|
||||
|
||||
return None
|
||||
|
@ -267,9 +268,12 @@ class ActivityHandler(object):
|
|||
last_live_uuid = db_session['live_uuid']
|
||||
last_transcode_key = db_session['transcode_key'].split('/')[-1]
|
||||
last_paused = db_session['last_paused']
|
||||
last_rating_key_websocket = db_session['rating_key_websocket']
|
||||
|
||||
# Make sure the same item is being played
|
||||
if this_rating_key == last_rating_key or this_live_uuid == last_live_uuid:
|
||||
if this_rating_key == last_rating_key \
|
||||
or this_rating_key == last_rating_key_websocket \
|
||||
or this_live_uuid == last_live_uuid:
|
||||
# Update the session state and viewOffset
|
||||
if this_state == 'playing':
|
||||
# Update the session in our temp session table
|
||||
|
|
|
@ -117,6 +117,7 @@ class ActivityProcessor(object):
|
|||
'live_uuid': session.get('live_uuid', ''),
|
||||
'secure': session.get('secure', None),
|
||||
'relayed': session.get('relayed', 0),
|
||||
'rating_key_websocket': session.get('rating_key_websocket', ''),
|
||||
'raw_stream_info': json.dumps(session),
|
||||
'stopped': int(time.time())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue