--By LIN --如果有用不顺手的地方可自行更改 DM="这里是江音乐欢迎使用!" gg.playMusic("https://fanyi.baidu.com/gettts?lan=zh&text="..DM.."&spd=5&source=wise") menu ={} name ={} id = 0 play = false song = "" _G_ = { function() local searchMusic = gg.prompt({ "歌曲•歌手", "字数•限制", },{"","10"},{ "text", "text", }) if not searchMusic then gg.setVisible(false) Main() elseif searchMusic[1] == "" then gg.alert("请输入歌曲/歌手!") _G_[1]() else local results = gg.makeRequest("http://music.163.com/api/search/get?s="..searchMusic[1].."&type=1&offset=0&total=true&limit="..searchMusic[2]) if results.code == 200 then n=1 for v,k in results.content:gmatch('"id":(.-),"name":"(.-)"') do if n%4 == 1 then menu[n/4+1] = v..";"..k end if n%4 == 2 then menu[n/4+1] = menu[n/4+1]..";"..k end n=n+1 end _G_[2]() else local s = gg.alert("请求异常,请检查网络……","返回","退出") if not s then gg.setVisible(false) Main() end if s == 1 then os.exit() end if s == 2 then _G_[1]() end end end end, function() if #menu == 0 then gg.alert("没有搜索记录") Main() else for n=1,#menu do name[n] = menu[n]:gsub("[0-9]+;",""):gsub(";","\n歌手:") end local mu = gg.choice(name,0,"歌单") if not mu then _G_[1]() else song = name[mu] local sn=gg.choice({"播放","查看歌词"},nil,"歌曲:"..name[mu]) if not sn then _G_[1]() end if sn == 1 then id = menu[mu]:match("(.-);") gg.toast("正在播放音乐:"..name[mu],true) gg.playMusic("http://music.163.com/song/media/outer/url?id="..id..".mp3") play = true end if sn == 2 then id = menu[mu]:match("(.-);") song = name[mu] _G_[3]() end end end end, function() if id == 0 then gg.alert("未有播放记录") Main() else local results = gg.makeRequest("http://music.163.com/api/song/media?id="..id).content rs = results:match('"lyric":"(.-)","code'):gsub("\\n","\n"):gsub("[[!-z]+]","") gg.alert("\n《"..song:gsub("\n","》\n").."\n\n"..rs) gg.setVisible(false) end end, function() if play then play = false gg.toast("正在停止播放...") for i=1,100 do gg.playMusic("stop") gg.playMusic("stop") gg.playMusic("stop") gg.playMusic("stop") gg.playMusic("stop") gg.playMusic("stop") end gg.toast("播放已停止") else gg.toast("无正在播放的音乐") end end, function() gg.setVisible(true) if play then _G_[4]() end os.exit() end } function Main() local WY = gg.choice({ "搜索歌曲", "搜索列表", "显示歌词", "暂停播放", "退出脚本" },nil,"江音乐") if not WY then gg.setVisible(false) end if WY then _G_[WY]() end end gg.setVisible(true) while true do if gg.isVisible() then gg.setVisible(false) Main() end end