百度音乐api接口

最近正在研究百度音乐的API,上网搜了下,不外乎就是直接抓网页或者是已经用烂的的widget的API:

http://box.zhangmen.baidu.com/x?op=12&count=1&title=大约在冬季$$齐秦$$$$ 

这东东输出的是一堆xml,而且结果也就那么四五条,觉得不实用,所以我打算研究下别的

用fiddler2抓了下网页版的百度音乐盒。。尼玛一堆的gif,css,js什么的,找不到什么有价值的url

后来我下了百度音乐电脑版的客户端,搜索一下音乐。。结果发现搜索界面也特么是html。。。不爽ing

想了许久,我看着桌上的手机,灵机一动~~诶,抓百度音乐的手机版会不会更方便些呢,手机为了省流量的话发出去的请求应该会少很多,也比较好找

说干就干,于是我下了百度音乐的安卓客户端,然后连接WiFi,把电脑的ip设成代理服务器,于是fiddler2上便出现了手机发出的http请求

果然,收获还是大大滴~~~

其实就是一个网址:

http://tingapi.ting.baidu.com/v1/restserver/ting

它全部都是用get请求实现的,后面加不同参数可以实现不同的功能,下面把我抓到的一一介绍(仅供学习交流,请勿用于商业用途):

1.根据关键词返回接近的结果

http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=4.9.2.0&method=baidu.ting.search.catalogSug&format=json&query=小苹果

然后它会给你个json出来,query参数的值不同他的结果不同,有这个songid你就可以在百度音乐找到地址啦

    {
    "song": [
        {
            "songid": "120125029",
            "songname": "小苹果",
            "artistname": "筷子兄弟"
        },
        {
            "songid": "121098102",
            "songname": "小苹果",
            "artistname": "回音哥"
        },
        {
            "songid": "85762160",
            "songname": "小苹果 - 每当唱起这首歌",
            "artistname": "王媛媛"
        },
        {
            "songid": "67368864",
            "songname": "小苹果",
            "artistname": "铃声"
        },
        {
            "songid": "85762158",
            "songname": "小苹果 手风琴曲",
            "artistname": "佚名"
        },
        {
            "songid": "85713017",
            "songname": "小苹果树请医生",
            "artistname": "儿童故事"
        },
           {
            "songid": "35408612",
            "songname": "小苹果树请医生",
            "artistname": "佚名"
        }
    ],
    "artist": [],
    "album": [],
    "order": "song",
    "error_code": 22000
}

2.根据歌曲名和歌手名搜索歌曲

http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=4.9.2.0&method=baidu.ting.search.merge&format=json&query=小苹果-筷子兄弟

同样会有个json,而且里面有歌词的链接哦:

{
"error_code": 22000,
"result": {
    "query": "小苹果-筷子兄弟",
    "syn_words": "",
    "rqt_type": 1,
    "song_info": {
        "total": 1,
        "song_list": [
            {
                "content": "",
                "copy_type": "1",
                "toneid": "0",
                "info": "电影《老男孩之猛龙过江》2014插曲",
                "all_rate": "64,128,192,256,320,flac",
                "resource_type": 0,
                "relate_status": 0,
                "has_mv_mobile": 1,
                "song_id": "120125029",
                "title": "小苹果",
                "ting_uid": "9295",
                "author": "筷子兄弟",
                "album_id": "121556956",
                "album_title": "老男孩之猛龙过江 电影原声",
                "is_first_publish": 0,
                "havehigh": 2,
                "charge": 0,
                "has_mv": 1,
                "learn": 1,
                "song_source": "",
                "piao_id": "0",
                "korean_bb_song": "",
                "resource_type_ext": "",
                "artist_id": "57520",
                "all_artist_id": "57520",
                "lrclink": "http://musicdata.baidu.com/data2/lrc/121017633/%E5%B0%8F%E8%8B%B9%E6%9E%9C.lrc",
                "data_source": 0,
                "cluster_id": 0
            }
        ]
    }
}
}

3.通过id获取地址歌词和图片

这个不是客户端抓的。。似乎那个API关于歌词图片下载地址的接口得参数都有加密

http://ting.baidu.com/data/music/links?songIds=120125029

还是json:

{
"errorCode": 22000,
"data": {
    "xcode": "963cc26c0c0fdd6cb639b3d1b2fa946c",
    "songList": [
        {
            "queryId": "120125029",
            "songId": 120125029,
            "songName": "小苹果",
            "artistId": "9295",
            "artistName": "筷子兄弟",
            "albumId": 121556956,
            "albumName": "老男孩之猛龙过江 电影原声",
            "songPicSmall": "http://a.hiphotos.baidu.com/ting/pic/item/32fa828ba61ea8d3a59619cd950a304e241f5846.jpg",
            "songPicBig": "http://b.hiphotos.baidu.com/ting/pic/item/dc54564e9258d109f857c47bd358ccbf6d814d46.jpg",
            "songPicRadio": "http://c.hiphotos.baidu.com/ting/pic/item/e4dde71190ef76c6966696e29f16fdfaae516746.jpg",
            "lrcLink": "/data2/lrc/121017633/121017633.lrc",
            "version": "",
            "copyType": 1,
            "time": 211,
            "linkCode": 22000,
            "songLink": "http://zhangmenshiting.baidu.com/data2/music/121859589/1201250291407038461.mp3?xcode=963cc26c0c0fdd6cd95227c58110eada88aca43f4cfb1c02",
            "showLink": "http://zhangmenshiting.baidu.com/data2/music/121859589/1201250291407038461.mp3?xcode=963cc26c0c0fdd6cd95227c58110eada88aca43f4cfb1c02",
            "format": "mp3",
            "rate": 128,
            "size": 3394555,
            "relateStatus": "0",
            "resourceType": "0"
        }
    ]
}
}

目前能用的就是这么多,应该可以弄一个微信点歌了^_^ ,等我把百度音乐的加密搞出来的话我会继续更新的~~~

希望这些东西对那些想做在线音乐的朋友们有帮助吧

已有 4 条评论
  1. 搞出来我也要用

添加新评论