1
0
Fork 0
musicbrainz.org Ruby client
Go to file
Gregory Eremin c2979690e0 Merge pull request #33 from rightsup/fix-recording
Adds Recording::find & moves Track::search into Recording::search
2015-05-13 12:52:59 +03:00
lib accidentally set id/mbid as an integer rather than string. 2015-05-12 18:57:25 +02:00
spec Migrate 'should' syntax to 'expect' 2015-05-12 19:00:38 +02:00
.gitignore Add .ruby-version to .gitignore 2015-03-13 15:54:28 -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 Readme and travis 2012-10-17 18:48:41 +04:00
CHANGELOG.md Release 0.7.7 2014-12-01 11:39:52 +01:00
Contributors created new track_search binding to allow searching for tracks (really recordings). Modified existing model classes to call super() to handle search (open/closed principle, attempting to reduce duplicate code). Fixed xml namespace issue in specs. 2013-05-05 18:58:12 -05:00
Gemfile Use magic encoding to ret rid of "invalid multibyte chat (US-ASCII)" errors. track_search is now renamed recording_search. recording_search now works (I mixed up the inputs). 2015-05-12 18:47:13 +02: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 Use magic encoding to ret rid of "invalid multibyte chat (US-ASCII)" errors. track_search is now renamed recording_search. recording_search now works (I mixed up the inputs). 2015-05-12 18:47:13 +02:00
Rakefile Initial version. 2013-05-06 20:45:41 +02:00
musicbrainz.gemspec Update to use modern RSpec syntax and conventions 2015-03-13 15:47:27 -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, if you still on 1.8 consider using gem version 0.5.2 and bundle it like this:

gem 'musicbrainz', '0.5.2'

Installation

gem install musicbrainz

or add this line to your Gemfile

gem 'musicbrainz'

Configuration

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

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

Models

MusicBrainz::Artist

# Class Methods:
MusicBrainz::Artist.find(id)
MusicBrainz::Artist.find_by_name(name)
MusicBrainz::Artist.search(name)
MusicBrainz::Artist.discography(id)

# Instance Methods:
@artist.release_groups

# Fields
{
  :id         => String,
  :type       => String,
  :name       => String,
  :country    => String,
  :date_begin => Date,
  :date_end   => Date,
  :urls       => Hash
}

MusicBrainz::ReleaseGroup

# Class Methods
MusicBrainz::ReleaseGroup.find(id)
MusicBrainz::ReleaseGroup.find_by_artist_and_title(artist_name, title, 'Album') # 3rd arg optional
MusicBrainz::ReleaseGroup.search(artist_name, title)
MusicBrainz::ReleaseGroup.search(artist_name, title, 'Album') # 3rd arg optional

# Instance Methods
@release_group.releases

# Fields
{
  :id                 => String,
  :type               => String,
  :title              => String,
  :desc               => String,
  :first_release_date => Date,
  :urls               => Hash
}

MusicBrainz::Release

# Class Methods
MusicBrainz::Release.find(id)

# Instance Methods
@release.tracks

# Fields
{
  :id      => String,
  :type    => String,
  :title   => String,
  :status  => String,
  :format  => String,
  :date    => Date,
  :country => String,
  :asin    => String,
  :barcode => String,
  :quality => String
}

MusicBrainz::Track (depreciated, now called Recording)

# Class Methods
MusicBrainz::Track.find(id)

# Fields
{
  :position     => Integer,
  :recording_id => String,
  :title        => String,
  :length       => Integer
}

MusicBrainz::Recording

# Class Methods
MusicBrainz::Recording.find(id)
MusicBrainz::Recording.search(track_name, artist_name)

# Fields
{
  :id     	=> Integer,
  :mbid			=> Integer,
  :title		=> String,
  :artist		=> String,
	:releases	=> String,
	:score		=> Integer
}

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) 2014 Gregory Eremin. See LICENSE for further details.