From 60b90b1f52e2735475c1062829904b13931894db Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 23 Feb 2018 15:24:26 +0100 Subject: [PATCH] Fix Companion displaying and selecting wrong subtitle --- resources/lib/playlist_func.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index b02e8d75..ac73cbd9 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -190,8 +190,16 @@ class Playlist_Item(object): """ stream_type = v.PLEX_STREAM_TYPE_FROM_STREAM_TYPE[stream_type] count = 0 + # Kodi indexes differently than Plex for stream in self.xml[0][self.part]: - if stream.attrib['streamType'] == stream_type: + if (stream.attrib['streamType'] == stream_type and + 'key' in stream.attrib): + if count == kodi_stream_index: + return stream.attrib['id'] + count += 1 + for stream in self.xml[0][self.part]: + if (stream.attrib['streamType'] == stream_type and + 'key' not in stream.attrib): if count == kodi_stream_index: return stream.attrib['id'] count += 1 @@ -208,7 +216,14 @@ class Playlist_Item(object): stream_type = v.PLEX_STREAM_TYPE_FROM_STREAM_TYPE[stream_type] count = 0 for stream in self.xml[0][self.part]: - if stream.attrib['streamType'] == stream_type: + if (stream.attrib['streamType'] == stream_type and + 'key' in stream.attrib): + if stream.attrib['id'] == plex_stream_index: + return count + count += 1 + for stream in self.xml[0][self.part]: + if (stream.attrib['streamType'] == stream_type and + 'key' not in stream.attrib): if stream.attrib['id'] == plex_stream_index: return count count += 1