mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
Merge pull request #515 from venomousZealot/patch-1
Allow multiple subtitles with identical names
This commit is contained in:
commit
aad222b603
1 changed files with 14 additions and 16 deletions
|
@ -5,7 +5,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
import collections
|
|
||||||
|
|
||||||
from kodi_six import xbmc, xbmcvfs
|
from kodi_six import xbmc, xbmcvfs
|
||||||
|
|
||||||
|
@ -566,8 +565,8 @@ class PlayUtils(object):
|
||||||
IsTextSubtitleStream if true, is available to download from server.
|
IsTextSubtitleStream if true, is available to download from server.
|
||||||
'''
|
'''
|
||||||
prefs = ""
|
prefs = ""
|
||||||
audio_streams = collections.OrderedDict()
|
audio_streams = list()
|
||||||
subs_streams = collections.OrderedDict()
|
subs_streams = list()
|
||||||
streams = source['MediaStreams']
|
streams = source['MediaStreams']
|
||||||
|
|
||||||
server_settings = self.api_client.get_transcode_settings()
|
server_settings = self.api_client.get_transcode_settings()
|
||||||
|
@ -580,9 +579,7 @@ class PlayUtils(object):
|
||||||
|
|
||||||
if stream_type == 'Audio':
|
if stream_type == 'Audio':
|
||||||
|
|
||||||
track = stream['DisplayTitle']
|
audio_streams.append(index)
|
||||||
|
|
||||||
audio_streams[track] = index
|
|
||||||
|
|
||||||
elif stream_type == 'Subtitle':
|
elif stream_type == 'Subtitle':
|
||||||
if stream['IsExternal']:
|
if stream['IsExternal']:
|
||||||
|
@ -593,24 +590,25 @@ class PlayUtils(object):
|
||||||
if not avail_for_extraction and not allow_burned_subs:
|
if not avail_for_extraction and not allow_burned_subs:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
track = stream['DisplayTitle']
|
subs_streams.append(index)
|
||||||
|
|
||||||
subs_streams[track] = index
|
|
||||||
|
|
||||||
skip_dialog = int(settings('skipDialogTranscode') or 0)
|
skip_dialog = int(settings('skipDialogTranscode') or 0)
|
||||||
audio_selected = None
|
audio_selected = None
|
||||||
|
|
||||||
|
def get_track_title(track_index):
|
||||||
|
return streams[track_index]['DisplayTitle'] or ("Track %s" % track_index)
|
||||||
|
|
||||||
if audio:
|
if audio:
|
||||||
audio_selected = audio
|
audio_selected = audio
|
||||||
|
|
||||||
elif skip_dialog in (0, 1):
|
elif skip_dialog in (0, 1):
|
||||||
if len(audio_streams) > 1:
|
if len(audio_streams) > 1:
|
||||||
|
|
||||||
selection = list(audio_streams.keys())
|
selection = list(map(get_track_title, audio_streams))
|
||||||
resp = dialog("select", translate(33013), selection)
|
resp = dialog("select", translate(33013), selection)
|
||||||
audio_selected = audio_streams[selection[resp]] if resp > -1 else source['DefaultAudioStreamIndex']
|
audio_selected = audio_streams[resp] if resp > -1 else source['DefaultAudioStreamIndex']
|
||||||
else: # Only one choice
|
elif len(audio_streams) > 0: # Only one choice
|
||||||
audio_selected = audio_streams[next(iter(audio_streams))]
|
audio_selected = audio_streams[0]
|
||||||
else:
|
else:
|
||||||
audio_selected = source['DefaultAudioStreamIndex']
|
audio_selected = source['DefaultAudioStreamIndex']
|
||||||
|
|
||||||
|
@ -632,11 +630,11 @@ class PlayUtils(object):
|
||||||
|
|
||||||
elif skip_dialog in (0, 2) and len(subs_streams):
|
elif skip_dialog in (0, 2) and len(subs_streams):
|
||||||
|
|
||||||
selection = list(['No subtitles']) + list(subs_streams.keys())
|
selection = list(['No subtitles']) + list(map(get_track_title, subs_streams))
|
||||||
resp = dialog("select", translate(33014), selection)
|
resp = dialog("select", translate(33014), selection) - 1
|
||||||
|
|
||||||
if resp:
|
if resp:
|
||||||
index = subs_streams[selection[resp]] if resp > -1 else source.get('DefaultSubtitleStreamIndex')
|
index = subs_streams[resp] if resp > -1 else source.get('DefaultSubtitleStreamIndex')
|
||||||
|
|
||||||
if index is not None:
|
if index is not None:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue