This creates a very detailed web of your CD collection based on CDDB info. Why you would want to do this is beyond me, but you can. Enjoy, I suppose.

I wrote this a year or two back when there was no easy method of getting CD's into a web in bulk with no typing and for free. The best that I had found was Clark Tisdale's Audiofile Internet companion, which allowed for bulk lookups against the CDDB, which was a start. You pop each disk into the CD drive, does a bulk lookup when you tell it to, and outputs a flat file of the tracks, etc.

Problem was, you had to buy a database to decode the flatfile, and for $29, it couldn't create a web database, and there was no way to link up the mp3's on your drive to the resulting database, anyway. So, I built this. Need breeds.

I included 2 versions: I use the first locally to link up the MP3's and create a little local web. It deletes all of the old html pages on each run and replaces them (in case you delete or add stuff in the flat file).

The second version is for uploading to the web. The differences are:

To use this:

  1. Download AIC from Spinfee. It's free.
  2. Change these 3 variables:
    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';
  3. Add a 'style.css file to the web directory

Version 1: With MP3 Linking

#creates web pages from AIC use strict; my $header="<HTML>\n".'<link REL="stylesheet" HREF="style.css" TYPE="t +ext/css"><BODY bgcolor="#000033" text="#ffffcc" link="#99ccff" vlink= +"#99ccff" font-face:"Arial">'."\n"; my $footer="\n<BR><A HREF=TOC.htm>Back to TOC</a>\n\n</BODY>\n</HTML>\ +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(<IN>){ 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="<a href\=$filename>$title</a>"; my $genre=$details[11]; my $MP3=""; # Write the output HTML file open OUT, ">$dboutdir/$filename" or die "Cannot open $dboutdir/$fi +lename for write :$!"; print OUT "$header<center>"; print OUT "<p><span class=artist>$artist</span><br><span class=alb +um>$title</span></p>"; print OUT "<TABLE width\=400px cellspacing\=0 cellpadding\=0 borde +r\=0>\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 "<TR>\n<TD class=one>",$_+1,".</TD>\n"; print OUT "<td class=one>"; if (@mp3match){ print OUT "<a href=\"$mp3match[0]\">$songsarray[ +$_]</a>"; my $MP3=' (mp3)'; }else{ print OUT "$songsarray[$_]"; } print OUT "</TD>\n"; print OUT "<td class=one>$timesarray[$_]</TD></TR>\n"; } print OUT "<TR><td class=one> </TD><td class=one> </TD><td class=o +ne>--------</TD></TR>"; printf OUT ("<TR><td class=one> </TD><td class=one> </TD><td class +=one>%02d:%02d</TD></TR>",$minutes,$seconds); print OUT "</TABLE>\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.h +tm for write :$!"; print TOCFILE "$header\n"; print TOCFILE "<p align=center><a href=0to9.htm>0to9</a> "; for('a'..'z'){ print TOCFILE "<a href=$_.htm>$_</a> "; } print TOCFILE "<a href=all.htm>All</a>"; print TOCFILE "<p align=center>".(keys %TOC)." Albums</p>"; print TOCFILE "<p align=center>Generated via Perl script on<BR>".scala +r localtime()."</p>"; 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 "<p><strong><font size=6 color=#999966>$_</font>< +/strong></p>"; foreach $key (sort keys %TOC){ if($key=~/^$_/){ print LETTERFILE "$TOC{$key}<BR>\n"; } } print LETTERFILE "$footer"; close LETTERFILE; } ###################################### open ALLFILE, ">$dboutdir/all.htm" or die "Cannot open $dboutdir/all.h +tm for write :$!"; open NUMFILE, ">$dboutdir/0to9.htm" or die "Cannot open $dboutdir/0to9 +.htm for write :$!"; print ALLFILE $header; print NUMFILE $header; print ALLFILE "<p><strong><font size=6 color=#999966>All</font></stron +g></p>\n"; print NUMFILE "<p><strong><font size=6 color=#999966>0to9</font></stro +ng></p>\n"; foreach $key (sort keys %TOC){ if ($key=~/^\d/){ print NUMFILE "$TOC{$key}<BR>\n"; } print ALLFILE "$TOC{$key}<BR>\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/mp3l +ist.htm for write :$!"; print OUT6 "$header"; print OUT6 "<p><strong><font size=6 color=#999966>MP3 Listing ($#mp3fi +les files)</font></strong></p>\n"; foreach (@mp3files){ print OUT6 "<a href=\"$_\">$_</a><br>\n"; } print OUT6 "$footer"; close OUT6; ######################################

Version 2: No MP3 Linking

For those of you outputting to the web who don't want to recreate all of the files, this version will append new files and skip the whole MP3 process:

#creates web pages from AIC use strict; my $header="<HTML>\n".'<link REL="stylesheet" HREF="style.css" TYPE="t +ext/css"><BODY bgcolor="#000033" text="#ffffcc" link="#99ccff" vlink= +"#99ccff" font-face:"Arial">'."\n"; my $footer="\n<BR><A HREF=TOC.htm>Back to TOC</a>\n\n</BODY>\n</HTML>\ +n"; my $dbin='the audiofile internet companion output file'; my $dboutdir='the dir to drop the web into'; my %TOC; my $key; open IN, "<$dbin" or die "Cannot open $dbin :$!"; print "Creating album files...\n"; while(<IN>){ 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="<a href\=$filename>$title</a>"; my $genre=$details[11]; # Write the output HTML file if (!-e "$dboutdir/$filename"){ open OUT, ">$dboutdir/$filename" or die "Cannot open $dboutdir +/$filename for write :$!"; print OUT "$header<center>"; print OUT "<p><span class=artist>$artist</span><br><span class +=album>$title</span></p>"; print OUT "<TABLE width\=400px cellspacing\=0 cellpadding\=0 b +order\=0>\n"; #write out the song titles for (0..$#songsarray) { print OUT "<TR>\n<TD class=one>",$_+1,".</TD>\n"; print OUT "<td class=one>$songsarray[$_]</TD>\n"; print OUT "<td class=one>$timesarray[$_]</TD></TR>\n"; } print OUT "<TR><td class=one> </TD><td class=one> </TD><td cla +ss=one>--------</TD></TR>"; printf OUT ("<TR><td class=one> </TD><td class=one> </TD><td c +lass=one>%02d:%02d</TD></TR>",$minutes,$seconds); print OUT "</TABLE>\n"; print OUT "$footer"; close OUT; } $TOC{$filename}="$artist2 $songlink";#add Genre Here } close IN; ######################################### print "Writing Table of contents file...\n"; open TOCFILE, ">$dboutdir/TOC.htm" or die "Cannot open $dboutdir/TOC.h +tm for write :$!"; print TOCFILE "$header\n"; print TOCFILE "<p align=center><a href=0to9.htm>0to9</a> "; for('a'..'z'){ print TOCFILE "<a href=$_.htm>$_</a> "; } print TOCFILE "<a href=all.htm>All</a>"; print TOCFILE "<p align=center>".(keys %TOC)." Albums</p>"; print TOCFILE "<p align=center>Generated via Perl script on<BR>".scala +r localtime()."</p>"; 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 "<p><strong><font size=6 color=#999966>$_</font>< +/strong></p>"; foreach $key (sort keys %TOC){ if($key=~/^$_/){ print LETTERFILE "$TOC{$key}<BR>\n"; } } print LETTERFILE "$footer"; close LETTERFILE; } ###################################### open ALLFILE, ">$dboutdir/all.htm" or die "Cannot open $dboutdir/all.h +tm for write :$!"; open NUMFILE, ">$dboutdir/0to9.htm" or die "Cannot open $dboutdir/0to9 +.htm for write :$!"; print ALLFILE $header; print NUMFILE $header; print ALLFILE "<p><strong><font size=6 color=#999966>All</font></stron +g></p>\n"; print NUMFILE "<p><strong><font size=6 color=#999966>0to9</font></stro +ng></p>\n"; foreach $key (sort keys %TOC){ if ($key=~/^\d/){ print NUMFILE "$TOC{$key}<BR>\n"; } print ALLFILE "$TOC{$key}<BR>\n"; } print ALLFILE "$footer"; print NUMFILE "$footer"; close ALLFILE; close NUMFILE;

style.css

...and style.css should be in the same dir:

<code> A {font-size:"10pt";font-family: Verdana;color:#00aaff;text-decoration: none;} A:hover {font-size:"10pt";font-family: Verdana;color:#00aaff;text-decoration: underline;} td {vertical-align:top;height:1px;font:"Arial"} td.one {font-family:arial;font-size:"10pt";} .album {font-size:"12pt";color:#999966;font-family:helvetica;} .artist {font-size:"24pt";color:#800000;font-family:"Die Nasty";}

-OzzyOsbourne


In reply to MP3 web with Audiofile Internet Companion by OzzyOsbourne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.