前面写过一个shell脚本:
http://blog.chinaunix.net/u3/96229/showart.php?id=2120174不过由于ST的网页更新,原shell脚本失效,新学了perl,正好处理这些文本内容
使用方法和原先一样(需要wget和mplayer):
试听: stmusic.pl l
下载: stmusic.pl d
注意修改
开头的{my $dir = "/home/stesen/music";}这行
#!/usr/bin/perl -wuse strict;use LWP::Simple;my $dir = "/home/stesen/music";my $url = $ARGV[0];my $act = $ARGV[1];unless ($url =~ m#^) { print "Wrong URL!\n";}unless ($act =~ /^(d|l)$/) { print "Download OR Listen?\n";}my $page = get ($url);my $name_begin = "border=\"0\" alt=\"";my $name_end = "\"> Listen Now";my $link_begin = "javascript:playmedia1\(";my $link_end = "\);ListenLog";$page =~ m/$link_begin(.*)$link_end/is;my $unclean_link = $1; $unclean_link =~ s/ //g; $unclean_link =~ s/\(//g; $unclean_link =~ s/\)//g; $unclean_link =~ s/\'//g;my @misc = split /\,/, $unclean_link;my $link = $misc[6].$misc[2].".mp3";print $link;if ($act eq 'd') { $page =~ m/$name_begin(.*)$name_end/is; my $name = $1; $name =~ s/ //g; $name =~ s/\(//g; $name =~ s/\)//g; $name =~ s/\[//g; $name =~ s/\《//g; $name =~ s/\&//g; $name =~ s/\@//g; $name =~ s/\”//g; $name =~ s/\"//g; $name =~ s/\“//g; $name =~ s/\`//g; $name =~ s/\'//g; $name =~ s/\\//g; $name =~ s/\///g; $name =~ s/\#//g; $name =~ s/\!//g; $name =~ s/\*//g; $name =~ s/\、//g; $name =~ s/\[//g; $name =~ s/\]//g; $name =~ s/\{//g; $name =~ s/\}//g; $name =~ s/\;//g; $name =~ s/\://g; $name =~ s/\$//g; exec "wget -c $link -O ${dir}/${name}.mp3";}elsif ($act eq 'l') { exec "mplayer $link";}
阅读(808) | 评论(0) | 转发(0) |