Return to addmp3playlist.pl CVS log | Up to [local] / mp3 / bin |
File: [local] / mp3 / bin / addmp3playlist.pl (download)
Revision 1.2, Sat Aug 12 00:14:53 2006 UTC (17 years, 11 months ago) by andrew
add RCS Ids. I am not sure why this wasn't committed when those were actually done, but it is now. |
#!/usr/bin/perl -w # $RedRiver$ ######################################################################## # addmp3playlist.pl *** Adds MP3's to the playlist # # 04-13-00 # Written by andrew fresh <andrew@mad-techies.org> ######################################################################## use strict; use diagnostics; ######################################################################## # *** Variables *** my $DestDir = '/home/mp3/Sorted'; my $filename = $ENV{'QUERY_STRING'}; my $playlist = '/var/www/mp3/playlist/playlist.lst'; ######################################################################## # *** MAIN *** ######################################################################## if (! -d $DestDir) { mkdir $DestDir, 0777 } print "Content-Type: text/html\n\n"; $filename =~ s/%(..)/pack("c",hex($1))/ge; if ($filename) { print "<html>\n<head>\n\t<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>"; if ($ENV{'QUERY_STRING'}) { print "<meta HTTP-EQUIV=Refresh CONTENT=\"10; URL=/blank.htm\">"; } print "<title>Added $filename</title>\n<body>\n\n"; print "<h3>Added $filename</h3>\n"; open PLAYLIST, ">>$playlist" or bail("unable to open PLAYLIST: $!"); print PLAYLIST "$filename\n"; close PLAYLIST or bail("unable to close PLAYLIST: $!"); } else { print "<h1>You need to pass a song</h1>"; } print "</body>\n</head>\n</html>\n"; ######################################################################## # *** SUBS *** ######################################################################## ######################################################################## # Bail: this subrouting dies and displays the error to the browser. # gotten from the example in the O'Reilly # _Learning_Perl_on_Win32_Systems_ sub bail { my $error = "@_"; print "Error! $error"; exit; } ######################################################################## sub Print_Nav { open FILE, 'nav.inc' or die "\n\ncouldn't open FILE nav.inc: $!"; while (<FILE>) { print; } close FILE; }