Example #1
0
 /// <summary>
 /// 获取歌词方法
 /// </summary>
 /// <param name="info">歌词基本信息</param>
 /// <returns>歌词内容</returns>
 public string GetLyricContent(MusicLrcInfo info)
 {
     Crawler crawler = new Crawler();
     //ILRCSearch objsearch = lrcSearcher.Find((x) => x.Key.Trim().Equals(objuid.ToString())).Value;
     if (mcc.LRCSearcher.Count < 1)
     {
         return string.Empty;
     }
     //TODO:
     ILRCSearch objsearch = mcc.LRCSearcher[0];
     return crawler.GetMusicLyric(info, objsearch);
 }
Example #2
0
 /// <summary>
 /// 创建歌词的获取地址
 /// </summary>
 /// <param name="info">歌词搜索信息</param>
 /// <returns></returns>
 public string CreateLrcUrl(MusicLrcInfo info)
 {
     try
     {
         //千千静听歌词获取地址
         string TTLrcUrl = "http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?dl?Id={0}&Code={1}&uid=03&mac=002421585787&hds=WD-WMAV22344505";
         return string.Format(TTLrcUrl, new object[] { info.ID, TTEncode.CreateQianQianCode(info.Artist, info.Title, int.Parse(info.ID)) });
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace.ToString());
         return string.Empty;
     }
 }
Example #3
0
        /// <summary>
        /// 获取音乐歌词内容
        /// </summary>
        /// <param name="info">歌词信息的实体类</param>
        /// <param name="objSearch">外部对象</param>
        /// <returns>歌词字符串</returns>
        public string GetMusicLyric(MusicLrcInfo info, ILRCSearch objSearch)
        {
            string _pageHTML;
            int TryTime = 1;
            int tryCount = 0;   // 已重试次数

            // 重复请求页面,如果成功则跳出,失败则根据重试次数重新请求
            while (true)
            {
                // 请求页面,默认芊芊静听直接返回请求的字符串
                NetworkRequest nwr = new NetworkRequest();
                PageRequestResults result = nwr.RequestPage(out _pageHTML, objSearch.CreateLrcUrl(info),objSearch.PageEncode());
                if (result == PageRequestResults.Success)
                {
                    return _pageHTML;
                }
                else
                {
                    // 如果发送或接受失败 ,根据重试次数重发
                    if (tryCount < TryTime)
                    {
                        tryCount++;
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return string.Empty;
        }