RBrainz - Ruby MusicBrainz library

RBrainz is a Ruby client library to query the MusicBrainz database using the MusicBrainz XML web service. RBrainz follows the design of the MusicBrainz client library reference implementation and supports the MusicBrainz XML Metadata Schema Version 1.2.

Download

RBrainz can be downloaded from the release page. You can also install RBrainz with RubyGems:

gem install rbrainz

If you want to calculate MusicBrainz Disc IDs you will have to install MB-DiscID as well. MB-DiscID provides Ruby bindings for libdiscid. MB-DiscID too can be installed with RubyGems:

gem install mb-discid

Usage

A simple example on how to use RBrainz is shown below. For more detailed instructions see the API documentation.

require 'rbrainz'
include MusicBrainz

# With the ArtistInclude object we can control what
# kind of information the MusicBrainz server will
# include in its answer.
artist_includes = Webservice::ArtistIncludes.new(
  :aliases      => true,
  :releases     => ['Album', 'Official'],
  :artist_rels  => true,
  :release_rels => true,
  :track_rels   => true,
  :label_rels   => true,
  :url_rels     => true
)

# Query the webservice for the artist with a given ID.
# The result will contain all the information
# specified in artist_includes.
query  = Webservice::Query.new
id     = 'c0b2500e-0cef-4130-869d-732b23ed9df5'
artist = query.get_artist_by_id(id, artist_includes)

# Display the fetched artist data together with
# all release titles.
print <<EOF
ID            : #{artist.id.uuid}
Name          : #{artist.name}
Sort name     : #{artist.sort_name}
Disambiguation: #{artist.disambiguation}
Type          : #{artist.type}
Begin date    : #{artist.begin_date}
End date      : #{artist.end_date}
Aliases       : #{artist.aliases.to_a.join('; ')}
Releases      : #{artist.releases.to_a.join('; ')}
EOF

Contact

If you have any questions or suggestions regarding RBrainz please write to the rbrainz-user mailinglist.

If you find bugs or if you have any feature requests please use the RBrainz bug tracker.