aboutsummaryrefslogtreecommitdiffhomepage
path: root/player/lua
diff options
context:
space:
mode:
authorGravatar ChrisK2 <spam@kalania.de>2015-08-27 13:42:04 +0200
committerGravatar ChrisK2 <spam@kalania.de>2015-08-27 13:42:04 +0200
commit3c86bd2bb521fd006070709e1f68d672be1937f9 (patch)
treea9252eb6539b48c86bd14ae7818964f38b8f8646 /player/lua
parentba384fffca982465e63c3ffe3a3fb34c08e75de2 (diff)
ytdl: catch bogous extractor info
Some extractors may claim to have extracted subtitles, but then set the relevant fields to null. Try to catch those cases. Fixes #2254
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/ytdl_hook.lua24
1 files changed, 12 insertions, 12 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
index 0e3bdd2e8c..df08c3d83f 100644
--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -96,12 +96,9 @@ mp.add_hook("on_load", 10, function ()
local format = mp.get_property("options/ytdl-format")
local raw_options = mp.get_property_native("options/ytdl-raw-options")
- -- subformat workaround
- local subformat = "ass/srt/best"
-
local command = {
ytdl.path, "--no-warnings", "-J", "--flat-playlist", "--all-subs",
- "--sub-format", subformat, "--no-playlist"
+ "--sub-format", "ass/srt/best", "--no-playlist"
}
-- Checks if video option is "no", change options accordingly
@@ -147,7 +144,8 @@ mp.add_hook("on_load", 10, function ()
-- direct URL, nothing to do
msg.verbose("Got direct URL")
return
- elseif not (json["_type"] == nil) and ((json["_type"] == "playlist") or (json["_type"] == "multi_video")) then
+ elseif not (json["_type"] == nil)
+ and ((json["_type"] == "playlist") or (json["_type"] == "multi_video")) then
-- a playlist
if (#json.entries == 0) then
@@ -244,18 +242,20 @@ mp.add_hook("on_load", 10, function ()
for lang, sub_info in pairs(json.requested_subtitles) do
msg.verbose("adding subtitle ["..lang.."]")
- local slang = lang
- if (lang:len() > 3) then
- slang = lang:sub(1,2)
- end
+ local sub = nil
if not (sub_info.data == nil) then
sub = "memory://"..sub_info.data
- else
+ elseif not (sub_info.url == nil) then
sub = sub_info.url
end
- mp.commandv("sub_add", sub,
- "auto", lang.." "..sub_info.ext, slang)
+
+ if not (sub == nil) then
+ mp.commandv("sub_add", sub,
+ "auto", sub_info.ext, lang)
+ else
+ msg.verbose("No subtitle data/url for ["..lang.."]")
+ end
end
end