上传文件至 / #1

Closed
color_garden wants to merge 1 commits from color_garden/computer_craft_video_play:main into main

View File

@@ -1,4 +1,3 @@
local mypath = "/"..fs.getDir(shell.getRunningProgram())
if not fs.exists(mypath.."/speakerlib.lua") then shell.run("wget https://git.liulikeji.cn/xingluo/computer_craft_video_play/raw/branch/main/speakerlib.lua "..mypath.."/speakerlib.lua") end
if not fs.exists(mypath.."/cc_big_http.lua") then shell.run("wget https://git.liulikeji.cn/xingluo/cc_big_http/raw/branch/main/cc_big_http.lua "..mypath.."/cc_big_http.lua") end
@@ -10,6 +9,7 @@ local age = {...}
local videoUrl = age[1]
local debug
local server_url = "https://newgmapi.liulikeji.cn"
local custom_server_flag = false -- 标志位:判断是否在命令行指定了服务器
local pix_fmt = "pal8"
local gpu_Size_Auto = false --自动分辨率设置
local gpu_Size = 64 --默认屏幕分辨率
@@ -22,7 +22,7 @@ Options:
-h/-high Use high color mode (rgba24) instead of palette (pal8)
-size <N> Set GPU size to NxN (1-64)
-gpu <id> Specify GPU peripheral ID to use
-server <URL> Set API server URL (default: http://127.0.0.1:5000)
-server <URL> Set API server URL (default: https://newgmapi.liulikeji.cn)
]]
for i,v in ipairs(age) do
@@ -35,6 +35,7 @@ for i,v in ipairs(age) do
elseif v == "-server" and age[i+1] then
server_url = age[i+1]
custom_server_flag = true -- 记录已通过参数设置
elseif v == "-help" then
print(play_help)
error("Help requested")
@@ -138,6 +139,33 @@ if not videoUrl then
return
end
-- 交互式服务器选择菜单
if not custom_server_flag then
print("\n=== API Server Selection ===")
print("[1] http://101.133.167.126:9000")
print("[2] https://newgmapi.liulikeji.cn (Default)")
print("Or manually input a custom server IP/URL.")
write("Select [1/2/URL] (Press Enter for default): ")
local choice = read()
if choice == "1" then
server_url = "http://101.133.167.126:9000"
elseif choice == "2" or choice == "" then
server_url = "https://newgmapi.liulikeji.cn"
else
-- 自动补全 http:// 前缀
if not string.match(choice, "^http[s]?://") then
server_url = "http://" .. choice
else
server_url = choice
end
end
print("\nUsing server: " .. server_url)
sleep(0.5)
end
_G.audio_ready = false
local task_id
local status_url
@@ -193,11 +221,6 @@ local all_logs = {} -- 存储所有日志(完整版本,包含时间戳)
local speakerrun = true
local last_log_count = 0 -- 记录上次已打印的日志数量
-- 用于记录已打印的日志数量,避免重复打印
local all_logs = {} -- 存储所有日志(完整版本,包含时间戳)
local speakerrun = true
local last_log_count = 0 -- 记录上次已打印的日志数量
-- 去除日志前的时间戳用于显示
local function removeTimestamp(logText)
-- 匹配 [YYYY-MM-DD HH:MM:SS] 格式并去除
@@ -849,4 +872,4 @@ else
perf_log_file.write(textutils.serialiseJSON(perf_log))
print("perf_log has been saved to "..mypath.."/perf_log.json")
end
end
end