Cleanup stream selection

This commit is contained in:
tomkat83 2017-04-02 20:10:10 +02:00
parent 946254d86c
commit b0fe3cba24

View file

@ -30,7 +30,6 @@ http://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-put-in-pyt
(and others...) (and others...)
""" """
import os
import logging import logging
from time import time from time import time
import urllib2 import urllib2
@ -40,6 +39,7 @@ import xml.etree.ElementTree as etree
from re import compile as re_compile, sub from re import compile as re_compile, sub
from json import dumps from json import dumps
from urllib import urlencode, quote_plus, unquote from urllib import urlencode, quote_plus, unquote
from os import path as os_path
import xbmcgui import xbmcgui
from xbmc import sleep, executebuiltin from xbmc import sleep, executebuiltin
@ -2187,32 +2187,38 @@ class API():
# Several streams/files available. # Several streams/files available.
dialoglist = [] dialoglist = []
for entry in self.item.findall('./Media'): for entry in self.item.findall('./Media'):
fileName = ''
audioLanguage = ''
# Get additional info (filename / languages) # Get additional info (filename / languages)
mediaPartEntry = self.item.find('./Media/Part') filename = None
if mediaPartEntry is not None: if 'file' in entry[0].attrib:
# Filename filename = os_path.basename(entry[0].attrib['file'])
if 'file' in mediaPartEntry.attrib: # Languages of audio streams
fileName = os.path.basename(mediaPartEntry.attrib['file']) languages = []
for stream in entry[0]:
# Languages - subtitle does not seem to be directly included in this stream info if (stream.attrib['streamType'] == '1' and
mediaPartStreamEntry = self.item.find('./Media/Part/Stream') 'language' in stream.attrib):
if mediaPartStreamEntry is not None: languages.append(stream.attrib['language'])
# Audio language languages = ', '.join(languages)
if 'language' in mediaPartStreamEntry.attrib: if filename:
audioLanguage = mediaPartStreamEntry.attrib['language'] option = tryEncode(filename)
if languages:
dialoglist.append( if option:
"%sp %s - %s (%s) (%s) %s" % option = '%s (%s): ' % (option, tryEncode(languages))
(entry.attrib.get('videoResolution', 'unknown'), else:
entry.attrib.get('videoCodec', 'unknown'), option = '%s: ' % tryEncode(languages)
entry.attrib.get('audioProfile', 'unknown'), if 'videoResolution' in entry.attrib:
entry.attrib.get('audioCodec', 'unknown'), option = '%s%sp ' % (option,
audioLanguage, entry.attrib.get('videoResolution'))
fileName) if 'videoCodec' in entry.attrib:
) option = '%s%s' % (option,
entry.attrib.get('videoCodec'))
option = option.strip() + ' - '
if 'audioProfile' in entry.attrib:
option = '%s%s ' % (option,
entry.attrib.get('audioProfile'))
if 'audioCodec' in entry.attrib:
option = '%s%s ' % (option,
entry.attrib.get('audioCodec'))
dialoglist.append(option)
media = xbmcgui.Dialog().select('Select stream', dialoglist) media = xbmcgui.Dialog().select('Select stream', dialoglist)
else: else:
media = 0 media = 0