From 4d17a9747ff68564a2c4a92447fc9d307bae3ce3 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 13 Jan 2019 17:57:48 +0100 Subject: [PATCH] Fix KeyError due to malformed PMS messages - Fixes #604 --- resources/lib/library_sync/websocket.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/lib/library_sync/websocket.py b/resources/lib/library_sync/websocket.py index 6b6b6dcd..06f344e1 100644 --- a/resources/lib/library_sync/websocket.py +++ b/resources/lib/library_sync/websocket.py @@ -154,7 +154,12 @@ def store_timeline_message(data): # (DVR ratingKeys are not unique and might correspond to a # movie or episode) continue - typus = v.PLEX_TYPE_FROM_WEBSOCKET[int(message['type'])] + try: + typus = v.PLEX_TYPE_FROM_WEBSOCKET[int(message['type'])] + except KeyError: + # E.g. -1 - thanks Plex! + LOG.info('Ignoring invalid message %s', data) + continue if typus in (v.PLEX_TYPE_CLIP, v.PLEX_TYPE_SET): # No need to process extras or trailers continue