#!/usr/bin/perl -w use strict; #warning: recursive ogginfo: #find mp3/ -name '*.ogg' |xargs ogginfo >ogginfo-index #todo: get ordering from .m3u's. my $dir = "/home/bfields/public_html/music"; my @albums = (); my $genres = {}; my $artists = {}; my $tracks = {}; readalbums("$dir/getinfo2-output"); xref_tag($genres, "genre"); xref_tag($artists, "artist"); # doesn't work, it's a list: xref_tag($artists, "track"); output_albums(); output_album_index(); output_genre_indices(); output_genre_index(); sub escape_name { my $name = shift(); $name =~ s|/|_|g; return $name; } sub write_head { my $file = shift(); my $title = shift(); print($file "$title\n"); print($file "\n"); } sub write_short_album { my $file = shift(); my $album = shift(); my $id = $album->{"id"}; print($file "
  • " . $album->{"title"} . "
  • \n"); } sub output_genre_indices { my $genre; foreach $genre (keys(%$genres)) { my $file = escape_name($genre); $file = "$dir/genres/$file.html"; open(INDEX, ">$file") or die("failed to open $file"); write_head(\*INDEX, "$genre index"); print(INDEX "\n\n\n"); close(INDEX); } } sub output_genre_index { my $genre; open(INDEX, ">$dir/genres/index.html") or die("failed to open $dir/genres/index.html"); write_head(\*INDEX, "genre index"); print(INDEX "\n"); print(INDEX "\n"); close(INDEX); } sub output_albums { my $album; my $track; foreach $album (@albums) { open(ALBUM, ">$dir/albums/".$album->{"id"}.".html"); write_head(\*ALBUM, $album->{"title"}); my $genrefile = "../genres/".escape_name($album->{"genre"}) .".html"; print ALBUM <{"title"}
    artist: $album->{"artist"}
    genre: $album->{"genre"}
    date: $album->{"date"}
    EOF print(ALBUM ""); print(ALBUM "\n"); close(ALBUM); } } sub output_album_index { my $album; open(INDEX, ">$dir/albums/index.html"); print(INDEX "\nalbum title index" . "\n"); print(INDEX "\n