From 5edd6a8caa45a1e31db942c1dee8dc2835822804 Mon Sep 17 00:00:00 2001 From: Ricardo Constantino Date: Sun, 11 Sep 2016 15:58:05 +0100 Subject: 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. --- player/lua/ytdl_hook.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'player/lua/ytdl_hook.lua') diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index a637d4e1aa..c60c1bfe9a 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -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 -- cgit v1.2.3