千千静听的歌词服务器地址是哪个?

如题... 如题 展开
 我来答
缘幸福462
2015-10-06 · TA获得超过7942个赞
知道小有建树答主
回答量:906
采纳率:0%
帮助的人:328万
展开全部
最近想做一个音乐播放器,播放器需要显示歌词,这就需要到网上下载歌词。花了两个晚上搞了一个歌词下载类,通过歌名和歌手算出响应代码到千千静听服务器下载
具体流程如下:
1、通过歌名 Title 和 歌手 Artist ,计算出歌词下载列表地址
  先把Title和Artist转换为十六进制,带入下面服务器地址
  歌词Id获取地址:http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?sh?Artist={0}&Title={1}&Flags=0"
  然后连接到地址,得到一个Xml文件,可以得到歌词的下载Id
2、通过 Id 和 Title 和 Artist 算出相应的Code,具体看代码(参考自网上)
  歌词下载服务器地址:http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?dl?Id={0}&Code={1}

下面是代码
  定义两个类:LyricsHelper(辅助获取歌词Id)LrcInfo(歌词下载相应信息)

public class LyricsHelper
{
//歌词Id获取地址
private static readonly string SearchPath = "http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?sh?Artist={0}&Title={1}&Flags=0";

//根据artist和title获取歌词信息
public static LrcInfo[] GetLrcList(string artist, string title, string filepath)
{
string artistHex = GetHexString(artist, Encoding.Unicode);
string titleHex = GetHexString(title, Encoding.Unicode);

string resultUrl = string.Format(SearchPath, artistHex, titleHex);

XmlDocument doc = new XmlDocument();
try
{
doc.Load(resultUrl);

XmlNodeList nodelist = doc.SelectNodes("/result/lrc");
List<LrcInfo> lrclist = new List<LrcInfo>();
foreach (XmlNode node in nodelist)
{
XmlElement element = (XmlElement)node;
string artistItem = element.GetAttribute("artist");
string titleItem = element.GetAttribute("title");
string idItem = element.GetAttribute("id");
lrclist.Add(new LrcInfo(idItem, titleItem, artistItem, filepath));
}
return lrclist.ToArray();
}
catch (XmlException)
{
return null;
}
}

//把字符串转换为十六进制
public static string GetHexString(string str, Encoding encoding)
{
StringBuilder sb = new StringBuilder();
byte[] bytes = encoding.GetBytes(str);
foreach (byte b in bytes)
{
sb.Append(b.ToString("X").PadLeft(2, '0'));
}
return sb.ToString();
}
}

public class LrcInfo
{
//歌词下载地址
private static readonly string DownloadPath = "http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?dl?Id={0}&Code={1}";

public string FilePath { get; set; }
public string Id { get; set; }
public string Artist { get; set; }
public string Title { get; set; }
public string LrcUri { get; set; }

public LrcInfo(string id, string title, string artist, string filepath)
{
this.FilePath = filepath;
this.Id = id.Trim();
this.Title = title;
this.Artist = artist;
//算出歌词的下载地址
this.LrcUri = string.Format(DownloadPath, Id, CreateQianQianCode());
}
public bool DownloadLrc()
{
string file = FilePath;
string directory = Path.GetDirectoryName(file) + "\\Lrc\\";
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
string filepath = directory + Path.GetFileNameWithoutExtension(file) + ".lrc";
WebRequest request = WebRequest.Create(LrcUri);

StringBuilder sb = new StringBuilder();
try
{
using (StreamReader sr = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.UTF8))
{
using (StreamWriter sw = new StreamWriter(filepath, false, Encoding.UTF8))
{
sw.Write(sr.ReadToEnd());
}
}
return true;
}
catch (WebException)
{

}
return false;
}

private string CreateQianQianCode()
{
int lrcId = Convert.ToInt32(Id);
string qqHexStr = LyricsHelper.GetHexString(Artist + Title, Encoding.UTF8);
int length = qqHexStr.Length / 2;
int[] song = new int[length];
for (int i = 0; i < length; i++)
{
song[i] = int.Parse(qqHexStr.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
}
int t1 = 0, t2 = 0, t3 = 0;
t1 = (lrcId & 0x0000FF00) >> 8;
if ((lrcId & 0x00FF0000) == 0)
{
t3 = 0x000000FF & ~t1;
}
else
{
t3 = 0x000000FF & ((lrcId & 0x00FF0000) >> 16);
}

t3 = t3 | ((0x000000FF & lrcId) << 8);
t3 = t3 << 8;
t3 = t3 | (0x000000FF & t1);
t3 = t3 << 8;
if ((lrcId & 0xFF000000) == 0)
{
t3 = t3 | (0x000000FF & (~lrcId));
}
else
{
t3 = t3 | (0x000000FF & (lrcId >> 24));
}

int j = length - 1;
while (j >= 0)
{
int c = song[j];
if (c >= 0x80) c = c - 0x100;

t1 = (int)((c + t2) & 0x00000000FFFFFFFF);
t2 = (int)((t2 << (j % 2 + 4)) & 0x00000000FFFFFFFF);
t2 = (int)((t1 + t2) & 0x00000000FFFFFFFF);
j -= 1;
}
j = 0;
t1 = 0;
while (j <= length - 1)
{
int c = song[j];
if (c >= 128) c = c - 256;
int t4 = (int)((c + t1) & 0x00000000FFFFFFFF);
t1 = (int)((t1 << (j % 2 + 3)) & 0x00000000FFFFFFFF);
t1 = (int)((t1 + t4) & 0x00000000FFFFFFFF);
j += 1;
}

int t5 = (int)Conv(t2 ^ t3);
t5 = (int)Conv(t5 + (t1 | lrcId));
t5 = (int)Conv(t5 * (t1 | t3));
t5 = (int)Conv(t5 * (t2 ^ lrcId));

long t6 = (long)t5;
if (t6 > 2147483648)
t5 = (int)(t6 - 4294967296);
return t5.ToString();
}
private long Conv(int i)
{
long r = i % 4294967296;
if (i >= 0 && r > 2147483648)
r = r - 4294967296;

if (i < 0 && r < 2147483648)
r = r + 4294967296;
return r;
}

}
匿名用户
2013-08-02
展开全部
根据ID以及CODE去下面的地址获取歌词。   http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?dl?Id={0}&Code={1}  {0}:ID  {1}:CODE
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2013-08-02
展开全部
搜索失败的原因可能有以下几个:
1. 你安装了什么防火墙之类的软件,当千千静听去网上搜歌词的时候你的防火墙阻止了它.如果是这样的话你可以在防火墙中设置一下使千千静听可以访问网络..
2. 你掉线了,或者网速太差..检查下你的网络...
3. 当时千千静听歌词服务器限制你的访问,原因也许是访问量过大导致的服务器崩溃....这种情况的话要么你等待,要么就换个歌词服务器,歌词服务器有很多,你可以自己去搜~
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式