public async Task UpdateGdAsync() { var dt = await HttpHelper.GetWebDatacAsync($"https://c.y.qq.com/rsc/fcgi-bin/fcg_get_profile_homepage.fcg?loginUin={qq}&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq&needNewCode=0&cid=205360838&ct=20&userid={qq}&reqfrom=1&reqtype=0", Encoding.UTF8, "pgv_pvi=9798155264; RK=JKKMei2V0M; ptcz=f60f58ab93a9b59848deb2d67b6a7a4302dd1208664e448f939ed122c015d8d1; pgv_pvid=4173718307; ts_uid=5327745136; ts_uid=5327745136; pt2gguin=o2728578956; ts_refer=xui.ptlogin2.qq.com/cgi-bin/xlogin; yq_index=0; o_cookie=2728578956; pac_uid=1_2728578956; pgv_info=ssid=s8910034002; pgv_si=s3134809088; _qpsvr_localtk=0.8145813010716534; uin=o2728578956; skey=@ZF3GfLQsE; ptisp=ctc; luin=o2728578956; lskey=00010000c504a12a536ab915ce52f0ba2a3d24042adcea8e3b78ef55972477fd6d67417e4fc27cdaa8a0bd86; p_uin=o2728578956; pt4_token=YoecK598VtlFoQ7Teus8nC51UayhpD9rfitjZ6BMUkc_; p_skey=SFU7-V*Vwn3XsXtF3MF4T2OAOBbSp96ol-zzMbhcCzM_; p_luin=o2728578956; p_lskey=00040000768e027ce038844edbd57908c83024d365b4a86c9c12cf8b979d473a573567e70c30bd779d5f20cd; yqq_stat=0"); var o = JObject.Parse(dt); var dx = o["data"]["mydiss"]["list"]; foreach (var ex in dx) { if (Settings.USettings.MusicGD.ContainsKey(ex["dissid"].ToString())) { Settings.USettings.MusicGD.Remove(ex["dissid"].ToString()); } var df = new MusicGData(); df.id = ex["dissid"].ToString(); df.Data = (await GetGDAsync(df.id)).Data; df.name = ex["title"].ToString(); if (ex["picurl"].ToString() != "") { df.pic = ex["picurl"].ToString(); } else { df.pic = "https://y.gtimg.cn/mediastyle/global/img/cover_playlist.png?max_age=31536000"; } Settings.USettings.MusicGD.Add(df.id, df); } }
public async Task <MusicGData> GetGDbyWYAsync(string id, Window x, TextBlock tb, ProgressBar pb) { string data = HttpHelper.PostWeb("http://lab.mkblog.cn/music/api.php", "types=playlist&id=" + id); JObject o = JObject.Parse(data); var dt = new MusicGData(); dt.name = o["playlist"]["name"].ToString(); dt.id = o["playlist"]["id"].ToString(); dt.pic = o["playlist"]["coverImgUrl"].ToString(); x.Dispatcher.Invoke(() => { pb.Maximum = o["playlist"]["tracks"].Count(); }); for (int i = 0; i != o["playlist"]["tracks"].Count(); i++) { var dtname = o["playlist"]["tracks"][i]["name"].ToString(); var dtsinger = ""; for (int dx = 0; dx != o["playlist"]["tracks"][i]["ar"].Count(); dx++) { dtsinger += o["playlist"]["tracks"][i]["ar"][dx]["name"] + "&"; } dtsinger = dtsinger.Substring(0, dtsinger.LastIndexOf("&")); var dtf = await SearchMusicAsync(dtname + "-" + dtsinger); if (dtf.Count > 0) { dt.Data.Add(dtf[0]); x.Dispatcher.Invoke(() => { pb.Value = i; tb.Text = dtf[0].MusicName + " - " + dtf[0].Singer; }); } else { x.Dispatcher.Invoke(() => { pb.Value--; }); } } return(dt); }
public async Task <MusicGData> GetGDAsync(string id = "2591355982") { var s = await HttpHelper.GetWebDatacAsync($"https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg?type=1&json=1&utf8=1&onlysong=0&disstid={id}&format=json&g_tk=1157737156&loginUin={qq}&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq&needNewCode=0", Encoding.UTF8); JObject o = JObject.Parse(s); var dt = new MusicGData(); dt.name = o["cdlist"][0]["dissname"].ToString(); dt.pic = o["cdlist"][0]["logo"].ToString(); dt.id = id; int i = 0; while (i != o["cdlist"][0]["songlist"].Count()) { string singer = ""; for (int ix = 0; ix != o["cdlist"][0]["songlist"][i]["singer"].Count(); ix++) { singer += o["cdlist"][0]["songlist"][i]["singer"][ix]["name"].ToString() + "&"; } Music m = new Music(); try { m.MusicName = o["cdlist"][0]["songlist"][i]["songname"].ToString().Replace("\\", "-").Replace("?", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", ""); m.MusicName_Lyric = o["cdlist"][0]["songlist"][i]["albumdesc"].ToString(); m.Singer = singer.Substring(0, singer.Length - 1); m.GC = o["cdlist"][0]["songlist"][i]["songid"].ToString(); m.MusicID = o["cdlist"][0]["songlist"][i]["songmid"].ToString(); m.ImageUrl = await GetImageUrlByIDAsync(m.MusicID); }//莫名其妙的System.NullReferenceException:“未将对象引用设置到对象的实例。” catch { } dt.Data.Add(m); if (!mldata.ContainsKey(m.MusicID)) { mldata.Add(m.MusicID, (m.MusicName + " - " + m.Singer).Replace("\\", "-").Replace("?", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "")); } i++; } return(dt); }