网站建设 郑州网站建设 网站制作 网页设计 网站设计 郑州建网站 - 爱易在线

网站地图 | 网站Tags标签 | RSS订阅 | 加入收藏
您的位置:网站首页 > 博客笔记 > 技术交流 > 正文 技术交流相关信息

C#解密虾米的location为真实地址

作者:郑州网站建设 2013/10/15 22:12:34 点击: 来源:

获取虾米包含真实文件的地址,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

 

 

 

 

 

 

 

Tag:C#
分享到:

上一篇:php用Curl的post方法只获取header头信息中的Location

下一篇:Global.asax 没有 Global.asax.cs 问题解决

技术交流推荐阅读

用户评论

最新博文

热门排行

推荐信息

关于爱之易| 付款方式| 联系我们| 网站地图| 网站Tags标签 | RSS订阅