及其龌龊的down-lrc.pl,会改的来试试。
发表于 : 2010-02-21 17:00
代码: 全选
● dog down-lrc.pl
use WWW::Mechanize;
use File::Basename qw/basename dirname/;
chdir dirname $ARGV[0];
$file=basename $ARGV[0];
$file=~s/\.mp3//;
print $file;
die "无此mp3文件。" if ! -f "$file.mp3";
if($file=~/-/){($ar,$ti)=split /-/,$file;}else{$ar="";$ti=$file;}
print "$file =...$ar...$ti...\n";
$ar=`echo $ar|iconv -f utf8 -t gbk|uni2ascii -a J`;
$ti=`echo $ti|iconv -f utf8 -t gbk|uni2ascii -a J`;
chomp $ar; chomp $ti;
my $mech = WWW::Mechanize->new();
$mech -> get("http://lrc.aspxp.net/?ar=$ar&ti=$ti");
if ($mech->success()) {
print $mech->uri();
$mech->content(format =>'text');
$mech->follow_link(text_regex=>qr/^LRC/, n=>1);
print "\nlrc=>".$mech->uri()."\n";
$_=$mech->content();
/\[ti:.*$/m; $_=$&; s/<.*?>/\n/g; print;
open OUT,">$file.lrc"; print OUT; close OUT;
}
返回的内容,因为没html头,follow_link取n=>2的时候,$mech->save_content("$file.lrc")都写成乱码。只好取网页n=>1,自己解析。
为了mp4播放器,规整当前目录的lrc。
代码: 全选
● for i in *.mp3;do down-lrc.pl $i; done