public bool Down(string filePath,ref byte[] lrcData,int iThread) { System.Net.ServicePointManager.DefaultConnectionLimit = iThread; string RequestURL = "http://www.cnlyric.com/search.php?k="; string ResponseURL = "http://www.cnlyric.com/"; var m_tools = new NetUtils(); var m_info = new MusicInfo(filePath, 0); string getURL = RequestURL + m_tools.URL_Encoding(m_info.Title, Encoding.GetEncoding("gb2312")) + "&t=s"; string lrcHtml = m_tools.Http_Get(getURL, Encoding.GetEncoding("gb2312")); if (lrcHtml.Equals("")) return false; Regex reg = new Regex(@"LrcDown/\d*/\d*.lrc"); try { string result = reg.Match(lrcHtml).ToString(); if (result.Equals("")) return false; byte[] gb2312Bytes = new WebClient().DownloadData(ResponseURL + result); // 编码统一转换为UTF-8 lrcData = Encoding.Convert(Encoding.GetEncoding("gb2312"), Encoding.UTF8, gb2312Bytes); return true; } catch (Exception exp) { return false; } }
public bool Down(string filePath, ref byte[] lrcData, int iThread) { System.Net.ServicePointManager.DefaultConnectionLimit = iThread; string RequestURL = "http://www.cnlyric.com/search.php?k="; string ResponseURL = "http://www.cnlyric.com/"; var m_tools = new NetUtils(); var m_info = new MusicInfo(filePath, 0); string getURL = RequestURL + m_tools.URL_Encoding(m_info.Title, Encoding.GetEncoding("gb2312")) + "&t=s"; string lrcHtml = m_tools.Http_Get(getURL, Encoding.GetEncoding("gb2312")); if (lrcHtml.Equals("")) { return(false); } Regex reg = new Regex(@"LrcDown/\d*/\d*.lrc"); try { string result = reg.Match(lrcHtml).ToString(); if (result.Equals("")) { return(false); } byte[] gb2312Bytes = new WebClient().DownloadData(ResponseURL + result); // 编码统一转换为UTF-8 lrcData = Encoding.Convert(Encoding.GetEncoding("gb2312"), Encoding.UTF8, gb2312Bytes); return(true); } catch (Exception exp) { return(false); } }