iScript
iScript copied to clipboard
希望虾米下载添加一个列表输入
在def main(argv):方法中加入
elif comd == 'dd':
x = xiami()
x.init();
for url in xxx:
url_list = open(url, 'r');
x.url_parser(url_list)
[root@localhost root]#xiami.py dd taskurl
taskurl 文件里面每行输入一个url
下面的脚本可以实现你想要的功能
#!/bin/bash
# filename xmd.sh
while IFS='' read -r line || [[ -n "$line" ]]; do
python2 path/to/xiami.py d "$line"
done < "$1"
用法
./xmd.sh taskfile
一、我增加了下面这个命令,可以实现多链接下载 使用:xiami.py dd taskurl.txt taskurl.txt里面每一行保存一个url elif comd == 'dd': x = xiami() x.init(); for url in xxx: url_list = open(url, 'r'); x.url_parser(url_list)
二、有时精选集里面会有大于50首的歌,可以这么做 url_collect_json = "http://www.xiami.com/collect/ajax-get-list?_=0&id=%s&p=%s&limit=50"
def get_complete_songs_list(self): html = ss.get(url_collect_json % (self.collect_id, 1)).text rawdata = json.loads(html) total_page = rawdata["result"]["total_page"]; total_songs_list = []; self.get_complete_songs_list_flag = 0; if total_page > 0: self.get_complete_songs_list_flag = 1; print("========================") for i in xrange(total_page): print("+++++++++++++++") print i; html_c = ss.get(url_collect_json % (self.collect_id, i+1)).text rawdata_c = json.loads(html_c) for k in rawdata_c["result"]["data"]: total_songs_list.append(k["song_id"]); # print(rawdata)
return (total_songs_list)
在 2016-03-23 10:11:37,"PeterDing" [email protected] 写道:
下面的脚本可以实现你想要的功能
#!/bin/bashwhile IFS=''read -r line || [[ -n"$line" ]];do python2 path/to/xiami.py d "$line"done<"$1"
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub