From 4ff2a606322494f060b90a982cbe2342738db665 Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Sun, 22 May 2016 22:18:27 +0100 Subject: ytdl_hook: support multi-arc subtitles While at it, pass durations of segments from ytdl if available. --- player/lua/ytdl_hook.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index 97ce02dab8..fb59aa3301 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -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" -- cgit v1.2.3