1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 00:02:13 +00:00

ytdl_hook: Support playlist entries without subtitles

Fixes missing subtitle tracks if the first entry didn't have any.

Previously it just checked for the first entry in the playlist for
requested languages and if that entry happened to not have subtitles
they also wouldn't show up for the other entries.

It will skip languages if the first entry with subs has less or
different languages than the others.

Unrelated to http_dash_segments.
This commit is contained in:
Ricardo Constantino 2016-09-11 15:58:05 +01:00 committed by wm4
parent 0e72f64ff4
commit 5edd6a8caa

View File

@ -180,11 +180,25 @@ mp.add_hook("on_load", 10, function ()
json.title)
end
if not (json.entries[1].requested_subtitles == nil) then
for j, req in pairs(json.entries[1].requested_subtitles) do
-- there might not be subs for the first segment
local entry_wsubs = nil
for i, entry in pairs(json.entries) do
if not (entry.requested_subtitles == nil) then
entry_wsubs = i
break
end
end
if not (entry_wsubs == nil) then
for j, req in pairs(json.entries[entry_wsubs].requested_subtitles) do
local subfile = "edl://"
for i, entry in pairs(json.entries) do
subfile = subfile..edl_escape(entry.requested_subtitles[j].url)
if not (entry.requested_subtitles == nil) and
not (entry.requested_subtitles[j] == nil) then
subfile = subfile..edl_escape(entry.requested_subtitles[j].url)
else
subfile = subfile..edl_escape("memory://WEBVTT")
end
if not (entry.duration == nil) then
subfile = subfile..",start=0,length="..entry.duration
end