[BACK]Return to addmp3playlist.pl CVS log [TXT][DIR] Up to [local] / mp3 / bin

Annotation of mp3/bin/addmp3playlist.pl, Revision 1.1.1.1

1.1       andrew      1: #!/usr/bin/perl -w
                      2: ########################################################################
                      3: # addmp3playlist.pl *** Adds MP3's to the playlist
                      4: #
                      5: # 04-13-00
                      6: # Written by andrew fresh <andrew@mad-techies.org>
                      7: ########################################################################
                      8: use strict;
                      9: use diagnostics;
                     10:
                     11:
                     12:
                     13: ########################################################################
                     14: # *** Variables ***
                     15: my $DestDir = '/home/mp3/Sorted';
                     16: my $filename = $ENV{'QUERY_STRING'};
                     17: my $playlist = '/var/www/mp3/playlist/playlist.lst';
                     18:
                     19:
                     20:
                     21: ########################################################################
                     22: # *** MAIN ***
                     23: ########################################################################
                     24: if (! -d $DestDir) { mkdir $DestDir, 0777 }
                     25:
                     26:
                     27:
                     28: print "Content-Type: text/html\n\n";
                     29:
                     30: $filename =~ s/%(..)/pack("c",hex($1))/ge;
                     31:
                     32: if ($filename) {
                     33:        print "<html>\n<head>\n\t<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>";
                     34:
                     35:        if ($ENV{'QUERY_STRING'}) {
                     36:                print "<meta HTTP-EQUIV=Refresh CONTENT=\"10; URL=/blank.htm\">";
                     37:        }
                     38:
                     39:        print "<title>Added $filename</title>\n<body>\n\n";
                     40:
                     41:        print "<h3>Added $filename</h3>\n";
                     42:        open  PLAYLIST, ">>$playlist" or bail("unable to open PLAYLIST: $!");
                     43:        print PLAYLIST "$filename\n";
                     44:        close PLAYLIST or bail("unable to close PLAYLIST: $!");
                     45: } else {
                     46:        print "<h1>You need to pass a song</h1>";
                     47: }
                     48:
                     49: print "</body>\n</head>\n</html>\n";
                     50:
                     51:
                     52:
                     53:
                     54:
                     55:
                     56:
                     57:
                     58:
                     59:
                     60: ########################################################################
                     61: # *** SUBS ***
                     62: ########################################################################
                     63:
                     64:
                     65:
                     66:
                     67:
                     68:
                     69:
                     70:
                     71: ########################################################################
                     72: # Bail: this subrouting dies and displays the error to the browser.
                     73: # gotten from the example in the O'Reilly
                     74: # _Learning_Perl_on_Win32_Systems_
                     75: sub bail {
                     76:        my $error = "@_";
                     77:        print "Error! $error";
                     78:        exit;
                     79: }
                     80: ########################################################################
                     81:
                     82:
                     83: sub Print_Nav
                     84: {
                     85:        open FILE, 'nav.inc' or die "\n\ncouldn't open FILE nav.inc: $!";
                     86:        while (<FILE>) {
                     87:                print;
                     88:        }
                     89:        close FILE;
                     90: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>