Identifying Albums

Dave Cross dave at dave.org.uk
Tue Apr 25 18:56:07 BST 2006


Dave Cross wrote:
> This feels like something that someone should have already written, but 
> I can't work out which chain of CPAN modules I need to string together 
> to do it.
> 
> I have a number of CDs that I want to get rid of. I'm probably going to 
> put a lot of them on eBay. In order to do that I want to include track 
> listings and other CD information in the auction description.
> 
> Most of these CDs haven't been ripped so I don't have nicely tagged Oggs 
> or MP3s hanging around. So what I want is a program that does part of 
> what CD ripping programs do when you put a new CD in the drive. It needs 
> to connect to a music recognition service (MusicBrainz?), identify the 
> CD and then write a file containing as much of the CD information 
> (title, artist, list of tracks) as possible to a text file.
> 
> Does anyone have any pointers?

If anyone is interested, I ended up with this:

   #!/usr/bin/perl

   use strict;
   use warnings;

   use MusicBrainz::Client::Simple;

   my $mb = MusicBrainz::Client::Simple->new;

   my @result = $mb->lookup_cd;
   die "error: " . $mb->get_error unless $mb->success;

   foreach my $album ( @result ) {
     print $album->get_name, "\n";
     print $album->get_artist->get_name, "\n";
     foreach my $t ($album->get_tracks) {
       print "\t", $t->get_name;
       if ($album->has_various_artists) {
         print " - ", $t->get_artist->get_name;
       }
       print "\n";
     }
   }


Dave...


More information about the london.pm mailing list