| 
 UID2033152 威望1 点 金钱3090 金币 点卡0 点 
 | 
1#
 发表于 2003-9-3 18:21 
 | 只看该作者 
 [转帖]提供在线听mp3
| 这个程序是为在服务器端提供在线听mp3歌曲的人减轻制作.m3u文件负担 而编造的, 它可以将指定目录下面的所有mp3歌曲的路径表示成为
 合法的URL并保存成all.m3u文件
 作者 callmedear.bbs@smth.org
 复制代码#!/usr/bin/perl -w # print usage information if no argument offered by user. if ($#ARGV < 0) {   print <<END_USAGE Usage: mkm3u top-URL dir-of-your-public-html dir-you-want-to-search For example, $ mkm3u http://mp3.your.net/~yourID/ /home/yourID/public-html/ mp3-directory And the result will be saved as all.m3u in your home directory. END_USAGE ; die("End of usage\n"); } # if the directory offered by user is not an absolute one, make it be. if( $ARGV[2] !~ /^\// ) {   $pwd = `pwd`;   chop($pwd);   $ARGV[2] = $pwd."/".$ARGV[2]; } # get the home dir of the user $home=$ENV{"HOME"}; print "The home dir of yours is: $home\n"; open(M3U, ">>${home}\/all.m3u"); &process_dir("$ARGV[2]"); print "The result is kept as $home/all.m3u\n"; close(M3U); sub process_dir {   my($pwd,@subs,$count,$i);   $pwd = $_[0];   print "The present directory is $pwd\n";   @subs=<$pwd/*>;   $count=@subs;   for($i=0;$i<$count;$i++)         {           if($subs[$i] !~ /\/\.?$/)           {              if( -f $subs[$i] && $subs[$i] =~ /\.mp3$/i)              {               $subs[$i] =~ s/$ARGV[1]/$ARGV[0]/e;               print M3U "$subs[$i]\n";              }              elsif( -d $subs[$i] )              {               &process_dir("$subs[$i]");              }            }          } } 
 | 
 |