view plaincopy to clipboardPRint? using System; using System.Collections.Generic; using System.Text;
namespace QianQianLrc { public class EncodeHelper { public static string ToQianQianHexString(string s, Encoding encoding) { StringBuilder sb = new StringBuilder(); byte[] bytes = encoding.GetBytes(s); foreach (byte b in bytes) { sb.Append(b.ToString("X").PadLeft(2, '0')); } return sb.ToString(); }
public static string CreateQianQianCode(string singer, string title, int lrcId) { string QQHexStr = ToQianQianHexString(singer + 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;
long t6 = (long)t5; if (t6 > 2147483648) t5 = (int)(t6 - 4294967296); return t5.ToString(); }
public static 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; } } } using System; using System.Collections.Generic; using System.Text;
namespace QianQianLrc { public class EncodeHelper { public static string ToQianQianHexString(string s, Encoding encoding) { StringBuilder sb = new StringBuilder(); byte[] bytes = encoding.GetBytes(s); foreach (byte b in bytes) { sb.Append(b.ToString("X").PadLeft(2, '0')); } return sb.ToString(); }
public static string CreateQianQianCode(string singer, string title, int lrcId) { string qqHexStr = ToQianQianHexString(singer + 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;
long t6 = (long)t5; if (t6 > 2147483648) t5 = (int)(t6 - 4294967296); return t5.ToString(); }
public static 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; } } }
QianQianLrcer.cs:---这个类负责请求歌词:
view plaincopy to clipboardprint? using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO; using System.xml; using System.Windows.Forms; using System.Collections;
namespace QianQianLrc { public class QianQianLrcer {
public static readonly string SearchPath = "http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?sh?Artist={0}&Title={1}&Flags=0"; public static readonly string DownloadPath = "http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?dl?Id={0}&Code={1}";
public static ArrayList listSongs = new ArrayList();
public static searchState sState = searchState.none; public enum searchState { none=1,begin , loading , complete};
public void DownLoadLrc2(string singer, string title, int lrcId) { string sURL = string.Format(DownloadPath, lrcId, EncodeHelper.CreateQianQianCode(singer, title, lrcId));
public class SongBase { public SongBase(int id,string artist,string title) { this.id = id; this.artist = artist; this.title = title; } private int id; private string artist; private string title;
public string Title { get { return title; } set { title = value; } }
public string Artist { get { return artist; } set { artist = value; } }
public int Id { get { return id; } set { id = value; } }
} } using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO; using System.Xml; using System.Windows.Forms; using System.Collections;
namespace QianQianLrc { public class QianQianLrcer {
public static readonly string SearchPath = "http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?sh?Artist={0}&Title={1}&Flags=0"; public static readonly string DownloadPath = "http://ttlrcct2.qianqian.com/dll/lyricsvr.dll?dl?Id={0}&Code={1}";
public static ArrayList listSongs = new ArrayList();
public static searchState sState = searchState.none; public enum searchState { none=1,begin , loading , complete};
public void DownLoadLrc2(string singer, string title, int lrcId) { string sURL = string.Format(DownloadPath, lrcId, EncodeHelper.CreateQianQianCode(singer, title, lrcId));