/// <summary> /// 方法:下载歌词 /// </summary> /// <param name="singer">歌手</param> /// <param name="title">歌名</param> /// <param name="downloadNow">是否下载</param> /// <returns></returns> public string DownloadLyric(XmlDocument xml) { string retStr = "没有找到该歌词"; if (xml == null) { return(retStr); } XmlNodeList list = xml.SelectNodes("/result/lrc"); if (list.Count > 0) { if (this.currentSong == null) { this.currentSong = list[0]; } } else if (list.Count == 1) { this.currentSong = list[0]; } else { return(retStr); } if (this.currentSong == null) { return(retStr); } XmlNode node = this.currentSong; int lrcId = -1; if (node != null && node.Attributes != null && node.Attributes["id"] != null) { string sLrcId = node.Attributes["id"].Value; if (int.TryParse(sLrcId, out lrcId)) { string xSinger = node.Attributes["artist"].Value; string xTitle = node.Attributes["title"].Value; retStr = RequestALink(string.Format(DownloadPath, lrcId, EncodeHelper.CreateQianQianCode(xSinger, xTitle, lrcId))); } } return(retStr); }
/// <summary> /// 获得有关歌词的xml待下载目录 /// </summary> /// <param name="singer"></param> /// <param name="title"></param> /// <returns></returns> public XmlDocument SearchLyric(string singer, string title) { XmlDocument xml = new XmlDocument(); singer = singer.ToLower().Replace(" ", "").Replace("'", ""); title = title.ToLower().Replace(" ", "").Replace("'", ""); string x = RequestALink(string.Format(SearchPath, EncodeHelper.ToQianQianHexString(singer, Encoding.Unicode), EncodeHelper.ToQianQianHexString(title, Encoding.Unicode))); try { xml.LoadXml(x); XmlNodeList list = xml.SelectNodes("/result/lrc"); OnSelectSong(list); } catch {} return(xml); }