diff options
author | wm4 <wm4@nowhere> | 2018-05-12 15:36:43 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:34 +0200 |
commit | 548ef07864f3e1a40f731b2643f037435ceae46d (patch) | |
tree | e40245dc8f8b323b00632fc9c4bad9d8f5f131d9 /player/lua | |
parent | d9bc97bda6e4750af2fbbfcb51ddb6b2c04c277b (diff) | |
download | mpv-548ef07864f3e1a40f731b2643f037435ceae46d.tar.bz2 mpv-548ef07864f3e1a40f731b2643f037435ceae46d.tar.xz |
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.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/defaults.lua | 23 |
1 files changed, 23 insertions, 0 deletions
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 {} |