musicbrainz-ruby 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +8 -4
- data/lib/musicbrainz.rb +29 -3
- metadata +5 -5
data/README.markdown
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
MusicBrainz-ruby
|
2
2
|
================
|
3
3
|
|
4
|
-
O hai, I HTTParty'd ur [web service][
|
4
|
+
O hai, I [HTTParty][1]'d with ur [web service][2].
|
5
5
|
|
6
6
|
No offence, RBrainz gem.
|
7
7
|
|
8
|
-
I have only done the artist call so far.
|
8
|
+
I have only done the artist call so far. Returns [Mashes][3] of the metadata tag.
|
9
9
|
|
10
|
-
[1]:
|
10
|
+
[1]: https://github.com/jnunemaker/httparty
|
11
|
+
[2]: http://wiki.musicbrainz.org/XMLWebService
|
12
|
+
[3]: https://github.com/intridea/hashie
|
11
13
|
|
12
14
|
Install
|
13
15
|
-------
|
@@ -18,9 +20,11 @@ Examples
|
|
18
20
|
--------
|
19
21
|
|
20
22
|
require 'musicbrainz-ruby'
|
21
|
-
brainz = MusicBrainz.new
|
23
|
+
brainz = MusicBrainz::Client.new
|
22
24
|
|
25
|
+
# Find an artist by id, include artist relations
|
23
26
|
brainz.artist('45d15468-2918-4da4-870b-d6b880504f77', :inc => 'artist-rels')
|
27
|
+
# Search for artists with the term 'Diplo'
|
24
28
|
brainz.artist(nil, :query => 'Diplo')
|
25
29
|
|
26
30
|
MIT License
|
data/lib/musicbrainz.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
|
3
|
+
gem 'httparty', '~> 0.6.1'
|
2
4
|
require 'httparty'
|
5
|
+
|
6
|
+
gem 'hashie', '~> 0.4.0'
|
3
7
|
require 'hashie'
|
4
8
|
|
5
9
|
module MusicBrainz
|
@@ -12,12 +16,34 @@ module MusicBrainz
|
|
12
16
|
def request(path, params)
|
13
17
|
options = {:query => {:type => 'xml'}}
|
14
18
|
options[:query].merge!(params)
|
15
|
-
|
16
|
-
|
19
|
+
|
20
|
+
response = self.class.get(path, options)
|
21
|
+
|
22
|
+
if response.response.is_a? Net::HTTPBadRequest
|
23
|
+
raise ArgumentError, response.parsed_response
|
24
|
+
end
|
25
|
+
|
26
|
+
Mash.new(response).metadata
|
17
27
|
end
|
18
28
|
|
19
29
|
def artist(musicbrainz_id = nil, params = {})
|
20
30
|
request("/artist/#{musicbrainz_id}", params)
|
21
31
|
end
|
32
|
+
|
33
|
+
def release_group(musicbrainz_id = nil, params = {})
|
34
|
+
request("/release-group/#{musicbrainz_id}", params)
|
35
|
+
end
|
36
|
+
|
37
|
+
def release(musicbrainz_id = nil, params = {})
|
38
|
+
request("/release/#{musicbrainz_id}", params)
|
39
|
+
end
|
40
|
+
|
41
|
+
def track(musicbrainz_id = nil, params = {})
|
42
|
+
request("/track/#{musicbrainz_id}", params)
|
43
|
+
end
|
44
|
+
|
45
|
+
def label(musicbrainz_id = nil, params = {})
|
46
|
+
request("/label/#{musicbrainz_id}", params)
|
47
|
+
end
|
22
48
|
end
|
23
|
-
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: musicbrainz-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robin Tweedie
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-17 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|