mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-10-09 10:22:05 +00:00
playutils: Fix streams indexes
Signed-off-by: Michal Chvíla <michal@chvila.sk>
This commit is contained in:
parent
c43f09e502
commit
aa22e9cea0
1 changed files with 36 additions and 34 deletions
|
@ -605,21 +605,21 @@ 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 = list()
|
audio_stream_indexes = list()
|
||||||
subs_streams = list()
|
subs_stream_indexes = list()
|
||||||
streams = source["MediaStreams"]
|
streams = dict()
|
||||||
|
|
||||||
server_settings = self.api_client.get_transcode_settings()
|
server_settings = self.api_client.get_transcode_settings()
|
||||||
allow_burned_subs = settings("allowBurnedSubs.bool")
|
allow_burned_subs = settings("allowBurnedSubs.bool")
|
||||||
|
|
||||||
for stream in streams:
|
for stream in source["MediaStreams"]:
|
||||||
|
|
||||||
index = stream["Index"]
|
index = stream["Index"]
|
||||||
stream_type = stream["Type"]
|
stream_type = stream["Type"]
|
||||||
|
|
||||||
if stream_type == "Audio":
|
streams[index] = stream
|
||||||
|
|
||||||
audio_streams.append(index)
|
if stream_type == "Audio":
|
||||||
|
audio_stream_indexes.append(index)
|
||||||
|
|
||||||
elif stream_type == "Subtitle":
|
elif stream_type == "Subtitle":
|
||||||
if stream["IsExternal"]:
|
if stream["IsExternal"]:
|
||||||
|
@ -633,7 +633,7 @@ 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
|
||||||
|
|
||||||
subs_streams.append(index)
|
subs_stream_indexes.append(index)
|
||||||
|
|
||||||
skip_dialog = int(settings("skipDialogTranscode") or 0)
|
skip_dialog = int(settings("skipDialogTranscode") or 0)
|
||||||
|
|
||||||
|
@ -641,54 +641,54 @@ class PlayUtils(object):
|
||||||
return streams[track_index]["DisplayTitle"] or ("Track %s" % track_index)
|
return streams[track_index]["DisplayTitle"] or ("Track %s" % track_index)
|
||||||
|
|
||||||
# Select audio stream
|
# Select audio stream
|
||||||
audio_selected = None
|
audio_selected_index = None
|
||||||
|
|
||||||
if skip_dialog == Transcode.MediaDefault:
|
if skip_dialog == Transcode.MediaDefault:
|
||||||
# NOTE: "DefaultAudioStreamIndex" is the default according to Jellyfin.
|
# NOTE: "DefaultAudioStreamIndex" is the default according to Jellyfin.
|
||||||
# The media's default is marked by the "IsDefault" value.
|
# The media's default is marked by the "IsDefault" value.
|
||||||
for track_index in audio_streams:
|
for track_index in audio_stream_indexes:
|
||||||
if streams[track_index]["IsDefault"]:
|
if streams[track_index]["IsDefault"]:
|
||||||
audio = track_index
|
audio = track_index
|
||||||
break
|
break
|
||||||
|
|
||||||
# Compare to None in the off-chance the track index is 0.
|
# Compare to None in the off-chance the track index is 0.
|
||||||
if audio is not None:
|
if audio is not None:
|
||||||
audio_selected = audio
|
audio_selected_index = audio
|
||||||
|
|
||||||
elif skip_dialog in (Transcode.Enabled, Transcode.Audio):
|
elif skip_dialog in (Transcode.Enabled, Transcode.Audio):
|
||||||
if len(audio_streams) > 1:
|
if len(audio_stream_indexes) > 1:
|
||||||
selection = list(map(get_track_title, audio_streams))
|
selection = list(map(get_track_title, audio_stream_indexes))
|
||||||
resp = dialog("select", translate(33013), selection)
|
resp = dialog("select", translate(33013), selection)
|
||||||
if resp > -1:
|
if resp > -1:
|
||||||
audio_selected = audio_streams[resp]
|
audio_selected_index = audio_stream_indexes[resp]
|
||||||
else:
|
else:
|
||||||
audio_selected = source["DefaultAudioStreamIndex"]
|
audio_selected_index = source["DefaultAudioStreamIndex"]
|
||||||
elif audio_streams:
|
elif audio_stream_indexes:
|
||||||
# Only one choice
|
# Only one choice
|
||||||
audio_selected = audio_streams[0]
|
audio_selected_index = audio_stream_indexes[0]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
audio_selected = source["DefaultAudioStreamIndex"]
|
audio_selected_index = source["DefaultAudioStreamIndex"]
|
||||||
|
|
||||||
if audio_selected is not None:
|
if audio_selected_index is not None:
|
||||||
self.info["AudioStreamIndex"] = audio_selected
|
self.info["AudioStreamIndex"] = audio_selected_index
|
||||||
prefs += "&AudioStreamIndex=%s" % audio_selected
|
prefs += "&AudioStreamIndex=%s" % audio_selected_index
|
||||||
|
|
||||||
# Select audio stream
|
# Select audio stream
|
||||||
subtitle_selected = None
|
subtitle_selected_index = None
|
||||||
|
|
||||||
if skip_dialog == Transcode.MediaDefault:
|
if skip_dialog == Transcode.MediaDefault:
|
||||||
for track_index in subs_streams:
|
for track_index in subs_stream_indexes:
|
||||||
if streams[track_index]["IsDefault"]:
|
if streams[track_index]["IsDefault"]:
|
||||||
subtitle = track_index
|
subtitle = track_index
|
||||||
break
|
break
|
||||||
|
|
||||||
if subtitle is not None:
|
if subtitle is not None:
|
||||||
subtitle_selected = subtitle
|
subtitle_selected_index = subtitle
|
||||||
|
|
||||||
elif skip_dialog in (Transcode.Enabled, Transcode.Subtitle) and subs_streams:
|
elif skip_dialog in (Transcode.Enabled, Transcode.Subtitle) and subs_stream_indexes:
|
||||||
selection = list(["No subtitles"]) + list(
|
selection = list(["No subtitles"]) + list(
|
||||||
map(get_track_title, subs_streams)
|
map(get_track_title, subs_stream_indexes)
|
||||||
)
|
)
|
||||||
resp = dialog("select", translate(33014), selection) - 1
|
resp = dialog("select", translate(33014), selection) - 1
|
||||||
# Possible responses:
|
# Possible responses:
|
||||||
|
@ -696,23 +696,25 @@ class PlayUtils(object):
|
||||||
# -1 No subtitles (Default)
|
# -1 No subtitles (Default)
|
||||||
# -2 Dialog was cancelled
|
# -2 Dialog was cancelled
|
||||||
if resp > -1:
|
if resp > -1:
|
||||||
track_index = subs_streams[resp]
|
subtitle_selected_index = subs_stream_indexes[resp]
|
||||||
subtitle_selected = track_index
|
|
||||||
|
|
||||||
if subtitle_selected is not None:
|
if subtitle_selected_index is not None:
|
||||||
server_settings = self.api_client.get_transcode_settings()
|
server_settings = self.api_client.get_transcode_settings()
|
||||||
stream = streams[track_index]
|
stream = streams[subtitle_selected_index]
|
||||||
if (
|
if (
|
||||||
server_settings["EnableSubtitleExtraction"]
|
server_settings["EnableSubtitleExtraction"]
|
||||||
and stream["SupportsExternalStream"]
|
and stream["SupportsExternalStream"]
|
||||||
):
|
):
|
||||||
self.info["SubtitleUrl"] = self.get_subtitles(
|
self.info["SubtitleUrl"] = self.get_subtitles(
|
||||||
source, stream, subtitle_selected
|
source, stream, subtitle_selected_index
|
||||||
)
|
)
|
||||||
self.info["SubtitleStreamIndex"] = subtitle_selected
|
self.info["SubtitleStreamIndex"] = subtitle_selected_index
|
||||||
elif allow_burned_subs:
|
elif allow_burned_subs:
|
||||||
prefs += "&SubtitleStreamIndex=%s" % subtitle_selected
|
prefs += "&SubtitleStreamIndex=%s" % subtitle_selected_index
|
||||||
self.info["SubtitleStreamIndex"] = subtitle_selected
|
self.info["SubtitleStreamIndex"] = subtitle_selected_index
|
||||||
|
|
||||||
|
prefs += "&SubtitleMethod=Encode"
|
||||||
|
self.info["SubtitleMethod"] = "Encode"
|
||||||
|
|
||||||
return prefs
|
return prefs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue