In article <p05200f01b9f8db35ea84@[63.173.138.149]>, Morbus Iff <[EMAIL PROTECTED]> 
wrote:

> I've recently been reorganizing my mp3 collections, and part of the reason
> was because I wanted to generate a listing of my albums automatically, but
> with ultimate control over the display. Most of the shareware/freeware
> converters worked, but didn't give me enough control.

here's a quick Mac::iTunes script to do the same thing.  you can do just about 
anything you like in the template file. if you want real control, separate
data generation from presentation. :)

   #!/usr/bin/perl
   
   use Mac::iTunes;
   use Text::Template 'fill_in_file';
   
   my $template = $ARGV[0] || die "Specify an output template file\n";
   my $file     = $ARGV[1] || "$ENV{HOME}/Music/iTunes/iTunes 3 Music Library";
   my $playlist = $ARGV[2] || 'Library';
   
   die "Music library file [$file] does not exist\n"   unless -e $file;
   die "Output template file [$file] does not exist\n" unless -e $template;
   
   my $itunes = Mac::iTunes->read( $file );
   die unless ref $itunes;
   
   my $playlist = $itunes->get_playlist( $playlist );
   
   print fill_in_file( $template, HASH =>
      {
      playlist => $playlist->title,
      items    => [ $playlist->items ],
      } );

Here's a template file example to make tab delimited output.

   {
   use Mac::iTunes::Item;
   
   my $string = "Playlist $playlist\n";
   
   foreach my $item ( @items )
      {
      $string .= join "\t", map { $item->$_ } qw(title artist);
      }
   
   $string;
   }

Here's a template for an HTML table.

   <html>
   <head>
      <title>Playlist { $playlist }</title>
   </head>
   
   <body>
   <table>
   
      {
      use Mac::iTunes::Item;
      use CGI qw(:html);
      
      foreach my $item ( @items )
         {
         $string .= Tr( td( $item->title ), td( $item->artist ) );
         }
      
      $string;
      }
   
   </table>
   </body>
   </html>

Reply via email to