From 548ef07864f3e1a40f731b2643f037435ceae46d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 12 May 2018 15:36:43 +0200 Subject: lua: reimplement mp.subprocess() by invoking the new subprocess command We keep mp.subprocess() with roughly the same semantics for compatibility with scripts (including the internal ytdl script). Seems to work with rhe ytdl wrapper. Not tested further. --- player/lua/defaults.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'player/lua/defaults.lua') diff --git a/player/lua/defaults.lua b/player/lua/defaults.lua index 6f5a9c4b6c..feb400111a 100644 --- a/player/lua/defaults.lua +++ b/player/lua/defaults.lua @@ -617,4 +617,27 @@ function mp_utils.format_bytes_humanized(b) return string.format("%0.2f %s", b, d[i] and d[i] or "*1024^" .. (i-1)) end +function mp_utils.subprocess(t) + local cmd = {} + cmd.name = "subprocess" + cmd.capture_stdout = true + for k, v in pairs(t) do + if k == "cancellable" then + k = "playback_only" + elseif k == "max_size" then + k = "capture_size" + end + cmd[k] = v + end + local res, err = mp.command_native(cmd) + if res == nil then + -- an error usually happens only if parsing failed (or no args passed) + res = {error_string = err, status = -1} + end + if res.error_string ~= "" then + res.error = res.error_string + end + return res +end + return {} -- cgit v1.2.3