From abe0b37f7dee5cbf25ffaf5a5adf5743ea56bf71 Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 15 Sep 2024 03:36:14 +0300 Subject: [PATCH] Fixed argument parsing --- video.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/video.lua b/video.lua index d2c0774..597ade4 100644 --- a/video.lua +++ b/video.lua @@ -33,11 +33,11 @@ while args[1] ~= nil and string.sub(args[1], 1, 1) == "-" do elseif k == "J" or k == "info-json" then local req = assert(http.get(table.remove(args, 1))) local info = textutils.unserializeJSON(req.readAll()) - delay = info.frametime + delay = info.frame_time n_frames = info.frame_count video_url = info.video audio_url_l = info.audio.l - audio_url_l = info.audio.r + audio_url_r = info.audio.r req.close() end end @@ -52,14 +52,16 @@ if not speakers.l then return end -if #args < 3 and not n_frames and not video_url and not audio_url_l then - printError("Usage: video [-w] [-b BUFSZ] [-t THREADS] [-J URL] [-m MONITOR] [-l SPK_L] [-r SPK_R] [-d FRAME_T] [RIGHT_CHANNEL]") - return -else - n_frames = tonumber(table.remove(args, 1)) - video_url = table.remove(args, 1) - audio_url_l = table.remove(args, 1) - audio_url_r = #args > 0 and table.remove(args, 1) or nil +if not n_frames and not video_url and not audio_url_l then + if #args < 3 then + printError("Usage: video [-w] [-b BUFSZ] [-t THREADS] [-J URL] [-m MONITOR] [-l SPK_L] [-r SPK_R] [-d FRAME_T] [RIGHT_CHANNEL]") + return + else + n_frames = tonumber(table.remove(args, 1)) + video_url = table.remove(args, 1) + audio_url_l = table.remove(args, 1) + audio_url_r = #args > 0 and table.remove(args, 1) or nil + end end print(string.format("Using monitor %s", peripheral.getName(monitor)))