# Sequential Song Evaluator, by Tyler Bletsch # Uses HTTPQ Winamp web control interface (http://httpq.sourceforge.net/) use LWP::Simple; use Cwd; use Term::ReadKey; $|=1; sub url { my ($cmd,%args) = @_; my $argStr = join('&',map {"$_=$args{$_}"} (keys %args)); return "http://$host:$port/$cmd?p=$pass&$argStr"; } sub amp { my ($cmd,%args) = @_; return get(url($cmd,%args)); } sub pramp { my ($cmd,%args) = @_; my $argStr = join(',',map {"$_=$args{$_}"} (keys %args)); my $result = amp($cmd,%args); print "$cmd ($argStr): $result\n"; } sub deathamp { my ($cmd,%args) = @_; my $argStr = join(',',map {"$_=$args{$_}"} (keys %args)); unless (amp($cmd,%args)) { die "Couldn't do operatio - $cmd ($argStr): '$result'\n"; } } sub mySystem { my ($cmd) = @_; #print "] $cmd\n"; system($cmd); } $host = 'localhost'; $port = 4800; $pass = 'lambda'; my $ver; unless ($ver = amp('getversion')) { print "Unable to get Winamp version...connection problem.\n"; exit; } print <$dir); ReadMode 'cbreak'; @files = glob('*.mp3'); for $file (@files) { deathamp('delete'); deathamp('playfile',file=>$file); deathamp('play'); my $title = amp('getcurrenttitle'); $title =~ s/^\d*\.\s*//; #print "Playing '$title'...\n"; while (1) { printf "\n%-70s? ",$title; $key = lc ReadKey(0); if ($key =~ /^[\d qs]$/i) { last; } } #print "\n\n"; deathamp('stop'); if ($key eq ' ') { print "DEATH.\n"; mkdir 'NO'; #who cares if it exists? not me mySystem("mv \"$file\" NO"); } elsif ($key =~ /^\d$/) { print "LIFE $key.\n"; mkdir $key; #who cares if it exists? not me mySystem("mv \"$file\" $key"); } elsif ($key eq 's') { print "SKIP.\n"; } elsif ($key eq 'q') { print "\n\nExiting...\n"; exit; } else { print "Bizarre input error.\n"; } #print "\n" x 25; } ReadMode 'normal';