mirror of
https://github.com/mpv-player/mpv
synced 2025-01-18 13:14:36 +00:00
ytdl_hook: support multi-arc subtitles
While at it, pass durations of segments from ytdl if available.
This commit is contained in:
parent
4aa017e301
commit
4ff2a60632
@ -159,7 +159,11 @@ mp.add_hook("on_load", 10, function ()
|
||||
|
||||
local playlist = "edl://"
|
||||
for i, entry in pairs(json.entries) do
|
||||
playlist = playlist .. edl_escape(entry.url) .. ";"
|
||||
playlist = playlist .. edl_escape(entry.url)
|
||||
if not (entry.duration == nil) then
|
||||
playlist = playlist..",start=0,length="..entry.duration
|
||||
end
|
||||
playlist = playlist .. ";"
|
||||
end
|
||||
|
||||
msg.debug("EDL: " .. playlist)
|
||||
@ -175,6 +179,21 @@ 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
|
||||
local subfile = "edl://"
|
||||
for i, entry in pairs(json.entries) do
|
||||
subfile = subfile..edl_escape(entry.requested_subtitles[j].url)
|
||||
if not (entry.duration == nil) then
|
||||
subfile = subfile..",start=0,length="..entry.duration
|
||||
end
|
||||
subfile = subfile .. ";"
|
||||
end
|
||||
msg.debug(j.." sub EDL: "..subfile)
|
||||
mp.commandv("sub-add", subfile, "auto", req.ext, j)
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
local playlist = "#EXTM3U\n"
|
||||
|
Loading…
Reference in New Issue
Block a user