1
0
Fork 0
musicbrainz.org Ruby client
Go to file
Gregory Eremin b22e45c65a Updated readme, travis file 2012-10-17 18:24:16 +04:00
lib Cleaning up 2012-10-17 18:05:40 +04:00
spec Cleaning up 2012-10-17 18:05:40 +04:00
.gitignore Mass rewrite 2012-10-12 16:45:51 +04:00
.rspec Gem is rewrapped with Bundler instead of Jeweler. All tests are using RSpec. Reorganized lib structure. Tests are fixed. 2012-07-04 17:10:47 +04:00
.travis.yml Updated readme, travis file 2012-10-17 18:24:16 +04:00
Contributors Mass rewrite 2012-10-12 16:45:51 +04:00
Gemfile Gem is rewrapped with Bundler instead of Jeweler. All tests are using RSpec. Reorganized lib structure. Tests are fixed. 2012-07-04 17:10:47 +04:00
LICENSE Gem is rewrapped with Bundler instead of Jeweler. All tests are using RSpec. Reorganized lib structure. Tests are fixed. 2012-07-04 17:10:47 +04:00
README.md Updated readme, travis file 2012-10-17 18:24:16 +04:00
musicbrainz.gemspec Cleaning up 2012-10-17 18:05:40 +04:00

README.md

MusicBrainz Web Service wrapper Travis CI

Ruby Version

IMPORTANT! Ruby version 1.9+ required. No support for 1.8.7 anymore.

Installation

gem install musicbrainz

or add this line to your Gemfile

gem "musicbrainz"

Usage

require "musicbrainz"

# Search for artists
@suggestions = MusicBrainz::Artist.search("Jet")

# Find artist by name or mbid
@foo_fighters = MusicBrainz::Artist.find_by_name("Foo Fighters")
@kasabian = MusicBrainz::Artist.find("69b39eab-6577-46a4-a9f5-817839092033")

# Use them like ActiveRecord models
@empire_tracks = @kasabian.release_groups[8].releases.first.tracks

# Configuring
MusicBrainz.configure do |c|
  # Application identity (required)
  c.app_name = "My Music App"
  c.app_version = "1.0"
  c.contact = "support@mymusicapp.com"

  # Cache config (optional)
  c.cache_path = "/tmp/musicbrainz-cache"
  c.perform_caching = true

  # Querying config (optional)
  c.query_interval = 1.2 # seconds
  c.tries_limit = 2
end

Api

MusicBrainz::Artist

@artists = MusicBrainz::Artist.search(query)
@artist = MusicBrainz::Artist.find_by_name(name)
@artist = MusicBrainz::Artist.find(mbid)
@artist.id
@artist.type
@artist.name
@artist.country
@artist.date_begin
@artist.date_end
@artist.release_groups

MusicBrainz::ReleaseGroup

@release_group = MusicBrainz::ReleaseGroup.find(mbid)
@release_group.id
@release_group.type
@release_group.title
@release_group.first_release_date
@release_group.releases

MusicBrainz::Release

@release = MusicBrainz::Release.find(mbid)
@release.id
@release.title
@release.status
@release.date
@release.country
@release.tracks

MusicBrainz::Track

@track = MusicBrainz::Track.find(mbid)
@track.position
@track.recording_id
@track.title
@track.length

Testing

bundle exec rspec

Debug console

bundle exec irb -r musicbrainz

Contributing

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch (IMPORTANT)
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright (c) 2011 Gregory Eremin. See LICENSE for further details.