#creates web pages from AIC use strict; my $header="\n".''."\n"; my $footer="\n
Back to TOC\n\n\n\n"; my $dbin='the audiofile internet companion output file'; my $dboutdir='the dir to drop the web into'; my $mp3dir='the loc of your mp3 dir'; my @mp3files; my %TOC; my $key; #########NEW use File::Find; print "Deleting old .htm files...\n"; unlink <$dboutdir/*.htm>; print "Storing local MP3's...\n"; find(\&wanted, $mp3dir); sub wanted { push @mp3files, "$File::Find::dir/$_\n" if /.mp3/i; } #########END open IN, "<$dbin" or die "Cannot open $dbin :$!"; print "Creating album files...\n"; while(){ my @details=split /"/; my @codearray=split /\/, $details[1]; my $code=$codearray[1]; my $totaltime=$codearray[$#codearray]; my $minutes=int ($totaltime/60); my $seconds = $totaltime-($minutes*60)-2; my @timesarray=split /\/, $details[3]; my $unknown1=$details[4]; my $title=$details[5]; my $artist=$details[7]; my $artist2=$artist; if ($artist=~/^the /i){ $artist2=~s/^The //i; $artist2="$artist2, The"; } my $filename=lc($artist2.$title.".htm"); $filename=~s/[\?\\\/:\*"'<>\| ]//g; my @songsarray=split /\/, $details[9]; my $songlink="$title"; my $genre=$details[11]; my $MP3=""; # Write the output HTML file open OUT, ">$dboutdir/$filename" or die "Cannot open $dboutdir/$filename for write :$!"; print OUT "$header
"; print OUT "

$artist
$title

"; print OUT "\n"; #write out the song titles for (0..$#songsarray) { my @mp3match=""; my @mp3match1 = grep /\Q$songsarray[$_]\E/i, @mp3files; my @mp3match = grep /$artist/i,@mp3match1; print OUT "\n\n"; print OUT "\n"; print OUT "\n"; } print OUT ""; printf OUT ("",$minutes,$seconds); print OUT "
",$_+1,"."; if (@mp3match){ print OUT "$songsarray[$_]"; my $MP3=' (mp3)'; }else{ print OUT "$songsarray[$_]"; } print OUT "$timesarray[$_]
--------
%02d:%02d
\n"; print OUT "$footer"; close OUT; $TOC{$filename}="$artist2 $songlink $MP3";#add Genre Here } close IN; ######################################### print "Writing Table of contents file...\n"; open TOCFILE, ">$dboutdir/TOC.htm" or die "Cannot open $dboutdir/TOC.htm for write :$!"; print TOCFILE "$header\n"; print TOCFILE "

0to9 "; for('a'..'z'){ print TOCFILE "$_ "; } print TOCFILE "All"; print TOCFILE "

".(keys %TOC)." Albums

"; print TOCFILE "

Generated via Perl script on
".scalar localtime()."

"; close TOCFILE; ######################################### print "Printing Alphabetical Sort...\n"; for ('a'..'z'){ open LETTERFILE, ">$dboutdir/$_.htm" or die "Cannot open $dboutdir/$_.htm for write :$!"; print LETTERFILE "$header"; print LETTERFILE "

$_

"; foreach $key (sort keys %TOC){ if($key=~/^$_/){ print LETTERFILE "$TOC{$key}
\n"; } } print LETTERFILE "$footer"; close LETTERFILE; } ###################################### open ALLFILE, ">$dboutdir/all.htm" or die "Cannot open $dboutdir/all.htm for write :$!"; open NUMFILE, ">$dboutdir/0to9.htm" or die "Cannot open $dboutdir/0to9.htm for write :$!"; print ALLFILE $header; print NUMFILE $header; print ALLFILE "

All

\n"; print NUMFILE "

0to9

\n"; foreach $key (sort keys %TOC){ if ($key=~/^\d/){ print NUMFILE "$TOC{$key}
\n"; } print ALLFILE "$TOC{$key}
\n"; } print ALLFILE "$footer"; print NUMFILE "$footer"; close ALLFILE; close NUMFILE; ###################################### #Write the MP3 listing page @mp3files=sort @mp3files; open OUT6, ">$dboutdir/mp3list.htm" or die "Cannot open $dboutdir/mp3list.htm for write :$!"; print OUT6 "$header"; print OUT6 "

MP3 Listing ($#mp3files files)

\n"; foreach (@mp3files){ print OUT6 "$_
\n"; } print OUT6 "$footer"; close OUT6; ######################################