public string GetLyric(string McMind) { string name = mldata[McMind]; string file = Settings.USettings.CachePath + "Lyric\\" + name + ".lrc"; if (!File.Exists(file)) { WebClient c = new WebClient(); c.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36"); c.Headers.Add("Accept", "*/*"); c.Headers.Add("Referer", "https://y.qq.com/portal/player.html"); c.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8"); c.Headers.Add("Cookie", $"tvfe_boss_uuid=c3db0dcc4d677c60; pac_uid=1_{qq}; qq_slist_autoplay=on; ts_refer=ADTAGh5_playsong; RK=pKOOKi2f1O; pgv_pvi=8927113216; o_cookie={qq}; pgv_pvid=5107924810; ptui_loginuin={qq}; ptcz=897c17d7e17ae9009e018ebf3f818355147a3a26c6c67a63ae949e24758baa2d; pt2gguin=o{qq}; pgv_si=s5715204096; qqmusic_fromtag=66; yplayer_open=1; ts_last=y.qq.com/portal/player.html; ts_uid=996779984; yq_index=0"); c.Headers.Add("Host", "c.y.qq.com"); string s = TextHelper.XtoYGetTo(c.DownloadString($"https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?callback=MusicJsonCallback_lrc&pcachetime=1494070301711&songmid={McMind}&g_tk=5381&jsonpCallback=MusicJsonCallback_lrc&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq&needNewCode=0"), "MusicJsonCallback_lrc(", ")", 0); Console.WriteLine(s); JObject o = JObject.Parse(s); string t = Encoding.UTF8.GetString(Convert.FromBase64String(o["lyric"].ToString())).Replace("'", "\'"); if (o["trans"].ToString() == "") { return(t); } else { string x = Encoding.UTF8.GetString(Convert.FromBase64String(o["trans"].ToString())).Replace("'", "\'"); return(PushLyric(t, x, file)); } } else { return(File.ReadAllText(file)); } }
public static String[] parserLine(String str, List <String> times, List <String> texs, Dictionary <String, String> data, bool doesAdd = true) { if (!str.StartsWith("[ti:") && !str.StartsWith("[ar:") && !str.StartsWith("[al:") && !str.StartsWith("[by:") && !str.StartsWith("[offset:") && !str.StartsWith("[kana") && str.Length != 0) { String TimeData = TextHelper.XtoYGetTo(str, "[", "]", 0); String io = "[" + TimeData + "]"; String TexsData = str.Replace(io, ""); //String unTimeData = TimeData.Substring(0, TimeData.Length - 1); if (doesAdd) { if (data.ContainsKey(TimeData)) { texs.Add(TexsData); data[TimeData] += "^" + TexsData; } else { times.Add(TimeData); texs.Add(TexsData); data.Add(TimeData, TexsData); } } return(new string[2] { TimeData, TexsData }); } else { return(null); } }
public static string YwY(string str, int i) { //00:02.06 => 00:02.07 string lstr = TextHelper.XtoYGetTo(str + "]", ".", "]", 0); //06 string LastTime = (int.Parse(lstr) + i).ToString(); //06+i if (LastTime.Length == 1) { LastTime = "0" + LastTime; } return(str.Replace(lstr, LastTime.ToString())); }
public async void GetAndPlayMusicUrlAsync(string mid, Boolean openlyric, TextBlock x, Window s, bool doesplay = true) { string name = mldata[mid] + ".mp3"; string downloadpath = Settings.USettings.CachePath + "Music\\" + mid + ".mp3"; if (!File.Exists(downloadpath)) { string musicurl = ""; musicurl = await GetUrlAsync(mid); WebClient dc = new WebClient(); dc.DownloadFileCompleted += delegate { pc.Open(downloadpath); if (doesplay) { pc.Play(); } s.Dispatcher.Invoke(DispatcherPriority.Normal, new System.Windows.Forms.MethodInvoker(delegate() { x.Text = TextHelper.XtoYGetTo("[" + name, "[", " -", 0).Replace("Wy", ""); })); }; dc.DownloadFileAsync(new Uri(musicurl), downloadpath); dc.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) { s.Dispatcher.Invoke(DispatcherPriority.Normal, new System.Windows.Forms.MethodInvoker(delegate() { x.Text = "加载中..." + e.ProgressPercentage + "%"; })); }; } else { pc.Open(downloadpath); if (doesplay) { pc.Play(); } s.Dispatcher.Invoke(DispatcherPriority.Normal, new System.Windows.Forms.MethodInvoker(delegate() { x.Text = TextHelper.XtoYGetTo("[" + name, "[", " -", 0).Replace("Wy", ""); })); } if (openlyric) { name = TextHelper.XtoYGetTo("[" + name, "[", ".mp3", 0); string dt = GetLyric(mid); lv.LoadLrc(dt); } }