Files
CC-StationBroadcast/update_station_broadcast.lua
T
Henry_Du c73bceaec7 feat: 重构音频系统,移除外部依赖并新增WAV格式支持
- 移除install和update脚本中的aukit/austream下载配置与目标,不再部署辅助脚本
- 替换station_broadcast.lua的aukit库为CC内置dfpwm模块,重写音频播放逻辑
- 添加原生扬声器API支持,支持WAV格式音频播放
- 重写云端服务器音频处理逻辑,支持直接传输WAV文件无需预转换
- 新增WAV文件时长解析、音频序列合成等辅助功能
2026-07-31 19:29:38 +08:00

79 lines
1.6 KiB
Lua

local STATION_BROADCAST_URL = "https://gitea.fse-media.group/Henry_Du/CC-StationBroadcast/raw/commit/e4b4fa5cdb2bc42279fd87098fef0d27a90e23d5/station_broadcast.lua"
local function fetch(url)
if not http then
return nil, "HTTP API unavailable"
end
if http.checkURL then
local ok, err = http.checkURL(url)
if not ok then
return nil, err or "URL blocked"
end
end
local res, err = http.get(url)
if not res then
return nil, err or "request failed"
end
local body = res.readAll()
res.close()
if type(body) ~= "string" or #body == 0 then
return nil, "empty response"
end
return body
end
local function writeFile(path, content)
local dir = fs.getDir(path)
if dir and dir ~= "" and not fs.exists(dir) then
fs.makeDir(dir)
end
local f = fs.open(path, "w")
if not f then
return nil, "cannot open " .. path
end
f.write(content)
f.close()
return true
end
local function downloadTo(url, path)
write(("Updating %s... "):format(path))
local body, err = fetch(url)
if not body then
print("FAILED")
print(err)
return false
end
local ok, werr = writeFile(path, body)
if not ok then
print("FAILED")
print(werr)
return false
end
print("OK")
return true
end
local targets = {
{ url = STATION_BROADCAST_URL, path = shell.resolve("/startup") }
}
for _, t in ipairs(targets) do
local ok = downloadTo(t.url, t.path)
if not ok then
print("Update aborted.")
return
end
end
print("Update complete.")