Address the repetitive notify/logging issue when multiple streams are active.

This commit is contained in:
Tim 2015-07-12 00:08:30 +02:00
parent 9152fa01af
commit d7c5046569

View file

@ -92,10 +92,12 @@ def check_active_sessions():
'transcode_height': result[37] 'transcode_height': result[37]
} }
if any(d['session_key'] == str(stream['session_key']) for d in media_container): if any(d['session_key'] == str(stream['session_key']) and d['rating_key'] == str(stream['rating_key'])
for d in media_container):
# 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['rating_key'] == str(stream['rating_key']): if session['session_key'] == str(stream['session_key']) and \
session['rating_key'] == str(stream['rating_key']):
# 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']:
@ -111,13 +113,6 @@ def check_active_sessions():
# Push any notifications # Push any notifications
notify(stream_data=stream, notify_action='stop') notify(stream_data=stream, notify_action='stop')
monitor_process.write_session_history(session=stream) monitor_process.write_session_history(session=stream)
else:
# The user's session is no longer active
logger.debug(u"Removing sessionKey %s from session queue" % stream['session_key'])
monitor_db.action('DELETE FROM sessions WHERE session_key = ?', [stream['session_key']])
# Push any notifications
notify(stream_data=stream, notify_action='stop')
monitor_process.write_session_history(session=stream)
# Process the newly received session data # Process the newly received session data
for session in media_container: for session in media_container: