Let subtitles have >1 type

Fixes #1627
This commit is contained in:
1hitsong 2024-01-11 21:16:58 -05:00 committed by Charles Ewert
parent 190f34edef
commit 765b36e322

View File

@ -250,7 +250,7 @@ function defaultSubtitleTrackFromVid(videoID) as integer
subtitles = sortSubtitles(meta.id, meta.json.MediaSources[0].MediaStreams) subtitles = sortSubtitles(meta.id, meta.json.MediaSources[0].MediaStreams)
selectedAudioLanguage = meta.json.MediaSources[0].MediaStreams[m.top.selectedAudioStreamIndex].Language ?? "" selectedAudioLanguage = meta.json.MediaSources[0].MediaStreams[m.top.selectedAudioStreamIndex].Language ?? ""
defaultTextSubs = defaultSubtitleTrack(subtitles["all"], selectedAudioLanguage, true) ' Find correct subtitle track (forced text) defaultTextSubs = defaultSubtitleTrack(subtitles["text"], selectedAudioLanguage, true) ' Find correct subtitle track (forced text)
if defaultTextSubs <> SubtitleSelection.none if defaultTextSubs <> SubtitleSelection.none
return defaultTextSubs return defaultTextSubs
end if end if
@ -494,26 +494,33 @@ function sortSubtitles(id as string, MediaStreams)
"IsExternal": stream.IsExternal, "IsExternal": stream.IsExternal,
"IsEncoded": stream.DeliveryMethod = "Encode" "IsEncoded": stream.DeliveryMethod = "Encode"
} }
if stream.isForced if stream.isForced
trackType = "forced" trackType = "forced"
else if stream.IsDefault else if stream.IsDefault
trackType = "default" trackType = "default"
else if stream.IsTextSubtitleStream
trackType = "text"
else else
trackType = "normal" trackType = "normal"
end if end if
if prefered_lang <> "" and prefered_lang = stream.Track.Language if prefered_lang <> "" and prefered_lang = stream.Track.Language
tracks[trackType].unshift(stream) tracks[trackType].unshift(stream)
if stream.IsTextSubtitleStream
tracks["text"].unshift(stream)
end if
else else
tracks[trackType].push(stream) tracks[trackType].push(stream)
if stream.IsTextSubtitleStream
tracks["text"].push(stream)
end if
end if end if
end if end if
end for end for
tracks["default"].append(tracks["normal"]) tracks["default"].append(tracks["normal"])
tracks["forced"].append(tracks["default"]) tracks["forced"].append(tracks["default"])
tracks["forced"].append(tracks["text"])
return { "all": tracks["forced"], "text": tracks["text"] } return { "all": tracks["forced"], "text": tracks["text"] }
end function end function