Saturday, 14 July 2012

Manually download baidu song on API way

Manually download baidu song on API way:
1. Open
http://box.zhangmen.baidu.com/dev/api/?tn=gls&titles=poker+face%24%24lady+gaga&callback=jsonplink1342282653123&r=0.02055948238744856 
, "titles=" change to song title, %24%24 also means $$, the next is singer name.
, if it doesn't work, r= should change to any random number, jsonplink's 1342282653123  can change to current javascript UNIX timestamp. The javascript UNIX timestamp can get via alert(new Date().getTime()). Or as a bash way, command "date +%s" and append any 3 digits. Or as a python geek, using "{0:.0f}".format(time.time()*1000)

2: then we would got something like "

jsonplink1342282653123({"errorCode":"0","data":{"songList":[[{"songID":"0","songName":"poker face",
"artistName":"lady gaga","albumID":"0","albumName":"","lrcLink":"http:\/\/zhangmenshiting.baidu.com\
/data2\/lrc\/598626\/598626.lrc","version":"","copy_type":"0","time":"218","songFileId":"","linkCode":
"0","songLink":"http:\/\/zhangmenshiting.baidu.com\/data2\/music\/12758910\/12758910.mp3",
"songShowLink":"","format":"mp3","rate":"64","size":"1677721","copyRight":"4","LRCID":"598626"},
{"songID":"0","songName":"poker face","artistName":"lady gaga","albumID":"0","albumName":"","lrcLink":
"http:\/\/zhangmenshiting.baidu.com\/data2\/lrc\/598626\/598626.lrc","version":"","copy_type":"0",
"time":"","songFileId":"","linkCode":"0","songLink":"http:\/\/mbsky.com.cn\/music\/MUSIC.mp3",
"songShowLink":"","format":"mp3","rate":"","size":"6291456","copyRight":"0","LRCID":"598626"},
{"songID":"0","songName":"poker face","artistName":"lady gaga","albumID":"0","albumName":"","lrcLink":
"http:\/\/zhangmenshiting.baidu.com\/data2\/lrc\/598626\/598626.lrc","version":"","copy_type":"0",
"time":"","songFileId":"","linkCode":"0","songLink":"http:\/\/m2.megalyrics.ru\/m21\/a1\/32726\/335148.mp3",
"songShowLink":"","format":"mp3","rate":"","size":"6291456","copyRight":"0","LRCID":"598626"},{"songID":"0",
"songName":"poker face","artistName":"lady gaga","albumID":"0","albumName":"","lrcLink":
"http:\/\/zhangmenshiting.baidu.com\/data2\/lrc\/598626\/598626.lrc","version":"","copy_type":"0","time":"",
"songFileId":"","linkCode":"0","songLink":"http:\/\/www.naizuud.com\/file\/music_folder\/224.mp3?
stdfrom=3width=1","songShowLink":"","format":"mp3","rate":"","size":"6291456","copyRight":"0","LRCID":
"598626"},{"songID":"0","songName":"poker face","artistName":"lady gaga","albumID":"0","albumName":"",
"lrcLink":"http:\/\/zhangmenshiting.baidu.com\/data2\/lrc\/598626\/598626.lrc","version":"","copy_type":"0",
"time":"","songFileId":"","linkCode":"0","songLink":
"http:\/\/s53253wl1b.wo99.com:8080\/userdir_2297\/4102476\/wo99.com_1328160486252310.mp3","songShowLink":"",
"format":"mp3","rate":"","size":"3145728","copyRight":"0","LRCID":"598626"}]],"p2p":[{"p2pSign":
"f377b0d332c097f32d0d69e3980ba820e7a3fe59","url":
"http:\/\/zhangmenshiting.baidu.com\/data2\/music\/3653665\/3653665.mp3?xcode=013740723af1edfcb033f115eaff28df",
"attr":"4294967295","duration":"238","cat":"0","size":"3893155","bitrate":"128","album_sign1":"4286053527",
"album_sign2":"3070126863","p2p_quku_id":"2914890","p2p_file_id":"3653665","unused1":"0","unused2":"0",
"unused3":"0"}],"xcode":"013740723af1edfcb033f115eaff28df"}})
"


, extract the .mp3, .wma,..whatever make sense song extension. example
"http:\/\/zhangmenshiting.baidu.com\/data2\/music\/10324364\/10324364.mp3"
, remove the back slash "\"
, become http://zhangmenshiting.baidu.com/data2/music/10324364/10324364.mp3

3. Try to download it, if no response or server error, extract "xcode=" value on the end of content we got just now,
"xcode":"013740723af1edfcb033f115eaff28df"}})
become http://zhangmenshiting.baidu.com/data2/music/10324364/10324364.mp3?xcode=013740723af1edfcb033f115eaff28df
Try download it again. Above url and xcode is example only. Normally the xcode would expired.
 
Chinese song example, http://box.zhangmen.baidu.com/dev/api/?tn=gls&titles=%E5%9C%A8%E5%8A%A8%E7%89%A9%E5%9B%AD%E6%95%A3%E6%AD%A5%E6%89%8D%E6%98%AF%E6%AD%A3%E7%BB%8F%E4%BA%8B%24%24my+little+airport&callback=jsonplink1335160684820&r=0.020559488740344856
or just http://box.zhangmen.baidu.com/dev/api/?tn=gls&titles=在动物园散步才是正经事%24%24my+little+airport&callback=jsonplink1335160684820&r=0.020559488740344856
Unknown singer example, portal song, http://box.zhangmen.baidu.com/dev/api/?tn=gls&titles=still+alive$$&callback=jsonplink1335160684820&r=0.020559488740344856
First blog to mention it:)
 

No comments:

Post a Comment