Fix KeyErrors if Kodi player does not return position

- Partially fixes #481
This commit is contained in:
Croneter 2018-06-01 18:43:56 +02:00
parent 7bf6d19708
commit a6881a8a32
2 changed files with 9 additions and 2 deletions

View file

@ -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):
"""

View file

@ -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)