From 04da3572cbaf6cfbb1aac56ce67f9ad8f8aa1f01 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 19 Jan 2019 09:22:00 +0100 Subject: [PATCH] Fix rare KeyError if user is playing something somewhere else --- resources/lib/library_sync/websocket.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resources/lib/library_sync/websocket.py b/resources/lib/library_sync/websocket.py index 06f344e1..17c53425 100644 --- a/resources/lib/library_sync/websocket.py +++ b/resources/lib/library_sync/websocket.py @@ -270,13 +270,14 @@ def process_playing(data): PLAYSTATE_SESSIONS[session_key] = {} else: # PMS is ours - get all current sessions - PLAYSTATE_SESSIONS.update(PF.GetPMSStatus(app.ACCOUNT.plex_token)) - LOG.debug('Updated current sessions. They are: %s', - PLAYSTATE_SESSIONS) - if session_key not in PLAYSTATE_SESSIONS: + pms_sessions = PF.GetPMSStatus(app.ACCOUNT.plex_token) + if session_key not in pms_sessions: LOG.info('Session key %s still unknown! Skip ' 'playstate update', session_key) continue + PLAYSTATE_SESSIONS[session_key] = pms_sessions[session_key] + LOG.debug('Updated current sessions. They are: %s', + PLAYSTATE_SESSIONS) # Attach Kodi info to the session PLAYSTATE_SESSIONS[session_key]['kodi_id'] = typus['kodi_id'] PLAYSTATE_SESSIONS[session_key]['file_id'] = typus['kodi_fileid']