From a6881a8a327c21fb48e0cad990afcc2c7146b971 Mon Sep 17 00:00:00 2001 From: Croneter Date: Fri, 1 Jun 2018 18:43:56 +0200 Subject: [PATCH] Fix KeyErrors if Kodi player does not return position - Partially fixes #481 --- resources/lib/PlexCompanion.py | 5 ++++- resources/lib/playback.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/lib/PlexCompanion.py b/resources/lib/PlexCompanion.py index 0f9162fb..89d5a7a9 100644 --- a/resources/lib/PlexCompanion.py +++ b/resources/lib/PlexCompanion.py @@ -195,7 +195,10 @@ class PlexCompanion(Thread): elif task['action'] == 'refreshPlayQueue': self._process_refresh(data) elif task['action'] == 'setStreams': - self._process_streams(data) + try: + self._process_streams(data) + except KeyError: + pass def run(self): """ diff --git a/resources/lib/playback.py b/resources/lib/playback.py index 57f2377f..ea54923e 100644 --- a/resources/lib/playback.py +++ b/resources/lib/playback.py @@ -62,7 +62,11 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True): return playqueue = PQ.get_playqueue_from_type( v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[plex_type]) - pos = js.get_position(playqueue.playlistid) + try: + pos = js.get_position(playqueue.playlistid) + except KeyError: + LOG.warning('No position returned from Kodi player! Assuming 0') + pos = 0 # Can return -1 (as in "no playlist") pos = pos if pos != -1 else 0 LOG.debug('playQueue position %s for %s', pos, playqueue)