From 436d2e4391a39f574e385ffec9a23201af42f97f Mon Sep 17 00:00:00 2001 From: croneter Date: Thu, 30 Sep 2021 14:17:52 +0200 Subject: [PATCH] Direct Paths: Fix TypeError: element indices must be integers for subtitles --- resources/lib/plex_api/base.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/lib/plex_api/base.py b/resources/lib/plex_api/base.py index 183166a9..f73a1db5 100644 --- a/resources/lib/plex_api/base.py +++ b/resources/lib/plex_api/base.py @@ -254,13 +254,21 @@ class Base(object): Returns the media streams directly from the PMS xml. Mind to set self.mediastream and self.part before calling this method! """ - return self.xml[self.mediastream][self.part] + try: + return self.xml[self.mediastream][self.part] + except TypeError: + # Direct Paths when we don't set mediastream and part + return self.xml[0][0] def part_id(self): """ Returns the unique id of the currently active part [int] """ - return int(self.xml[self.mediastream][self.part].attrib['id']) + try: + return int(self.xml[self.mediastream][self.part].attrib['id']) + except TypeError: + # Direct Paths when we don't set mediastream and part + return int(self.xml[0][0].attrib['id']) def plot(self): """