分页: 2 / 2

Re: linux 下载音乐脚本(正式版)

发表于 : 2009-09-26 11:58
leoonline
已经使用vim查出file的编码是latin1,上面问题已经解决,但url,和url_1的匹配又出现问题,bash -x调试输出如下:
leo@leo-laptop:/opt/app_shell$ bash -x down.sh
++ which axel
+ e=/usr/bin/axel
++ which mid3v2
+ e_1=/usr/bin/mid3v2
+ '[' -x /usr/bin/axel ']'
+ echo '检测到你已经安装了axel 将会成为你默认的下载工具'
检测到你已经安装了axel 将会成为你默认的下载工具
+ '[' -x /usr/bin/mid3v2 ']'
+ echo $'\346\243\200\346\265\213\345\210\260mid3v2\344\274\232\346\212\212\344\275\240\351\237\263\344\271\220\347\232\204tag\351\203\275\345\210\240\351\231\244\346\216\211,\351\242\204\351\230\262\345\207\272\347\216\260\344\271\261\347\240\201'
检测到mid3v2会把你音乐的tag都删除掉,预防出现乱码
+ read -p $'\350\257\267\350\276\223\345\205\245\344\275\240\350\246\201\346\220\234\347\264\242\347\232\204\351\237\263\344\271\220:' a
请输入你要搜索的音乐:爱
+ echo $'\347\210\261'
+ iconv -f utf8 -t gb2312 down.file
++ od -t x1 down.file1
++ awk 'BEGIN{OFS="%"}{$1=""}NF'
+ b=%b0%ae%0a
+ wget 'http://mp3.baidu.com/m?f=ms&tn=baidump3 ... e%0a&lm=-1' -O file
--2009-09-26 11:30:06-- http://mp3.baidu.com/m?f=ms&tn=baidump3 ... e%0a&lm=-1
正在解析主机 mp3.baidu.com... 220.181.43.121
正在连接 mp3.baidu.com|220.181.43.121|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 未指定 [text/html]
保存到‘file’

[ <=> ] 79,050 17.7K/s in 4.4s

2009-09-26 11:30:12 (17.7 KB/s) - `file' 被保存 [79050]

+ iconv -f latin1 -t utf8 file
+ grep -m 5 'M</td>'
+ awk '-F>' '{print $2}'
+ awk '-F<' '{print $1} '
+ iconv -f latin1 -t utf8 file
+ grep -m 5 '<td class=d><a href='
+ awk -F, '{print $2}'
+ awk '-F&' '{print $1}'
+ awk '{a[NR]=$0}END{for(i=1;i<=NR/2;i++)printf "(%d)\t%s\t%s\n",i,a,a[i+NR/2]}' size
(1) 4.2 M http://www.lzlhll.cn/music/ZWcz.mp3
(2) 4.2 M http://www.htgq.gov.cn/jfz/upload_file/ ... VqNQ$$.mp3
(3) 4.2 M http://219.159.196.124:8080/xuekehome/s ... GpmTU$.mp3
(4) 4.2 M HTTP://baobao.qq.com/data/k5OilpallmljZ ... RoaTY$.mp3
(5) 1.6 M http://www.cp007.com/yule/UploadFiles_2 ... xsamEy.wma
+ read -p $'\350\257\267\351\200\211\346\213\251\344\275\240\350\246\201\344\270\213\350\275\275\347\254\254\345\207\240\351\246\226:' c
请选择你要下载第几首:1
+ iconv -f latin1 -t utf8 file
+ grep -m 1 '<td class=d><a href='
+ sed -n p song
+ awk -F, '{print $2}'
+ awk '-F&' '{print $1}'
+ iconv -f utf8 -t gb2312 song_1
++ od -t x1 down.file3
++ awk 'BEGIN{OFS="%"}{$1=""}NF'
++ awk -F%0a '{print $1}'
+ url='%68%74%74%70%3a%2f%2f%77%77%77%2e%6c%7a%6c%68%6c
%6c%2e%63%6e%2f%6d%75%73%69%63%2f%5a%57%63%7a%2e
%6d%70%33'
++ iconv -f latin1 -t utf8 file
++ grep -m 1 '<td classs=d><a href='
++ cut -d, -f2
+ url_1=
+ echo %68%74%74%70%3a%2f%2f%77%77%77%2e%6c%7a%6c%68%6c %6c%2e%63%6e%2f%6d%75%73%69%63%2f%5a%57%63%7a%2e %6d%70%33
%68%74%74%70%3a%2f%2f%77%77%77%2e%6c%7a%6c%68%6c %6c%2e%63%6e%2f%6d%75%73%69%63%2f%5a%57%63%7a%2e %6d%70%33
+ echo

+ echo

+ echo

+ wget '' -O file_1
http://: 非法主机名称.
+ iconv -f latin1 -t utf8 file_1
+ grep -m 1 '<a href'
+ awk '-F"' '{print $2}'
++ cat down.file4
+ h=
+ '[' -x /usr/bin/axel ']'
+ axel -n 10 -o $'\347\210\261.mp3'
Usage: axel [options] url1 [url2] [url...]

--max-speed=x -s x Specify maximum speed (bytes per second)
--num-connections=x -n x Specify maximum number of connections
--output=f -o f Specify local output file
--search[=x] -S [x] Search for mirrors and download from x servers
--header=x -H x Add header string
--user-agent=x -U x Set user agent
--no-proxy -N Just don't use any proxy server
--quiet -q Leave stdout alone
--verbose -v More status information
--alternate -a Alternate progress indicator
--help -h This information
--version -V Version information

Report bugs to [email protected] (using reportbug)
+ '[' -x /usr/bin/mid3v2 ']'
+ mid3v2 -D $'\347\210\261.mp3'
deleting ID3 tag info in 爱.mp3
Traceback (most recent call last):
File "/usr/bin/mid3v2", line 219, in <module>
main(sys.argv)
File "/usr/bin/mid3v2", line 209, in main
delete_tags(args, "v1" in options.action, "v2" in options.action)
File "/usr/bin/mid3v2", line 62, in delete_tags
mutagen.id3.delete(filename, v1, v2)
File "/usr/lib/python2.6/dist-packages/mutagen/id3.py", line 496, in delete
f = open(filename, 'rb+')
IOError: [Errno 2] No such file or directory: '\xe7\x88\xb1.mp3'

问题我知道在哪里,但是不知道怎么解决,等待中,谢谢

Re: linux 下载音乐脚本(正式版)

发表于 : 2009-10-16 8:26
leoonline
benqlk, 了看下我的问题哦,谢啦