Fix playback sometimes not starting up

- Fixes #492 UnboundLocalError
This commit is contained in:
Croneter 2018-07-04 09:08:39 +02:00
parent 768de346b1
commit 4f461ed02b

View file

@ -1228,46 +1228,49 @@ class API(object):
for entry in self.item.iterfind('./Media'): for entry in self.item.iterfind('./Media'):
count += 1 count += 1
if (count > 1 and ( if (count > 1 and (
(self.plex_type() != 'clip' and (self.plex_type() != v.PLEX_TYPE_CLIP and
utils.settings('bestQuality') == 'false') utils.settings('bestQuality') == 'false')
or or
(self.plex_type() == 'clip' and (self.plex_type() == v.PLEX_TYPE_CLIP and
utils.settings('bestTrailer') == 'false'))): utils.settings('bestTrailer') == 'false'))):
# Several streams/files available. # Several streams/files available.
dialoglist = [] dialoglist = []
for entry in self.item.iterfind('./Media'): for entry in self.item.iterfind('./Media'):
# Get additional info (filename / languages) # Get additional info (filename / languages)
filename = None
if 'file' in entry[0].attrib: if 'file' in entry[0].attrib:
filename = path_ops.path.basename(entry[0].attrib['file']) option = utils.try_decode(entry[0].attrib['file'])
option = path_ops.path.basename(option)
else:
option = self.title() or ''
# Languages of audio streams # Languages of audio streams
languages = [] languages = []
for stream in entry[0]: for stream in entry[0]:
if (stream.attrib['streamType'] == '1' and if (stream.attrib['streamType'] == '1' and
'language' in stream.attrib): 'language' in stream.attrib):
languages.append(stream.attrib['language']) language = utils.try_decode(stream.attrib['language'])
languages.append(language)
languages = ', '.join(languages) languages = ', '.join(languages)
if filename:
option = utils.try_encode(filename)
if languages: if languages:
if option: if option:
option = '%s (%s): ' % (option, option = '%s (%s): ' % (option, languages)
utils.try_encode(languages))
else: else:
option = '%s: ' % utils.try_encode(languages) option = '%s: ' % languages
else:
option = '%s ' % option
if 'videoResolution' in entry.attrib: if 'videoResolution' in entry.attrib:
option = '%s%sp ' % (option, res = utils.try_decode(entry['videoResolution'])
entry.get('videoResolution')) option = '%s%sp ' % (option, res)
if 'videoCodec' in entry.attrib: if 'videoCodec' in entry.attrib:
option = '%s%s' % (option, codec = utils.try_decode(entry['videoCodec'])
entry.get('videoCodec')) option = '%s%s' % (option, codec)
option = option.strip() + ' - ' option = option.strip() + ' - '
if 'audioProfile' in entry.attrib: if 'audioProfile' in entry.attrib:
option = '%s%s ' % (option, profile = utils.try_decode(entry['audioProfile'])
entry.get('audioProfile')) option = '%s%s ' % (option, profile)
if 'audioCodec' in entry.attrib: if 'audioCodec' in entry.attrib:
option = '%s%s ' % (option, codec = utils.try_decode(entry['audioCodec'])
entry.get('audioCodec')) option = '%s%s ' % (option, codec)
option = utils.try_encode(option.strip())
dialoglist.append(option) dialoglist.append(option)
media = utils.dialog('select', 'Select stream', dialoglist) media = utils.dialog('select', 'Select stream', dialoglist)
else: else: