local bx=os.date("%Y年%m月%d日%H时%M分%S秒") print(bx) bqt={"🌠","🎋","🍥","🍡","🍋","🍀","🔰","🙃","💮","🎡","💠","🍁️","🌀"} function Main() local sjbq= bqt[math.random(1,#bqt)]SY = gg.choice({ [1] = sjbq.."🔥播放音乐🔥️"..sjbq, },2022,os.date("音乐")) if SY==1 then B() end FX1=0 end local g = {} g.file = gg.getFile() g.sel = nil gqlb={"请先搜索歌曲",} idb={"1010"} SN,gc=1,nil g.config = gg.getFile():gsub("%lua$", "").."cfg" function bei() g.data = loadfile(g.config) if g.data ~= nil then g.sel = g.data() g.data = nil end if g.sel == nil then g.sel = {"【FREE】lucky","30"} end end bei() --搜索歌曲 function start(name,sl) fw=gg.makeRequest("http://music.163.com/api/search/get?s="..name.."&type=1&offset=0&total=true&limit="..sl) return fw end --歌词 --播放音乐 function play(id,name) gg.toast("正在播放音乐:"..name,true) gg.playMusic("http://music.163.com/song/media/outer/url?id="..id..".mp3") end --停止播放 function stop() gg.toast("正在停止音乐") for i=1,100 do gg.playMusic("stop") gg.playMusic("stop") gg.playMusic("stop") end end ---- function Play(gqlb,idb) SN = gg.choice(gqlb,nil,ts) if SN == nil then XGCK =-1 else sn=gg.choice({"播放"},nil,"歌曲:"..gqlb[SN]) if sn == nil then end if sn == 1 then play(idb[SN],gqlb[SN]) end XGCK=-1 end end function zjson(jsonr) local str = jsonr -- 匹配Json Key的正则表达式 local pattern = "\"[%w]+\":" string.gsub(str, pattern, function(v) if string.find(str, v) then str = string.gsub(str, v, string.gsub(v, "\"", "")) end end) str = string.gsub(str, ":", "=") str = string.gsub(str, "%[", "{") str = string.gsub(str, "%]", "}") local data = "return " .. str local res = load(data)() return res end function json(con) res=zjson(con) zd=res.result.songCount pd=go3-zd if pd <= 0 then else go3=zd end ts="《"..go1.."》找到"..zd.."首歌曲,当前显示"..go3.."首" gqlb={} idb={} for i=1,go3 do gqlb[i]=res.result.songs[i].name idb[i]=res.result.songs[i].id end --print(idb) end function YY998() Obtain=gg.makeRequest("https://api.uomg.com/api/rand.music?sort=热歌榜&format=json").content muchen=Obtain:match('url":"(.-)","picurl') gg.playMusic(muchen) end --主页 function B() SN = gg.choice({ "🔥搜 索 歌 曲🔥", "🔥搜 索 列 表🔥", "🔥播 放 热 歌🔥", "🔥停 止 播 放🔥", "️⚡️返 回 主 页⚡️️", },2018,os.date("当前时间%Y年%m月%d日%H时%M分%S秒")) if SN==1 then s1() end if SN==2 then Play(gqlb,idb) end if SN==3 then YY998() end if SN==4 then stop() end if SN==5 then Main() end FX1=0 end --- function s1() search = gg.prompt({ "输入要搜索的歌曲\n可加上歌手名字", "设置显示数量(数字)", },g.sel,{ "text", }) if not search then return end gg.saveVariable(search,g.config) bei() go1=search[1] go3=search[2] jg=start(go1,go3) if jg.code == 200 then fh=jg.content fh=json(fh) --print(fh) Play(gqlb,idb) else function inspect() gg.alert("访问网络异常,错误代码:\n\n"..jg.code) end if not pcall(inspect) then print("网络异常,请先连接上网络") os.exit() end end XGCK=-1 end function Exit() print("🐔你太美") gg.toast("🔰欢迎下次使用🔰") os.exit() end gg.showUiButton() while true do if gg.isClickedUiButton() then Main() end end