File: [local] / mp3 / bin / addmp3playlist.pl (download)
Revision 1.1.1.1 (vendor branch), Thu Mar 2 23:20:47 2006 UTC (18 years, 4 months ago) by andrew
Branch: REDRIVER
Changes since 1.1: +0 -0 lines
our MP3 player
|
#!/usr/bin/perl -w
########################################################################
# 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;
}