summaryrefslogtreecommitdiffstats
path: root/player/lua/ytdl_hook.lua
diff options
context:
space:
mode:
authorRicardo Constantino <wiiaboo@gmail.com>2016-09-11 15:58:05 +0100
committerwm4 <wm4@nowhere>2016-09-13 09:22:55 +0200
commit5edd6a8caa45a1e31db942c1dee8dc2835822804 (patch)
tree812a2a7fd41c6b750f2709ddea961c4da74528e9 /player/lua/ytdl_hook.lua
parent0e72f64ff46747d4b1399d6cb7803e3f675d047c (diff)
downloadmpv-5edd6a8caa45a1e31db942c1dee8dc2835822804.tar.bz2
mpv-5edd6a8caa45a1e31db942c1dee8dc2835822804.tar.xz
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.
Diffstat (limited to 'player/lua/ytdl_hook.lua')
-rw-r--r--player/lua/ytdl_hook.lua20
1 files changed, 17 insertions, 3 deletions
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