1
0
Fork 0
musicbrainz/README.md

178 lines
4.0 KiB
Markdown
Raw Permalink Normal View History

## MusicBrainz Web Service wrapper [![Travis CI](https://secure.travis-ci.org/magnolia-fan/musicbrainz.png)](http://travis-ci.org/magnolia-fan/musicbrainz)
2012-10-17 14:48:41 +00:00
### Ruby Version
**IMPORTANT!**
2013-01-20 12:36:52 +00:00
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](https://github.com/magnolia-fan/musicbrainz/tree/v0.5.2#musicbrainz-web-service-wrapper-) and bundle it like this:
```ruby
gem 'musicbrainz', '0.5.2'
```
2012-10-17 14:24:16 +00:00
### Installation
2012-10-17 14:24:16 +00:00
```
gem install musicbrainz
```
2012-07-08 22:45:54 +00:00
or add this line to your Gemfile
```ruby
2013-01-20 12:36:52 +00:00
gem 'musicbrainz'
2012-07-08 22:45:54 +00:00
```
2012-10-17 14:48:41 +00:00
### Configuration
```ruby
2012-10-17 14:24:16 +00:00
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
```
2012-10-17 14:48:41 +00:00
### Usage
```ruby
2013-01-20 12:36:52 +00:00
require 'musicbrainz'
2012-10-17 14:48:41 +00:00
# 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
```
2013-01-20 12:36:52 +00:00
### Models
MusicBrainz::Artist
```ruby
2013-01-20 12:36:52 +00:00
# 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
2013-01-20 12:36:52 +00:00
# Fields
{
:id => String,
:type => String,
:name => String,
:country => String,
:date_begin => Date,
:date_end => Date,
:urls => Hash
}
```
MusicBrainz::ReleaseGroup
```ruby
2013-01-20 12:36:52 +00:00
# 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
2013-01-20 12:36:52 +00:00
# Instance Methods
@release_group.releases
2013-01-20 12:36:52 +00:00
# Fields
{
:id => String,
:type => String,
:title => String,
:desc => String,
2013-02-06 13:07:20 +00:00
:first_release_date => Date,
:urls => Hash
2013-01-20 12:36:52 +00:00
}
```
MusicBrainz::Release
```ruby
2013-01-20 12:36:52 +00:00
# Class Methods
MusicBrainz::Release.find(id)
# Instance Methods
@release.tracks
2013-01-20 12:36:52 +00:00
# Fields
{
:id => String,
2013-01-25 08:35:24 +00:00
:type => String,
2013-01-20 12:36:52 +00:00
:title => String,
:status => String,
:format => String,
:date => Date,
:country => String,
:asin => String,
:barcode => String,
:quality => String
2013-01-20 12:36:52 +00:00
}
```
MusicBrainz::Track (depreciated, now called Recording)
```ruby
2013-01-20 12:36:52 +00:00
# Class Methods
MusicBrainz::Track.find(id)
# Fields
{
:position => Integer,
:recording_id => String,
:title => String,
:length => Integer
}
```
MusicBrainz::Recording
```ruby
# 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
}
```
2012-07-08 22:45:54 +00:00
### Testing
2012-10-17 14:24:16 +00:00
```
bundle exec rspec
2012-07-08 22:45:54 +00:00
```
### Debug console
2012-10-17 14:24:16 +00:00
```
bundle exec irb -r musicbrainz
2012-07-08 22:45:54 +00:00
```
### 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
2012-10-17 14:48:41 +00:00
* **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
2014-01-23 10:05:28 +00:00
Copyright (c) 2014 Gregory Eremin. See [LICENSE](https://raw.github.com/magnolia-fan/musicbrainz/master/LICENSE) for further details.