{
"count": 2,
"code": 0,
"result": [
{
"aid": 2727794,
"lrc": "http://s.geci.me/lrc/327/32793/3279317.lrc",
"song": "不得不爱",
"artist_id": 2,
"sid": 3279317
},
{
"aid": 3048347,
"lrc": "http://s.geci.me/lrc/371/37129/3712941.lrc",
"song": "不得不爱",
"artist_id": 2,
"sid": 3712941
}
]
}
public static Lrc SearchLrc(string musicName)
{
string path = @"D:\lrc\" + musicName + ".lrc";
if (System.IO.File.Exists(path))
{
return InitLrc(path);
}
else
{
return DownloadLrc(musicName, path);
}
}
public class TempJosnMain
{
public int count { get; set; }
public int code { get; set; }
public List<TempJsonChild> result { get; set; }
}
public class TempJsonChild
{
public int aid { get; set; }
public string lrc { get; set; }
public string song { get; set; }
public int artist_id { get; set; }
public int sid { get; set; }
}
static Lrc DownloadLrc(string musicName, string path)
{
if (musicName.Contains("-"))
musicName = musicName.Split('-')[1].Trim();
string url = "http://geci.me/api/lyric/" + musicName;
WebClient wc = new WebClient();
string json = wc.DownloadString(url);
JavaScriptSerializer js = new JavaScriptSerializer();
TempJosnMain res = js.Deserialize<TempJosnMain>(json);
if (res.count > 0)
{
wc.DownloadFile(new Uri(res.result[0].lrc), path);
wc.Dispose();
return InitLrc(path);
}
return new Lrc();
}
public static void SearchLrcAsyc(string musicName, Action<Lrc> action)
{
string path = @"D:\lrc\" + musicName + ".lrc";
if (System.IO.File.Exists(path))
{
action(InitLrc(path));
}
else
{
DownloadLrcAsyc(musicName, path, action);
}
}
public void DownloadStringAsync( Uri address, object userToken )
public class CallbackObject
{
public string path { get; set; }
public Action<Lrc> action { get; set; }
}
static void DownloadLrcAsyc(string musicName, string path, Action<Lrc> action)
{
if (musicName.Contains("-"))
musicName = musicName.Split('-')[1].Trim();
string url = "http://geci.me/api/lyric/" + musicName;
WebClient wc = new WebClient();
CallbackObject co = new CallbackObject()
{
action = action,
path = path
};
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
wc.DownloadStringAsync(new Uri(url), co);
}
static void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
JavaScriptSerializer js = new JavaScriptSerializer();
TempJosnMain res = js.Deserialize<TempJosnMain>(e.Result);
if (res.count > 0)
{
WebClient wc = sender as WebClient;
if (wc == null)
wc = new WebClient();
CallbackObject co = e.UserState as CallbackObject;
wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
wc.DownloadFileAsync(new Uri(res.result[0].lrc), co.path, co);
}
}
static void wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
CallbackObject co = e.UserState as CallbackObject;
co.action(InitLrc(co.path));
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有