aboutsummaryrefslogtreecommitdiffhomepage
path: root/player/lua
diff options
context:
space:
mode:
authorGravatar ChrisK2 <spam@kalania.de>2015-09-30 22:28:01 +0200
committerGravatar ChrisK2 <spam@kalania.de>2015-09-30 22:28:01 +0200
commit1b7e8ff6c590ef3ef289c7468941acd6cf450e41 (patch)
tree3fe87032eef2b77863dfbd8a33bdd0c1a1cb8ebe /player/lua
parent739452361f5e1de1067ca44c0bb01e95e1c075d9 (diff)
ytdl: Don't override user-set format in no-video mode
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/ytdl_hook.lua34
1 files changed, 23 insertions, 11 deletions
diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua
index df08c3d83f..ff905be990 100644
--- a/player/lua/ytdl_hook.lua
+++ b/player/lua/ytdl_hook.lua
@@ -12,7 +12,7 @@ local function exec(args)
return ret.status, ret.stdout, ret
end
--- return if it was explicitly set on the command line
+-- return true if it was explicitly set on the command line
local function option_was_set(name)
return mp.get_property_bool("option-info/" .. name .. "/set-from-commandline",
false)
@@ -51,6 +51,11 @@ local function append_rtmp_prop(props, name, value)
return props..name.."=\""..value.."\""
end
+local function edl_escape(url)
+ return "%" .. string.len(url) .. "%" .. url
+end
+
+
mp.add_hook("on_load", 10, function ()
local url = mp.get_property("stream-open-filename")
@@ -101,8 +106,11 @@ mp.add_hook("on_load", 10, function ()
"--sub-format", "ass/srt/best", "--no-playlist"
}
- -- Checks if video option is "no", change options accordingly
- if (mp.get_property("options/vid") == "no") then
+ -- Checks if video option is "no", change format accordingly,
+ -- but only if user didn't explicitly set one
+ if (mp.get_property("options/vid") == "no")
+ and not option_was_set("ytdl-format") then
+
format = "bestaudio/best"
msg.verbose("Video disabled. Only using audio")
end
@@ -162,10 +170,7 @@ mp.add_hook("on_load", 10, function ()
local playlist = "edl://"
for i, entry in pairs(json.entries) do
-
- local urllength = string.len(entry.url)
- playlist = playlist .. "%" .. urllength .. "%" .. entry.url .. ";"
-
+ playlist = playlist .. edl_escape(entry.url) .. ";"
end
msg.debug("EDL: " .. playlist)
@@ -206,14 +211,21 @@ mp.add_hook("on_load", 10, function ()
-- DASH?
if not (json["requested_formats"] == nil) then
- msg.info("Using DASH, expect inaccurate duration.")
- if not (json.duration == nil) then
- msg.info("Actual duration: " .. mp.format_time(json.duration))
- end
-- video url
streamurl = json["requested_formats"][1].url
+ -- fake duration
+ --if (true) and not (json.duration == nil) then
+ -- streamurl = "edl://" .. edl_escape(streamurl)
+ -- .. ",0," .. json.duration .. ";"
+ -- msg.info("Faking duration, ignore the following warning.")
+
+ --elseif not (json.duration == nil) then
+ msg.info("Using DASH, expect inaccurate duration.")
+ msg.info("Actual duration: " .. mp.format_time(json.duration))
+ --end
+
-- audio url
mp.set_property("file-local-options/audio-file",
json["requested_formats"][2].url)