From 14fc33442285adb4b8bc661c9b7b04a589ad1354 Mon Sep 17 00:00:00 2001 From: croneter Date: Wed, 13 Sep 2017 15:41:06 +0200 Subject: [PATCH] Fix IndexError e.g. for channels if stream info missing --- resources/lib/PlexAPI.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index c7bf53b4..8de6fbcf 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -1754,8 +1754,16 @@ class API(): videotracks = [] audiotracks = [] subtitlelanguages = [] - # Sometimes, aspectratio is on the "toplevel" - aspectratio = self.item[0].attrib.get('aspectRatio', None) + try: + # Sometimes, aspectratio is on the "toplevel" + aspectratio = self.item[0].attrib.get('aspectRatio', None) + except IndexError: + # There is no stream info at all, returning empty + return { + 'video': videotracks, + 'audio': audiotracks, + 'subtitle': subtitlelanguages + } # TODO: what if several Media tags exist?!? # Loop over parts for child in self.item[0]: