From c049e8d05e95dae321f92a75d9af12cf6a339ac0 Mon Sep 17 00:00:00 2001 From: RickDB Date: Sun, 2 Apr 2017 14:11:13 +0200 Subject: [PATCH] Included additional info in stream selection dialog --- resources/lib/PlexAPI.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index a324f2e2..fec9e228 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -30,6 +30,7 @@ http://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-pyt (and others...) """ +import os import logging from time import time import urllib2 @@ -2186,12 +2187,31 @@ class API(): # Several streams/files available. dialoglist = [] for entry in self.item.findall('./Media'): + fileName = '' + audioLanguage = '' + + # Get additional info (filename / languages) + mediaPartEntry = self.item.find('./Media/Part') + if mediaPartEntry is not None: + # Filename + if 'file' in mediaPartEntry.attrib: + fileName = os.path.basename(mediaPartEntry.attrib['file']) + + # Languages - subtitle does not seem to be directly included in this stream info + mediaPartStreamEntry = self.item.find('./Media/Part/Stream') + if mediaPartStreamEntry is not None: + # Audio language + if 'language' in mediaPartStreamEntry.attrib: + audioLanguage = mediaPartStreamEntry.attrib['language'] + dialoglist.append( - "%sp %s - %s (%s)" - % (entry.attrib.get('videoResolution', 'unknown'), - entry.attrib.get('videoCodec', 'unknown'), - entry.attrib.get('audioProfile', 'unknown'), - entry.attrib.get('audioCodec', 'unknown')) + "%sp %s - %s (%s) (%s) %s" % + (entry.attrib.get('videoResolution', 'unknown'), + entry.attrib.get('videoCodec', 'unknown'), + entry.attrib.get('audioProfile', 'unknown'), + entry.attrib.get('audioCodec', 'unknown'), + audioLanguage, + fileName) ) media = xbmcgui.Dialog().select('Select stream', dialoglist) else: