예제 #1
0
        static void _GetMusicList(string ids)
        {
            List <Json.MusicInfo> ret = new List <Json.MusicInfo>();
            TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
            string   _u = ApiUrl + "song/detail?ids=" + ids;
            string   j  = GetHTML(_u);

            Json.MusicDetails.Root mdr = JsonConvert.DeserializeObject <Json.MusicDetails.Root>(j);
            string u = ApiUrl + "song/url?id=" + ids + "&br=" + Setting.DownloadQuality;

            Json.GetUrl.Root urls = JsonConvert.DeserializeObject <Json.GetUrl.Root>(GetHTML(u));
            for (int i = 0; i < mdr.songs.Count; i++)
            {
                string        singer   = "";
                List <string> singerid = new List <string>();
                string        _url     = "";

                for (int x = 0; x < mdr.songs[i].ar.Count; x++)
                {
                    singer += mdr.songs[i].ar[x].name + "、";
                    singerid.Add(mdr.songs[i].ar[x].id.ToString());
                }

                for (int x = 0; x < urls.data.Count; x++)
                {
                    if (urls.data[x].id == mdr.songs[i].id)
                    {
                        _url = urls.data[x].url;
                    }
                }

                Json.MusicInfo mi = new Json.MusicInfo()
                {
                    Album    = mdr.songs[i].al.name,
                    AlbumId  = mdr.songs[i].al.id,
                    Id       = mdr.songs[i].id,
                    LrcUrl   = ApiUrl + "lyric?id=" + mdr.songs[i].id,
                    PicUrl   = mdr.songs[i].al.picUrl,
                    Singer   = singer.Substring(0, singer.Length - 1),
                    SingerId = singerid,
                    Song     = mdr.songs[i].name,
                    Url      = _url,
                    MvUrl    = ApiUrl + "mv/url?id=" + mdr.songs[i].mv.ToString()
                };
                ret.Add(mi);
            }
            SearchResult.AddRange(ret);
        }
예제 #2
0
        static List <Json.MusicInfo> Search(string Key, int Page = 1, int limit = 100)
        {
            if (Key == null || Key == "")
            {
                return(null);
            }
            WebClient wc     = new WebClient();
            string    offset = ((Page - 1) * 100).ToString();
            string    url    = ApiUrl + "search?keywords=" + Key + "&limit=" + limit.ToString() + "&offset=" + offset;
            string    json   = GetHTML(url);

            if (json == null || json == "")
            {
                return(null);
            }
            Json.SearchResultJson.Root srj = JsonConvert.DeserializeObject <Json.SearchResultJson.Root>(json);
            List <Json.MusicInfo>      ret = new List <Json.MusicInfo>();
            string ids = "";

            for (int i = 0; i < srj.result.songs.Count; i++)
            {
                ids += srj.result.songs[i].id + ",";
            }
            string _u = ApiUrl + "song/detail?ids=" + ids.Substring(0, ids.Length - 1);
            string j  = GetHTML(_u);

            Json.MusicDetails.Root mdr = JsonConvert.DeserializeObject <Json.MusicDetails.Root>(j);
            string u = ApiUrl + "song/url?id=" + ids.Substring(0, ids.Length - 1) + "&br=" + Setting.DownloadQuality;

            Json.GetUrl.Root urls = JsonConvert.DeserializeObject <Json.GetUrl.Root>(GetHTML(u));

            for (int i = 0; i < mdr.songs.Count; i++)
            {
                string        singer   = "";
                List <string> singerid = new List <string>();
                string        _url     = "";

                for (int x = 0; x < mdr.songs[i].ar.Count; x++)
                {
                    singer += mdr.songs[i].ar[x].name + "、";
                    singerid.Add(mdr.songs[i].ar[x].id.ToString());
                }

                for (int x = 0; x < urls.data.Count; x++)
                {
                    if (urls.data[x].id == mdr.songs[i].id)
                    {
                        _url = urls.data[x].url;
                    }
                }

                Json.MusicInfo mi = new Json.MusicInfo()
                {
                    Album    = mdr.songs[i].al.name,
                    AlbumId  = mdr.songs[i].al.id,
                    Id       = mdr.songs[i].id,
                    LrcUrl   = ApiUrl + "lyric?id=" + mdr.songs[i].id,
                    PicUrl   = mdr.songs[i].al.picUrl,
                    Singer   = singer.Substring(0, singer.Length - 1),
                    SingerId = singerid,
                    Song     = mdr.songs[i].name,
                    Url      = _url,
                    MvUrl    = ApiUrl + "mv/url?id=" + mdr.songs[i].mv.ToString()
                };
                ret.Add(mi);
            }
            return(ret);
        }