-- play32.lua - launcher for sanjuuni combined-stream .32vid videos on CC:Tweaked -- Usage: -- play32 [monitorSide] [textScale] -- Examples: -- play32 myvideo.32vid top 0.5 -- play32 https://yourhost.com/myvideo.32vid top 0.5 local args = { ... } if #args < 1 then print("Usage: play32 [monitorSide] [textScale]") return end local SOURCE = args[1] local MON_SIDE = args[2] local SCALE = tonumber(args[3]) local PLAYER_FILE = "32vid-player-mini.lua" local PLAYER_URL = "https://raw.githubusercontent.com/MCJack123/sanjuuni/master/32vid-player-mini.lua" local function ensure_http() if not http then error("HTTP is disabled. Enable it in CC:Tweaked config (http.enabled=true).") end end local function download_to(url, path) ensure_http() local ok, why = http.checkURL(url) if ok == false then error("URL blocked by HTTP rules: " .. tostring(why)) end local res, err = http.get(url, { ["Cache-Control"] = "no-cache" }) if not res then error("HTTP GET failed: " .. tostring(err)) end local f = fs.open(path, "w") if not f then res.close(); error("Can't write file: " .. path) end while true do local chunk = res.read(8192) if not chunk then break end f.write(chunk) end f.close() res.close() end local function ensure_player() if fs.exists(PLAYER_FILE) then return end print("Downloading player...") download_to(PLAYER_URL, PLAYER_FILE) print("Saved " .. PLAYER_FILE) end local function maybe_redirect_monitor() local mon = nil if MON_SIDE and MON_SIDE ~= "" then if peripheral.getType(MON_SIDE) == "monitor" then mon = peripheral.wrap(MON_SIDE) end else mon = peripheral.find("monitor") end if mon then if SCALE then pcall(function() mon.setTextScale(SCALE) end) end term.redirect(mon) term.setCursorPos(1, 1) term.clear() end end -- Main ensure_player() maybe_redirect_monitor() -- Run the player. It accepts a local filename OR an HTTP URL. shell.run(PLAYER_FILE, SOURCE)