打开douban.fm
运行js:
function getPropertyCount(obj) { var count = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) { count++; } } return count; } var total = $('#rec_liked').text(); var songs = new Object(); function getSongs(songs){ $.ajax({ url: 'http://douban.fm/j/mine/playlist?type=n&sid=&pt=0.0&channel=-3&from=mainsite&r=f5b061dff2', async: false, dataType: 'json', success: function(data){ for(var i in data['song']){ songs[data['song'][i]['aid']] = {'title':data['song'][i]['title'], 'url':data['song'][i]['url']}; } if(getPropertyCount(songs) < 80){ console.log(getPropertyCount(songs)); getSongs(songs); } } }); }; getSongs(songs); var str = ''; for(var i in songs){ str += songs[i]['title']+'|'+songs[i]['url']+"\n"; } console.log(str);
把输出的字符串写入文本doubanlist,写个shell脚本download处理
#!/bin/bash
cat $1 | while read LINE
do
#echo $LINE | awk -F'|' '{print $1}'
wget -c $(echo $LINE|awk -F'|' '{print $2}') -O "`echo $LINE | awk -F'|' '{print $1".mp3"}'`"
done
然后shell下面: sh download doubanlist 搞定。
等有空看能搞个chrome插件不...
备注:http://douban.fm/j/mine/playlist?type=n&sid=&pt=0.0&channel=-3&from=mainsite&r=f5b061dff2是抓取喜欢列表