February 6th, 2003

Semiformalishmaybe

mp3deep

  1. !/usr/bin/perl -w

    Recursively, randomly play mp3s under current dir with mpg123

main();

sub main{ # eventually accept arguments for mpg123, for now, ignore args@mp3_list = recurse_get_mp3list(".");do_mpg123(@mp3_list);}

sub recurse_get_mp3list{my $cwd = shift;opendir(THISDIR, $cwd);my @mp3files;my @direntries = map {$cwd . '/' . $_;} grep !/^\./, readdir(THISDIR);closedir(THISDIR);foreach my $entry (@direntries)
{
if( -d $entry)
{
push(@mp3files, recurse_get_mp3list($entry));
next;
}
if( ( -f $entry) && ($entry =~ /\.LINKLINKLINK$/))
{
push(@mp3files, $entry);
next;
}
}
return @mp3files;}

sub do_mpg123{my @mp3s = @_;

  1. print "Asked to play: " . join(' ', @mp3s) . "\n";
$cmd = 'mpg123 -z ' . join ' ', (map {"\"$_\"" ;} @mp3s);print "Try LINK\n";exec $cmd;}