The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


MusicBrainz::Client::Simple - Perlish Interface to MusicBrainz Client API


  use MusicBrainz::Client::Simple;

  my $mb = MusicBrainz::Client::Simple->new( debug => 1, utf8 => 0 );

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

  foreach my $album ( @result ) {
      print $album->get_name, "\n";


MusicBrainz::Client::Simple is a class providing access to the meta data of This class aims to be as easy to use as possible while still offering the most important functionality. If you need a more powerful interface, try MusicBrainz::Client instead.


new( [ OPTIONS ] )

The constructor for a new MusicBrainz::Client::Simple object. To adjust the object's behaviour, you can pass options in a hash like style as illustrated in the above example. The following options are possible:

device - The device name of your CD-ROM/DVD-ROM drive. (default: depends on libmusicbrainz installation)

debug - Print the client's query and the server's response on standard output. (default: 0)

utf8 - If set, strings are in UTF-8 instead of ISO-8859-1 (latin1). (default: 0)

max_items - The maximum number of records (Artists, Albums, Tracks etc.) the server returns for one query. (default: 25)

proxy_host - The hostname of a HTTP proxy server. (default: unused)

proxy_port - The port number of a HTTP proxy server. (default: unused)

On the Windows platform, the constructor calls WSAInit() and WSAStop() on MusicBrainz::Client.



Queries the CD-ROM/DVD-ROM drive to calculate a CDIndexID. The ID is then sent to the musicbrainz server. lookup_cd returns a list of MusicBrainz::Client::Simple::Album objects which contain various information about album, artist and tracks of your CD.

The reason why you might get multiple Album objects under some rare circumstances is the following: A CDIndexID is not necessarily unique, so there is a small probability that two or more albums have the same CDIndexID.

After lookup_cd, the success method should be called. In case of an error, success returns false. You can then use get_error to get a printable error message.

lookup_by_cdindex( CDINDEXID )

This method does the same as lookup_cd except for the difference that you have to pass a valid CDIndexID as an argument. The CD-ROM/DVD-ROM drive is not used.


Returns a true value if the previous operation was successful and false otherwise.


Returns a printable string describing the last error that occurred. This method should only be used if the success method returned false.


None by default.




 Matthias Friedrich, <>
 Sander van Zoest, <>


Copyright 2003 by Matthias Friedrich <>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.