Exemple #1
0
 void OnThreadWork()
 {
     if (mSearchChoice == LInterface.LSearchChoice.NetEase)
     {
         NetEaseReturn_Song ners = LInterface.Deserialize <NetEaseReturn_Song>(LInterface.GetResponse(LInterface.NetEaseMusic_Search(1, mKeyWord)));
         if (isSeachCanceled)
         {
             SearchResultUpdateHandler?.Invoke(null, true); return;
         }
         foreach (NERS_Single nerss in ners.result.songs)
         {
             if (isSeachCanceled)
             {
                 SearchResultUpdateHandler?.Invoke(null, true); return;
             }
             try { SearchResultUpdateHandler?.Invoke(new LSearchResult(nerss)); }
             catch { continue; }
         }
     }
     else if (mSearchChoice == LInterface.LSearchChoice.QQMusic)
     {
         QQMusicReturn_Song qmrs = LInterface.Deserialize <QQMusicReturn_Song>(LInterface.GetResponse(LInterface.QQMusic_Search(1, mKeyWord), true));
         if (isSeachCanceled)
         {
             return;
         }
         foreach (QMRS_Single qmrss in qmrs.data.song.list)
         {
             if (isSeachCanceled)
             {
                 SearchResultUpdateHandler?.Invoke(null, true); return;
             }
             try { SearchResultUpdateHandler?.Invoke(new LSearchResult(qmrss)); }
             catch { continue; }
         }
     }
     else
     {
         KGMusicReturn_Song kgrs = LInterface.Deserialize <KGMusicReturn_Song>(LInterface.GetResponse(LInterface.KuGouMusic_Search(1, mKeyWord)));
         if (isSeachCanceled)
         {
             return;
         }
         foreach (KGRS_Single kgrss in kgrs.data.info)
         {
             if (isSeachCanceled)
             {
                 SearchResultUpdateHandler?.Invoke(null, true); return;
             }
             try { SearchResultUpdateHandler?.Invoke(new LSearchResult(kgrss)); }
             catch { continue; }
         }
     }
     SearchResultUpdateHandler?.Invoke(null, true);
 }
Exemple #2
0
 /// <summary>
 /// 提供歌词搜索结果,自动搜索专辑封面,歌词,网易版
 /// </summary>
 /// <param name="nerls">网易云歌词搜索结果集合</param>
 public LSearchResult(NERS_Single nerls)
 {
     Src             = LInterface.LSearchChoice.NetEase;
     b_SongName      = nerls.name;
     b_SongArtist    = nerls.artists[0].name;
     b_SongAlbum     = nerls.album.name;
     b_SongDuration  = (nerls.duration / 1000).ToString();
     b_OnlinePlayUrl = new Uri(LInterface.NetEaseMusic_Play(nerls.id));
     QMid            = nerls.id.ToString();
     albumID         = nerls.album.id;
 }
Exemple #3
0
 /// <summary>
 /// 提供歌词搜索结果,自动搜索专辑封面,歌词,QQ版
 /// </summary>
 /// <param name="qmrss">QQ音乐歌词搜索结果</param>
 public LSearchResult(QMRS_Single qmrss)
 {
     Src = LInterface.LSearchChoice.QQMusic;
     // SongID 作为专辑 mid
     b_SongName     = qmrss.songname;
     b_SongAlbum    = qmrss.albumname;
     b_SongDuration = qmrss.interval.ToString();
     b_SongArtist   = qmrss.singer[0].name;
     SongID         = qmrss.albumid;
     QMid           = qmrss.songmid;
     b_PicUrl       = new Uri(LInterface.QQMusic_Album(SongID));
 }
Exemple #4
0
        public void SpecifyAsync(object obj /*callback*/)
        {
            if (Src == LInterface.LSearchChoice.NetEase)
            {
                int SongID = int.Parse(QMid);
                NetEaseReturn_Lyric nerl = LInterface.Deserialize <NetEaseReturn_Lyric>(LInterface.GetResponse(LInterface.NetEaseMusic_Lyric(SongID)));
                b_SongLyric = nerl.lrc.lyric + nerl.tlyric.lyric;
                NetEaseReturn_Download nerd = LInterface.Deserialize <NetEaseReturn_Download>(LInterface.GetResponse(LInterface.NetEaseMusic_Download(SongID)));
                b_FileUrl = new Uri(nerd.data[0].url);
                NetEaseReturn_Pic nerp = LInterface.Deserialize <NetEaseReturn_Pic>(LInterface.GetResponse(LInterface.NetEaseMusic_Album(albumID)));
                b_PicUrl = new Uri(nerp.songs[0].al.picUrl);
            }
            else if (Src == LInterface.LSearchChoice.QQMusic)
            {
                // 获取Token,再获取下载地址
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(LInterface.QQMusic_Token(QMid)));
                req.Headers.Add("Cookie", "skey=@Y3TD47qBo");
                req.Referer = "https://y.qq.com/portal/player.html";
                QQMusicReturn_Token qmrt;
                using (Stream stream = req.GetResponse().GetResponseStream())
                {
                    StreamReader sr = new StreamReader(stream, Encoding.UTF8);
                    qmrt = LInterface.Deserialize <QQMusicReturn_Token>(sr.ReadToEnd());
                    sr.Close();
                    stream.Close();
                }

                b_FileUrl = new Uri(LInterface.QQMusic_Download(QMid, qmrt.data.items[0].vkey));
                //获取歌词
                QQMusicReturn_Lyric qmrl;
                req = (HttpWebRequest)WebRequest.Create(new Uri(LInterface.QQMusic_Token(QMid)));
                req.Headers.Add("Cookie", "skey=@Y3TD47qBo");
                req.Referer = "https://y.qq.com/portal/player.html";
                using (Stream stream = req.GetResponse().GetResponseStream())
                {
                    StreamReader sr = new StreamReader(stream, Encoding.UTF8);
                    qmrl = LInterface.Deserialize <QQMusicReturn_Lyric>(sr.ReadToEnd());
                    sr.Close();
                    stream.Close();
                }
                if (qmrl.lyric == null)
                {
                    b_SongLyric = "";
                }
                else
                {
                    SongLyric = Encoding.UTF8.GetString(Convert.FromBase64String(qmrl.lyric));
                }
                if (qmrl.trans != null)
                {
                    b_SongLyric += Encoding.UTF8.GetString(Convert.FromBase64String(qmrl.trans));
                }
                b_OnlinePlayUrl = new Uri(LInterface.QQMusic_Play(QMid));
            }
            else
            {
                // 取得详细信息
                KGRS_Detail     kgrs;
                CookieContainer cookie = new CookieContainer();
                cookie.Add(new Cookie("kg_mid", LInterface.GetKGMid(), "/", "kugou.com"));
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(LInterface.KuGouMusic_Detail(QMid));
                req.CookieContainer = cookie;
                using (Stream stream = req.GetResponse().GetResponseStream())
                {
                    StreamReader sr = new StreamReader(stream, Encoding.UTF8);
                    kgrs = LInterface.Deserialize <KGRS_Detail>(sr.ReadToEnd());
                    sr.Close(); sr.Dispose();
                }
                b_FileUrl       = new Uri(kgrs.data.play_url);
                b_PicUrl        = new Uri(kgrs.data.img);
                b_OnlinePlayUrl = new Uri(LInterface.KuGouMusic_OnlineAddr(QMid));
                b_SongLyric     = kgrs.data.lyrics;
            }
            ((Action)obj).Invoke();
        }