From a2c2649bc9cad2ea0b91d07d1374b2422c4abb27 Mon Sep 17 00:00:00 2001 From: croneter Date: Tue, 6 Feb 2018 07:43:22 +0100 Subject: [PATCH] Fix TypeError for trailers You need to resync the Kodi database --- resources/lib/PlexAPI.py | 29 +++++++++++------------------ resources/lib/itemtypes.py | 2 +- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index a10d59e0..01ca1714 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -1729,7 +1729,7 @@ class API(): 5: Behind the scenes Output: list of dicts with one entry of the form: - 'key': e.g. /library/metadata/xxxx + 'ratingKey': e.g. '12345' 'title': 'thumb': artwork 'duration': @@ -1744,27 +1744,20 @@ class API(): for extra in extras: try: extraType = int(extra.attrib['extraType']) - except: + except (KeyError, TypeError): extraType = None if extraType != 1: continue - key = extra.attrib.get('key', None) - title = extra.attrib.get('title', None) - thumb = extra.attrib.get('thumb', None) duration = float(extra.attrib.get('duration', 0.0)) - year = extra.attrib.get('year', None) - originallyAvailableAt = extra.attrib.get( - 'originallyAvailableAt', None) - elements.append( - { - 'key': key, - 'title': title, - 'thumb': thumb, - 'duration': int(duration * v.PLEX_TO_KODI_TIMEFACTOR), - 'extraType': extraType, - 'originallyAvailableAt': originallyAvailableAt, - 'year': year - }) + elements.append({ + 'ratingKey': extra.attrib.get('ratingKey'), + 'title': extra.attrib.get('title'), + 'thumb': extra.attrib.get('thumb'), + 'duration': int(duration * v.PLEX_TO_KODI_TIMEFACTOR), + 'extraType': extraType, + 'originallyAvailableAt': extra.attrib.get('originallyAvailableAt'), + 'year': extra.attrib.get('year') + }) break return elements diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index d1a73f72..3ca61e2a 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -256,7 +256,7 @@ class Movies(Items): if extra['extraType'] == 1: trailer = ("plugin://plugin.video.plexkodiconnect?" "plex_id=%s&plex_type=%s&mode=play" - % (extra['key'], v.PLEX_TYPE_CLIP)) + % (extra['ratingKey'], v.PLEX_TYPE_CLIP)) break # GET THE FILE AND PATH #####