获取虾米包含真实文件的地址,GET获取单曲:http://www.xiami.com/song/playlist/id/1769816970
红色的部分是歌曲ID,get后得到xml格式的数据,其中的location的值就是真实的下载地址,通过下面的代码转换即可得到真实地址。
C#版:
/// <summary> /// 转换虾米的加密location /// </summary> /// <param name="str">虾米location加密地址</param> /// <returns>真实song地址</returns> private string getXiaMiUrl(string str) { double rowNum = Convert.ToDouble(str.Substring(0, 1)); string newStr = str.Substring(1, str.Length - 1); double remainder = newStr.Length % rowNum; double colsNum = Math.Ceiling(Convert.ToDouble(newStr.Length / rowNum)); string str2 = newStr.Substring(Convert.ToInt32(remainder * colsNum), newStr.Length - Convert.ToInt32(remainder * colsNum)); string result = ""; for (int k = 0; k < colsNum; k++) { for (int i = k; i < newStr.Length; i = i + Convert.ToInt32(colsNum)) { if (i <= newStr.Length - 1 && i < Convert.ToInt32(remainder * colsNum)) { result = result + newStr.Substring(i, i + 1 - i); } } if (k < colsNum - 1) { for (int i = k; i < str2.Length; i = i + Convert.ToInt32(colsNum) - 1) { if (i <= str2.Length - 1) { result = result + str2.Substring(i, i + 1 - i); } } } } result = HttpUtility.UrlDecode(result).Replace("^", "0"); return result; }
获取精选集:
get:http://www.xiami.com/song/playlist/id/16468269/type/3
红色部分是精选集id。后边的红色3是typeID
上面获取到的都是已加密的地址,下面的是获取未加密的地址
获取未加密的单曲地址:
GET:http://www.xiami.com/app/iphone/song/id/1769816970