import console;
import fsys;
import godking.http;
var url = "https://api.cenguigui.cn/api/music/kuwo/KoWo_Dg.php?type=text&msg="++console.getText("请输入歌手:")++"&num=500";
console.log("查找到的歌曲有:",(godking.http(url)));
var str = godking.http(url ++ "&n=" ++ console.getNumber("请输入要下载的歌曲序号:")):"";
var s1,s2,s3 = string.match( str, "歌名:(.+?)\r\n歌手:(.+?)\r\n.+?播放链接:(.+)" );
if #s3 {
var ext = ..string.split(s3,"<.>");
fsys.createDir("\酷我音乐下载\");
var data,header,result = godking.http({
url = s3;
file = "\酷我音乐下载\"++s2++s1++"."++ext[#ext];
callback = function(ID,已下载大小,总大小,网址,本地文件名){
if 已下载大小===-1 and 总大小===-1 console.log(" 下载完毕");
else console.writeBack(string.format("%03d",math.round(已下载大小*100/总大小,0))++"%");
}
})
if (result.success) {
console.logPause("文件已下载完成!");
} else {
console.logPause("下载错误:"++result.info);
}
} else {
console.logPause("获取文件信息错误!");
}