Example #1
0
        protected override List <SongInfo> GetPlaylist(string id)
        {
            try
            {
                FetchConfig fc = new FetchConfig
                {
                    prot    = "http://",
                    host    = "m.kugou.com",
                    path    = $"/plist/list/{id}?json=true",
                    referer = $"http://m.kugou.com/plist/list/{id}",
                    cookie  = COOKIES
                };
                var response = Fetch(fc);

                var json = JObject.Parse(response);
                return((json.SelectToken("list.list.info") as JArray)?.Select(song =>
                {
                    SongInfo songInfo;
                    try
                    {
                        string[] filename = song["filename"].ToString().Split(new char[3] {
                            ' ', '-', ' '
                        });
                        songInfo = new SongInfo(
                            this,
                            song["hash"].ToString(),
                            filename[0],
                            filename[1].Split('\u3001')
                            );
                        songInfo.SetInfo("albumid", song["album_id"].ToString());
                    }
                    catch (Exception ex)
                    { Log($"歌曲信息获取结果错误(ex:{ex.Message})"); return null; }

                    return songInfo;
                }).ToList());
            }
            catch (Exception ex)
            {
                Log($"歌单下载错误(ex:{ex.Message})");
                return(null);
            }
        }
Example #2
0
        protected override List <SongInfo> GetPlaylist(string id)
        {
            try
            {
                FetchConfig fc = new FetchConfig
                {
                    host    = API_HOST,
                    path    = API_PATH + $"/music-service-c/web/song/of-menu?pn=1&ps=100&sid={id}",
                    referer = API_PROTOCOL + API_HOST + API_PATH,
                    gzip    = true
                };
                var json = JObject.Parse(Fetch(fc));
                return((json.SelectToken("data.data") as JArray)?.Select(song =>
                {
                    SongInfo songInfo;
                    try
                    {
                        songInfo = new SongInfo(
                            this,
                            song["id"].ToString(),
                            song["title"].ToString(),
                            song["author"].ToString().Split(new char[3] {
                            ' ', '·', ' '
                        })
                            );
                        songInfo.SetInfo("referer", API_PROTOCOL + API_HOST + API_PATH);
                    }
                    catch (Exception ex)
                    { Log($"歌曲信息获取结果错误(ex:{ex.Message})"); return null; }

                    return songInfo;
                }).ToList());
            }
            catch (Exception ex)
            {
                Log($"歌单下载错误(ex:{ex.Message})");
                return(null);
            }
        }
Example #3
0
        protected override SongInfo Search(string keyword)
        {
            try
            {
                var response = Fetch(API_PROTOCOL, "songsearch.kugou.com",
                                     $"/song_search_v2?keyword={keyword}&pagesize=1");
                var      json = JObject.Parse(response);
                var      song = json.SelectToken("data.lists[0]");
                SongInfo songInfo;
                songInfo = new SongInfo(
                    this,
                    song["FileHash"].ToString(),
                    song["SongName"].ToString(),
                    song["SingerName"].ToString().Split('\u3001')
                    );
                songInfo.SetInfo("albumid", song["AlbumID"].ToString());
                songInfo.Lyric = GetLyric(songInfo);

                return(songInfo);
            }
            catch (Exception ex)
            { Log($"歌曲信息获取结果错误(ex:{ex.Message})"); return(null); }
        }
Example #4
0
 protected override SongInfo Search(string keyword)
 {
     try
     {
         var response = Fetch(API_PROTOCOL, "api.bilibili.com",
                              API_PATH + $"/music-service-c/s?search_type=audio&page=0&pagesize=1&keyword={keyword}");
         var      json = JObject.Parse(response);
         var      song = json.SelectToken("data.result[0]");
         SongInfo songInfo;
         songInfo = new SongInfo(
             this,
             song["id"].ToString(),
             song["title"].ToString(),
             song["author"].ToString().Split(new char[3] {
             ' ', '·', ' '
         })
             );
         songInfo.Lyric = GetLyric(songInfo);
         songInfo.SetInfo("referer", API_PROTOCOL + API_HOST + API_PATH);
         return(songInfo);
     }
     catch (Exception ex)
     { Log($"歌曲信息获取结果错误:{keyword}(ex:{ex.Message})"); return(null); }
 }