Пример #1
0
        public override string DownloadLyric(SearchSongResultBase song, bool requestTransLyrics = false)
        {
            //没支持翻译歌词的
            if (requestTransLyrics)
            {
                return(string.Empty);
            }

            Uri url = new Uri(string.Format(API_URL, song.ID));

            HttpWebRequest request = WebRequest.CreateHttp(url);

            request.Timeout = Settings.SearchAndDownloadTimeout;

            var response = request.GetResponse();

            string content;

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                content = reader.ReadToEnd();
            }

            JObject obj = JObject.Parse(content);

            if ((int)obj["err_code"] != 0)
            {
                return(null);
            }
            var rawLyric = obj["data"]["lyrics"].ToString();
            var lyrics   = rawLyric.Replace("\r\n", "\n");

            return(lyrics);
        }
Пример #2
0
        public override string DownloadLyric(SearchSongResultBase song, bool requestTransLyrics = false)
        {
            HttpWebRequest request =
                WebRequest.CreateHttp(string.Format(LyricApiUrl, song.ResultId, requestTransLyrics ? "tv=-1" : "lv=1"));

            request.Timeout = Settings.SearchDownloadTimeout;
            var    response   = request.GetResponse();
            Stream respStream = response.GetResponseStream();

            string content;

            if (respStream != null)
            {
                using (var reader = new StreamReader(respStream))
                {
                    content = reader.ReadToEnd();
                }
            }
            else
            {
                throw new NullReferenceException();
            }

            JObject json = JObject.Parse(content);

            return(json[requestTransLyrics ? "tlyric" : "lrc"]["lyric"].ToString());
        }
Пример #3
0
        public override string DownloadLyric(SearchSongResultBase song, bool requestTransLyrics = false)
        {
            string songType = (song as Song)?.type ?? "0";

            Uri            url     = new Uri(string.Format(NewApiUrl, song.ResultId, songType));
            HttpWebRequest request = WebRequest.CreateHttp(url);

            request.Timeout = Settings.SearchDownloadTimeout;
            request.Referer = "https://y.qq.com/portal/player.html";
            request.Headers.Add("Cookie", "skey=@LVJPZmJUX; p");

            var    response   = request.GetResponse();
            Stream respStream = response.GetResponseStream();

            string content;

            if (respStream != null)
            {
                using (var reader = new StreamReader(respStream))
                {
                    content = reader.ReadToEnd();
                }
            }
            else
            {
                throw new NullReferenceException();
            }

            if (content.StartsWith("json("))
            {
                content = content.Remove(0, 5);
            }
            if (content.EndsWith(")"))
            {
                content = content.Remove(content.Length - 1);
            }

            content = System.Web.HttpUtility.HtmlDecode(content);
            JObject json = JObject.Parse(content);

            int result = json["retcode"].ToObject <int>();

            if (result < 0)
            {
                return(null);
            }

            content = json[requestTransLyrics ? "trans" : "lyric"]?.ToString();
            if (string.IsNullOrWhiteSpace(content))
            {
                return(null);
            }

            content = Utils.Base64Decode(content);

            return(content);
        }
        public override string DownloadLyric(SearchSongResultBase song, bool request_trans_lyrics)
        {
            HttpWebRequest request = HttpWebRequest.CreateHttp(string.Format(LYRIC_API_URL, song.ID, request_trans_lyrics ? "tv=-1" : "lv=1"));

            request.Timeout = Setting.SearchAndDownloadTimeout;

            var response = request.GetResponse();

            string content = string.Empty;

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                content = reader.ReadToEnd();
            }

            JObject json = JObject.Parse(content);

            return(json[request_trans_lyrics ? "tlyric" : "lrc"]?["lyric"]?.ToString() ?? string.Empty);
        }
Пример #5
0
        public override string DownloadLyric(SearchSongResultBase song, bool requestTransLyrics = false)
        {
            //没支持翻译歌词的
            if (requestTransLyrics)
            {
                return(string.Empty);
            }

            Uri            url     = new Uri(string.Format(ApiUrl, song.ResultId));
            HttpWebRequest request = WebRequest.CreateHttp(url);

            request.Timeout = Settings.SearchDownloadTimeout;
            var    response   = request.GetResponse();
            Stream respStream = response.GetResponseStream();

            string content;

            if (respStream != null)
            {
                using (var reader = new StreamReader(respStream))
                {
                    content = reader.ReadToEnd();
                }
            }
            else
            {
                throw new NullReferenceException();
            }

            JObject obj = JObject.Parse(content);

            if ((int)obj["err_code"] != 0)
            {
                return(null);
            }
            var rawLyric = obj["data"]["lyrics"].ToString();

            return(rawLyric.Replace("\r\n", "\n"));
        }
Пример #6
0
 public abstract string DownloadLyric(SearchSongResultBase song, bool requestTransLyrics = false);