discogs 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/Manifest.txt +27 -0
- data/README.txt +97 -0
- data/Rakefile +22 -0
- data/bin/discogs +7 -0
- data/lib/artist.rb +47 -0
- data/lib/base.rb +65 -0
- data/lib/contributor.rb +13 -0
- data/lib/discogs.rb +22 -0
- data/lib/format.rb +13 -0
- data/lib/image.rb +22 -0
- data/lib/label.rb +70 -0
- data/lib/release.rb +92 -0
- data/lib/search.rb +86 -0
- data/lib/track.rb +17 -0
- data/lib/util.rb +19 -0
- data/spec/artist_spec.rb +34 -0
- data/spec/base_spec.rb +23 -0
- data/spec/fixtures/artist.xml +1 -0
- data/spec/fixtures/label.xml +5 -0
- data/spec/fixtures/release.xml +1 -0
- data/spec/fixtures/search.xml +6 -0
- data/spec/label_spec.rb +49 -0
- data/spec/release_spec.rb +74 -0
- data/spec/search_spec.rb +30 -0
- data/spec/spec_helper.rb +12 -0
- metadata +92 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
bin/discogs
|
6
|
+
lib/discogs.rb
|
7
|
+
lib/artist.rb
|
8
|
+
lib/base.rb
|
9
|
+
lib/contributor.rb
|
10
|
+
lib/format.rb
|
11
|
+
lib/image.rb
|
12
|
+
lib/label.rb
|
13
|
+
lib/release.rb
|
14
|
+
lib/search.rb
|
15
|
+
lib/track.rb
|
16
|
+
lib/util.rb
|
17
|
+
spec/artist_spec.rb
|
18
|
+
spec/base_spec.rb
|
19
|
+
spec/fixtures
|
20
|
+
spec/fixtures/artist.xml
|
21
|
+
spec/fixtures/label.xml
|
22
|
+
spec/fixtures/release.xml
|
23
|
+
spec/fixtures/search.xml
|
24
|
+
spec/label_spec.rb
|
25
|
+
spec/release_spec.rb
|
26
|
+
spec/search_spec.rb
|
27
|
+
spec/spec_helper.rb
|
data/README.txt
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
= discog
|
2
|
+
|
3
|
+
* http://discogs.rubyforge.org
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
API Wrapper for discogs.org
|
8
|
+
http://www.discogs.com/help/api
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* API wrapper for:
|
13
|
+
- releases
|
14
|
+
- artists
|
15
|
+
- labels
|
16
|
+
- search
|
17
|
+
* with class wrappers for:
|
18
|
+
- contributors
|
19
|
+
- genres
|
20
|
+
- styles
|
21
|
+
- images
|
22
|
+
- tracks
|
23
|
+
- formats
|
24
|
+
|
25
|
+
And a bin util
|
26
|
+
|
27
|
+
== SYNOPSIS:
|
28
|
+
|
29
|
+
d = Discog::Artist.new(ARGV[0])
|
30
|
+
puts "
|
31
|
+
Artist: #{d.name}
|
32
|
+
Members: #{d.members}
|
33
|
+
Images: #{d.images}
|
34
|
+
URLs: #{d.urls}
|
35
|
+
Releases: #{d.releases.map{|r| r.title }}
|
36
|
+
"
|
37
|
+
|
38
|
+
release = Discog::Release.new('188365')
|
39
|
+
puts "
|
40
|
+
Title: #{release.title}
|
41
|
+
Labels: #{release.labels}
|
42
|
+
Format: #{release.formats}
|
43
|
+
Status: #{release.discog_status}
|
44
|
+
Genres: #{release.genres}
|
45
|
+
Styles: #{release.styles}
|
46
|
+
Country: #{release.country}
|
47
|
+
ReleaseDate: #{release.released}
|
48
|
+
Tracks #{release.tracks}
|
49
|
+
Images: #{release.images}
|
50
|
+
Extras: #{release.contributors.join(', ')}
|
51
|
+
"
|
52
|
+
|
53
|
+
label = Discog::Label.new(ARGV[0])
|
54
|
+
puts "
|
55
|
+
Name: #{label.name}
|
56
|
+
Images: #{label.images}
|
57
|
+
Contact: #{label.contact_info}
|
58
|
+
Profile: #{label.profile}
|
59
|
+
URLs: #{label.urls}
|
60
|
+
Parent: #{label.parent}
|
61
|
+
SubLabels: #{label.sublabels}
|
62
|
+
Releases: #{label.releases}
|
63
|
+
"
|
64
|
+
|
65
|
+
== REQUIREMENTS:
|
66
|
+
|
67
|
+
rubygems
|
68
|
+
hpricot
|
69
|
+
|
70
|
+
== INSTALL:
|
71
|
+
|
72
|
+
sudo gem install discogs
|
73
|
+
|
74
|
+
== LICENSE:
|
75
|
+
|
76
|
+
(The MIT License)
|
77
|
+
|
78
|
+
Copyright (c) 2008 Josh Stephenson
|
79
|
+
|
80
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
81
|
+
a copy of this software and associated documentation files (the
|
82
|
+
'Software'), to deal in the Software without restriction, including
|
83
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
84
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
85
|
+
permit persons to whom the Software is furnished to do so, subject to
|
86
|
+
the following conditions:
|
87
|
+
|
88
|
+
The above copyright notice and this permission notice shall be
|
89
|
+
included in all copies or substantial portions of the Software.
|
90
|
+
|
91
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
92
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
93
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
94
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
95
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
96
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
97
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'spec'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
require 'hoe'
|
8
|
+
require './lib/discogs.rb'
|
9
|
+
|
10
|
+
Hoe.new('discogs', Discogs::VERSION) do |p|
|
11
|
+
p.rubyforge_name = 'discogs' # if different than lowercase project name
|
12
|
+
p.developer('Josh Stephenson', 'josh@joshstephenson.net')
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Run all specs in spec directory"
|
16
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
17
|
+
# t.rcov = true
|
18
|
+
# t.rcov_opts = ["--output=coverage"]
|
19
|
+
t.spec_opts = ["--color"]
|
20
|
+
t.spec_files = FileList['spec/*_spec.rb']
|
21
|
+
end
|
22
|
+
|
data/bin/discogs
ADDED
data/lib/artist.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Discogs
|
2
|
+
class Artist < Base
|
3
|
+
|
4
|
+
attr_accessor :name,
|
5
|
+
:members,
|
6
|
+
:urls,
|
7
|
+
:releases,
|
8
|
+
:images,
|
9
|
+
:realname
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= (parsed/'artist'/'name').first.inner_html
|
13
|
+
end
|
14
|
+
|
15
|
+
def realname
|
16
|
+
@realname ||= (parsed/'artist'/'realname').first.inner_html
|
17
|
+
end
|
18
|
+
|
19
|
+
def members
|
20
|
+
@members ||= (parsed/'artist'/'members'/'name').collect { |artist| artist.inner_html }
|
21
|
+
end
|
22
|
+
|
23
|
+
def images
|
24
|
+
@images ||= (parsed/'artist'/'images'/'image').collect do |image|
|
25
|
+
Image.new(image.attributes['url'],
|
26
|
+
image.attributes['type'],
|
27
|
+
image.attributes['uri150'],
|
28
|
+
image.attributes['width'],
|
29
|
+
image.attributes['height'])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def urls
|
34
|
+
@urls ||= (parsed/'artist'/'urls').collect { |url| (url/'url').inner_html }
|
35
|
+
end
|
36
|
+
|
37
|
+
def releases
|
38
|
+
@release ||= (parsed/'artist'/'releases'/'release').collect do |release|
|
39
|
+
Release.new(api_key, release.attributes['id'])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_s
|
44
|
+
name
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/base.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'hpricot'
|
4
|
+
require 'zlib'
|
5
|
+
require 'cgi'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
module Discogs
|
9
|
+
class Base
|
10
|
+
attr_accessor :api_key, :request_type, :request_string
|
11
|
+
|
12
|
+
DISCOGS_BASE_URL = 'http://www.discogs.com'
|
13
|
+
|
14
|
+
def initialize(request_string = nil, request_type = :artist)
|
15
|
+
@api_key = load_api_key
|
16
|
+
@request_string = request_string
|
17
|
+
@request_type = request_type.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def parsed
|
21
|
+
@parsed ||= Hpricot.XML(fetched)
|
22
|
+
end
|
23
|
+
|
24
|
+
def fetched
|
25
|
+
@fetched ||= begin
|
26
|
+
gz = Zlib::GzipReader.new(open(request_url, 'Accept-encoding' => 'gzip, deflate'))
|
27
|
+
fetched = gz.read
|
28
|
+
gz.close
|
29
|
+
fetched
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
def request_url
|
35
|
+
"#{DISCOGS_BASE_URL}/#{request_type}/#{CGI::escape(request_string)}?f=xml&api_key=#{api_key}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def load_api_key
|
39
|
+
begin
|
40
|
+
YAML::load(open(config_file))[:api_key]
|
41
|
+
rescue Errno::ENOENT
|
42
|
+
File.open(config_file, 'w') do |file|
|
43
|
+
file.write({:api_key => "CHANGE ME"}.to_yaml)
|
44
|
+
puts "Please edit #{config_file}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def home_dir
|
50
|
+
ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH']
|
51
|
+
end
|
52
|
+
|
53
|
+
def config_filename(rails = false)
|
54
|
+
rails ? 'discogs.yml' : '.discogs'
|
55
|
+
end
|
56
|
+
|
57
|
+
def config_file
|
58
|
+
if defined?(RAILS_ROOT)
|
59
|
+
File.join(RAILS_ROOT, 'config', config_filename)
|
60
|
+
else
|
61
|
+
File.join(home_dir, config_filename)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/contributor.rb
ADDED
data/lib/discogs.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
require 'rubygems'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'hpricot'
|
5
|
+
require 'zlib'
|
6
|
+
require 'cgi'
|
7
|
+
|
8
|
+
require 'base'
|
9
|
+
require 'artist'
|
10
|
+
require 'label'
|
11
|
+
require 'release'
|
12
|
+
require 'format'
|
13
|
+
require 'image'
|
14
|
+
require 'track'
|
15
|
+
require 'contributor'
|
16
|
+
require 'search'
|
17
|
+
|
18
|
+
|
19
|
+
module Discogs
|
20
|
+
VERSION = '1.0.0'
|
21
|
+
API_VERSION = '1.0'
|
22
|
+
end
|
data/lib/format.rb
ADDED
data/lib/image.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Discogs
|
2
|
+
class Image
|
3
|
+
|
4
|
+
attr_accessor :uri,
|
5
|
+
:type,
|
6
|
+
:uri150,
|
7
|
+
:width,
|
8
|
+
:height
|
9
|
+
|
10
|
+
def initialize(uri, type, uri150, width, height)
|
11
|
+
@uri = uri
|
12
|
+
@type = type
|
13
|
+
@uri150 = uri150
|
14
|
+
@width = width
|
15
|
+
@height = height
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
uri
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/label.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
module Discogs
|
2
|
+
class Label < Base
|
3
|
+
attr_accessor :name, :images, :contact_info, :profile, :urls, :parent, :sublabels, :releases
|
4
|
+
|
5
|
+
def initialize(request_string)
|
6
|
+
@request_string = request_string
|
7
|
+
super(@request_string, 'label')
|
8
|
+
end
|
9
|
+
|
10
|
+
def label
|
11
|
+
@label ||= (parsed/'label')
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
@name ||= (label/'name').inner_html
|
16
|
+
end
|
17
|
+
|
18
|
+
def images
|
19
|
+
@images ||= (label/'images'/'image').collect do |image|
|
20
|
+
Image.new(image.attributes['url'],
|
21
|
+
image.attributes['type'],
|
22
|
+
image.attributes['uri150'],
|
23
|
+
image.attributes['width'],
|
24
|
+
image.attributes['height'])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def contact_info
|
29
|
+
@contact_info ||= (label/'contactinfo').inner_html
|
30
|
+
end
|
31
|
+
|
32
|
+
def profile
|
33
|
+
@profile ||= (label/'profile').inner_html
|
34
|
+
end
|
35
|
+
|
36
|
+
def urls
|
37
|
+
@url ||= (label/'urls'/'url').collect { |url | url.inner_html }
|
38
|
+
end
|
39
|
+
|
40
|
+
def parent
|
41
|
+
@parent_label ||= begin
|
42
|
+
Label.new((label/'parentLabel').inner_html) unless (label/'parentLabel').empty?
|
43
|
+
rescue
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def sublabels
|
48
|
+
@sub_labels ||= begin
|
49
|
+
(label/'sublabels'/'label').collect do |label|
|
50
|
+
label = label.inner_html
|
51
|
+
Label.new(label) unless label.empty?
|
52
|
+
end
|
53
|
+
rescue
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def releases
|
58
|
+
@releases ||= begin
|
59
|
+
(label/'releases'/'release').collect do |release|
|
60
|
+
Release.new(release.attributes['id']) unless release.attributes['id'].empty?
|
61
|
+
end
|
62
|
+
rescue
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_s
|
67
|
+
name
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/release.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
module Discogs
|
2
|
+
class Release < Base
|
3
|
+
|
4
|
+
attr_accessor :discog_id,
|
5
|
+
:title,
|
6
|
+
:label,
|
7
|
+
:format,
|
8
|
+
:discog_status,
|
9
|
+
:genres,
|
10
|
+
:styles,
|
11
|
+
:formats,
|
12
|
+
:labels,
|
13
|
+
:country,
|
14
|
+
:released,
|
15
|
+
:tracks,
|
16
|
+
:images,
|
17
|
+
:contributors
|
18
|
+
|
19
|
+
def initialize(discog_id)
|
20
|
+
@discog_id = discog_id
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def discog_status
|
25
|
+
@discog_status ||= (parsed/'release').first.attributes['status']
|
26
|
+
end
|
27
|
+
|
28
|
+
def title
|
29
|
+
@title ||= (parsed/'title').first.inner_html
|
30
|
+
end
|
31
|
+
|
32
|
+
def labels
|
33
|
+
@labels ||= (parsed/'labels'/'label').collect { |label| label.attributes['name'] }
|
34
|
+
end
|
35
|
+
|
36
|
+
def genres
|
37
|
+
@genres ||= (parsed/'genres'/'genre').collect { |genre| genre.inner_html }
|
38
|
+
end
|
39
|
+
|
40
|
+
def styles
|
41
|
+
@styles ||= (parsed/'styles'/'style').collect{ |label| label.inner_html }
|
42
|
+
end
|
43
|
+
|
44
|
+
def country
|
45
|
+
@country ||= (parsed/'country').inner_html
|
46
|
+
end
|
47
|
+
|
48
|
+
def released
|
49
|
+
@released ||= (parsed/'released').inner_html
|
50
|
+
end
|
51
|
+
|
52
|
+
def formats
|
53
|
+
@formats ||= (parsed/'formats'/'format').collect do |format|
|
54
|
+
Format.new(format.attributes['name'], format.attributes['qty'])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def tracks
|
59
|
+
@tracks ||= (parsed/'tracklist'/'track').collect do |track|
|
60
|
+
Track.new((track/'position').inner_html,
|
61
|
+
(track/'title').inner_html,
|
62
|
+
(track/'duration').inner_html
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def images
|
68
|
+
@images ||= (parsed/'images'/'image').collect do |image|
|
69
|
+
Image.new(image.attributes['url'],
|
70
|
+
image.attributes['type'],
|
71
|
+
image.attributes['uri150'],
|
72
|
+
image.attributes['width'],
|
73
|
+
image.attributes['height'])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def contributors
|
78
|
+
@contributors ||= (parsed/'extraartists'/'artist').collect do |artist|
|
79
|
+
Contributor.new((artist/'name').inner_html, (artist/'role').inner_html)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_s
|
84
|
+
"#{title} - #{label} - #{released} - #{format}"
|
85
|
+
end
|
86
|
+
|
87
|
+
protected
|
88
|
+
def request_url
|
89
|
+
"#{DISCOGS_BASE_URL}/release/#{discog_id}?f=xml&api_key=#{api_key}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/search.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
module Discogs
|
2
|
+
class Search < Base
|
3
|
+
|
4
|
+
attr_accessor :exactresults,
|
5
|
+
:results,
|
6
|
+
:search_type,
|
7
|
+
:exactresult_size,
|
8
|
+
:result_size
|
9
|
+
|
10
|
+
def initialize(request_string)
|
11
|
+
@request_string = request_string
|
12
|
+
@search_type = 'all' # search_type doesn't seem to make any difference as of API v 1.0
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def exactresult_size
|
17
|
+
@exactresult_size ||= exactresults.size
|
18
|
+
end
|
19
|
+
|
20
|
+
def result_size
|
21
|
+
(parsed/'searchresults').first.attributes['end'].to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
def exactresults
|
25
|
+
(parsed/'exactresults'/'result').collect do |result|
|
26
|
+
SearchResult.new(
|
27
|
+
result.attributes['type'],
|
28
|
+
(result/'title').inner_html,
|
29
|
+
(result/'uri').inner_html,
|
30
|
+
(result/'summary').inner_html
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def results
|
37
|
+
(parsed/'searchresults'/'result').collect do |result|
|
38
|
+
SearchResult.new(
|
39
|
+
result.attributes['type'],
|
40
|
+
(result/'title').inner_html,
|
41
|
+
(result/'uri').inner_html,
|
42
|
+
(result/'summary').inner_html
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def best_match
|
48
|
+
first_result = exactresults.first
|
49
|
+
if first_result.artist?
|
50
|
+
artist = Discogs::Artist.new(api_key, first_result.title)
|
51
|
+
artist.releases[0,5]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
def request_url
|
57
|
+
"#{base_url}/search?type=#{search_type}&q=#{request_string}&f=xml&api_key=#{api_key}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class SearchResult
|
62
|
+
attr_accessor :type,
|
63
|
+
:title,
|
64
|
+
:uri,
|
65
|
+
:summary
|
66
|
+
|
67
|
+
def initialize(type, title, uri, summary = nil)
|
68
|
+
@type = type
|
69
|
+
@title = title
|
70
|
+
@uri = uri
|
71
|
+
@summary = summary
|
72
|
+
end
|
73
|
+
|
74
|
+
def method_missing(method, *args, &block)
|
75
|
+
type = method.to_s.match(/([a-zA-Z0-9_-]+)\?/)
|
76
|
+
# if type.size < 2 the method did not have a question mark at the end
|
77
|
+
super if type.size < 2
|
78
|
+
@type == type[1].to_s
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_s
|
82
|
+
"#{title}"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
data/lib/track.rb
ADDED
data/lib/util.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Discogs
|
2
|
+
class Util < Base
|
3
|
+
class << self
|
4
|
+
def run!
|
5
|
+
if ARGV.size < 1
|
6
|
+
usage
|
7
|
+
end
|
8
|
+
search = Discogs::Search.new(ARGV.join(' '))
|
9
|
+
puts search.best_match
|
10
|
+
end
|
11
|
+
|
12
|
+
def usage
|
13
|
+
puts "Usage:\n\tdiscogs Broken Social Scene"
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/artist_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Artist do
|
4
|
+
before do
|
5
|
+
artist_file = File.join(File.dirname(__FILE__), 'fixtures', 'artist.xml')
|
6
|
+
@artist_data = File.read(artist_file)
|
7
|
+
@artist = Discogs::Artist.new('Broken Social Scene')
|
8
|
+
@artist.should_receive(:fetched).and_return(@artist_data)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns name from xml data" do
|
12
|
+
@artist.name.should eql('Broken Social Scene')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns members from xml data" do
|
16
|
+
@artist.members.should eql(["Amy Millan", "Andrew Whiteman", "Brendan Canning", "Charles Spearin", "David Newfeld", "Emily Haines", "Evan Cranley", "Feist", "James Shaw", "Jason Collett", "Jo-Ann Goldsmith", "John Crossingham", "Julie Penner", "Justin Peroff", "Kevin Drew", "Lisa Lobsinger", "Martin Davis Kinack", "Ohad Benchetrit", "Torquil Campbell"])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns images from xml data" do
|
20
|
+
mock_image = mock('image')
|
21
|
+
Discogs::Image.should_receive(:new).twice.and_return(mock_image)
|
22
|
+
@artist.images.should eql([mock_image, mock_image])
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns url from xml data" do
|
26
|
+
@artist.urls.should eql(["http://www.arts-crafts.ca/bss/"])
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns releases from xml data" do
|
30
|
+
mock_release = mock('release')
|
31
|
+
Discogs::Release.should_receive(:new).at_least(59).times.and_return(mock_release)
|
32
|
+
@artist.releases.should eql([mock_release]*59)
|
33
|
+
end
|
34
|
+
end
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Base do
|
4
|
+
before do
|
5
|
+
artist_file = File.join(File.dirname(__FILE__), 'fixtures', 'artist.xml')
|
6
|
+
@artist_data = File.read(artist_file)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "obtains xml data via open-uri and zlib" do
|
10
|
+
base = Discogs::Base.new('Broken Social Scene')
|
11
|
+
mock_reader = mock('Zlib::GzipReader')
|
12
|
+
Zlib::GzipReader.should_receive(:new).and_return(mock_reader)
|
13
|
+
mock_reader.should_receive(:read).and_return(@artist_data)
|
14
|
+
mock_reader.should_receive(:close)
|
15
|
+
base.send(:fetched)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "finds the api_key from a yaml file" do
|
19
|
+
base = Discogs::Base.new
|
20
|
+
YAML.should_receive(:load).and_return({:api_key => '1234'})
|
21
|
+
base.send(:load_api_key).should eql('1234')
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<resp stat="ok" version="1.0" requests="432"><artist><images><image height="175" type="secondary" uri="http://www.discogs.com/image/A-138844-1107963722.jpg" uri150="http://www.discogs.com/image/A-150-138844-1107963722.jpg" width="324" /><image height="176" type="secondary" uri="http://www.discogs.com/image/A-138844-1107964548.jpg" uri150="http://www.discogs.com/image/A-150-138844-1107964548.jpg" width="272" /></images><name>Broken Social Scene</name><urls><url>http://www.arts-crafts.ca/bss/</url></urls><members><name>Amy Millan</name><name>Andrew Whiteman</name><name>Brendan Canning</name><name>Charles Spearin</name><name>David Newfeld</name><name>Emily Haines</name><name>Evan Cranley</name><name>Feist</name><name>James Shaw</name><name>Jason Collett</name><name>Jo-Ann Goldsmith</name><name>John Crossingham</name><name>Julie Penner</name><name>Justin Peroff</name><name>Kevin Drew</name><name>Lisa Lobsinger</name><name>Martin Davis Kinack</name><name>Ohad Benchetrit</name><name>Torquil Campbell</name></members><releases><release id="188365" status="Accepted" type="Main"><title>Feel Good Lost</title><format>CD</format><label>Noise Factory Records</label><year>2001</year></release><release id="470665" status="Accepted" type="Main"><title>You Forgot It In People</title><format>2xLP</format><label>Arts & Crafts International</label><year>2002</year></release><release id="642230" status="Accepted" type="Main"><title>You Forgot It In People</title><format>2xLP</format><label>Mercury</label><year>2002</year></release><release id="1181007" status="Accepted" type="Main"><title>Stars And Sons / KC Accidental</title><format>2x7", EP</format><label>Vertigo</label><year>2003</year></release><release id="392125" status="Accepted" type="Main"><title>You Forgot It In People</title><format>CD, Album</format><label>Arts & Crafts International</label><year>2003</year></release><release id="413953" status="Accepted" type="Main"><title>You Forgot It In People</title><format>CD</format><label>Mercury</label><year>2003</year></release><release id="1122350" status="Accepted" type="Main"><title>You Forgot It In People</title><format>CD, Album, Dig</format><label>Arts & Crafts International</label><year>2003</year></release><release id="396405" status="Accepted" type="Main"><title>Bee Hives</title><format>CD</format><label>Arts & Crafts International</label><year>2004</year></release><release id="397486" status="Accepted" type="Main"><title>Feel Good Lost</title><format>CD</format><label>Arts & Crafts International</label><year>2004</year></release><release id="532628" status="Accepted" type="Main"><title>Broken Social Scene</title><format>2xCD</format><label>Arts & Crafts International</label><year>2005</year></release><release id="565072" status="Accepted" type="Main"><title>Broken Social Scene</title><format>CD, Album, Dig</format><label>Arts & Crafts International</label><year>2005</year></release><release id="586824" status="Accepted" type="Main"><title>Broken Social Scene</title><format>2xLP</format><label>Arts & Crafts International</label><year>2005</year></release><release id="1008238" status="Accepted" type="Main"><title>Ibi Dreams Of Pavement (A Better Day)</title><format>7", Single</format><label>City Slang</label><year>2005</year></release><release id="1202405" status="Accepted" type="Main"><title>Ibi Dreams Of Pavement (A Better Day)</title><format>CD, Single, Promo</format><label>City Slang</label><year>2005</year></release><release id="671616" status="Accepted" type="Main"><title>7/4 (Shoreline)</title><format>CD, Maxi</format><label>City Slang</label><year>2006</year></release><release id="982408" status="Accepted" type="Main"><title>7/4 (Shoreline)</title><format>7", Single</format><label>City Slang</label><year>2006</year></release><release id="620688" status="Accepted" type="Main"><title>Broken Social Scene</title><format>2xLP</format><label>City Slang</label><year>2006</year></release><release id="622246" status="Accepted" type="Main"><title>Broken Social Scene</title><format>CD, Album, Dig</format><label>City Slang, City Slang</label><year>2006</year></release><release id="628959" status="Accepted" type="Main"><title>Broken Social Scene</title><format>CD + CD, Maxi</format><label>City Slang</label><year>2006</year></release><release id="1061762" status="Accepted" type="Main"><title>Feel Good Lost</title><format>CD, Enh</format><label>Pony Canyon Inc.</label><year>2006</year></release><release id="723943" status="Accepted" type="Main"><title>Fire Eye'd Boy</title><format>7"</format><label>City Slang</label><year>2006</year></release><release id="1245300" status="Accepted" type="Main"><title>Backed Out On The...</title><format>7", Single</format><label>Arts & Crafts International</label><year>2007</year></release><release id="1076879" status="Accepted" type="Main"><title>Spirit If...</title><format>CD, Album, Dig</format><label>Arts & Crafts International</label><year>2007</year></release><release id="1080528" status="Accepted" type="Main"><title>Spirit If...</title><format>CD, Album, Ltd</format><label>City Slang</label><year>2007</year></release><release id="1107034" status="Accepted" type="Main"><title>Spirit If...</title><format>CD, Album</format><label>City Slang</label><year>2007</year></release><release id="1160734" status="Accepted" type="Main"><title>Spirit If...</title><format>2xLP, Album</format><label>Arts & Crafts International</label><year>2007</year></release><release id="1245302" status="Accepted" type="Main"><title>Tbtf</title><format>7", Single, Whi</format><label>Arts & Crafts International</label><year>2007</year></release><release id="758993" status="Accepted" type="Appearance"><title>One Evening</title><format>10"</format><label>Polydor</label><year>2004</year></release><release id="1272907" status="Accepted" type="Appearance"><title>Wicker Park</title><trackinfo>Lover's Spit</trackinfo><format>CD, Album</format><label>Lakeshore Records</label><year>2004</year></release><release id="1058967" status="Accepted" type="Appearance"><title>Arts & Crafts Sampler Vol 4</title><trackinfo>TBTF, Cocaine Skin</trackinfo><format>CD, Smplr, Promo</format><label>Arts & Crafts International</label><year>2007</year></release><release id="1039487" status="Accepted" type="Appearance"><title>Untitled</title><trackinfo>Tbtf</trackinfo><format>CD</format><label>Spex Magazine</label><year>2007</year></release><release id="194316" status="Accepted" type="TrackAppearance"><title>Noise Factory: The Sampler</title><trackinfo>Last Place</trackinfo><format>CD</format><label>Noise Factory Records</label><year>2002</year></release><release id="597151" status="Accepted" type="TrackAppearance"><title>foehn006.</title><trackinfo>Love & Mathematics</trackinfo><format>2xCD</format><label>Foehn Records</label><year>2003</year></release><release id="537695" status="Accepted" type="TrackAppearance"><title>La Route Du Rock - La Compilation 2003</title><trackinfo>Almost Crimes (Radio K...</trackinfo><format>CD</format><label>La Route Du Rock</label><year>2003</year></release><release id="646202" status="Accepted" type="TrackAppearance"><title>Playlist: Volume 17</title><trackinfo>Stars And Sons</trackinfo><format>CD</format><label>HMV</label><year>2003</year></release><release id="732780" status="Accepted" type="TrackAppearance"><title>Queer As Folk (The Third Season)</title><trackinfo>Lover's Spit</trackinfo><format>CD + CD, Enh</format><label>Tommy Boy Music</label><year>2003</year></release><release id="250315" status="Accepted" type="TrackAppearance"><title>Like What Ya Heard?</title><trackinfo>Do The 95</trackinfo><format>CD</format><label>Caroline Records</label><year>2004</year></release><release id="249204" status="Accepted" type="TrackAppearance"><title>Noise Factory: Sampler Vol. 2</title><trackinfo>Love And Mathematics</trackinfo><format>CD</format><label>Noise Factory Records</label><year>2004</year></release><release id="758993" status="Accepted" type="TrackAppearance"><title>One Evening</title><trackinfo>Lover's Spit</trackinfo><format>10"</format><label>Polydor</label><year>2004</year></release><release id="1220265" status="Accepted" type="TrackAppearance"><title>See You On The Moon - Songs For Kids Of All Ages</title><trackinfo>Puff The Magic Dragon</trackinfo><format>CD</format><label>Paper Bag Records</label><year>2004</year></release><release id="259369" status="Accepted" type="TrackAppearance"><title>SPEX CD #41</title><trackinfo>KC Accidental</trackinfo><format>CD</format><label>Spex Magazine</label><year>2004</year></release><release id="1346279" status="Accepted" type="TrackAppearance"><title>The Cornerstone Player 041</title><trackinfo>Stars And Sons (Edit)</trackinfo><format>CD, Comp, Promo + CD, Comp, Mixed, Promo + DVD</format><label>Cornerstone Promotion</label><year>2004</year></release><release id="1058985" status="Accepted" type="TrackAppearance"><title>The Unending, Undying, & Often Unforgiving Pursuit Of Spring</title><trackinfo>Market Fresh</trackinfo><format>2xCD, Smplr</format><label>Caroline Records</label><year>2004</year></release><release id="1272907" status="Accepted" type="TrackAppearance"><title>Wicker Park</title><trackinfo>Lover's Spit</trackinfo><format>CD, Album</format><label>Lakeshore Records</label><year>2004</year></release><release id="1275602" status="Accepted" type="TrackAppearance"><title>New Noises Vol. 74</title><trackinfo>7/4 (Shoreline)</trackinfo><format>CD, Comp, Car</format><label>Rolling Stone (Germany)</label><year>2005</year></release><release id="1363312" status="Accepted" type="TrackAppearance"><title>Sampler Volume I</title><trackinfo>7/4 (Shoreline)</trackinfo><format>CD, Promo, Smplr</format><label>Cooperative Music</label><year>2005</year></release><release id="572438" status="Accepted" type="TrackAppearance"><title>Sounds - Now!</title><trackinfo>7/4 (Shoreline)</trackinfo><format>CD</format><label>Musikexpress</label><year>2005</year></release><release id="533198" status="Accepted" type="TrackAppearance"><title>SPEX CD #56</title><trackinfo>7/4 (Shoreline)</trackinfo><format>CD</format><label>Spex Magazine</label><year>2005</year></release><release id="556875" status="Accepted" type="TrackAppearance"><title>Visualität Und Pop</title><trackinfo>7/4 (Shoreline)</trackinfo><format>CD, Promo</format><label>Persona Non Grata, City Slang</label><year>2005</year></release><release id="769201" status="Accepted" type="TrackAppearance"><title>25 Jahre Spex</title><trackinfo>Ibi Dreams Of Pavement...</trackinfo><format>DVD</format><label>Spex Magazine</label><year>2006</year></release><release id="742092" status="Accepted" type="TrackAppearance"><title>Cooperative Music Sampler Volume 3</title><trackinfo>7/4 (Shoreline)</trackinfo><format>CD + DVD</format><label>Cooperative Music</label><year>2006</year></release><release id="622288" status="Accepted" type="TrackAppearance"><title>Fear Of Music</title><trackinfo>7/4 (Shorelines)</trackinfo><format>CD, Promo</format><label>V2 Records, Inc.</label><year>2006</year></release><release id="763616" status="Accepted" type="TrackAppearance"><title>Objectif 2006 - Vol. 2</title><trackinfo>7/4 Shoreline (Version...</trackinfo><format>CD</format><label>Les Inrockuptibles</label><year>2006</year></release><release id="1210574" status="Accepted" type="TrackAppearance"><title>Oh What A Feeling 3</title><trackinfo>Cause = Time</trackinfo><format>4xCD</format><label>EMI Music (Canada)</label><year>2006</year></release><release id="717519" status="Accepted" type="TrackAppearance"><title>Untitled</title><trackinfo>Fire Eye'd Boy</trackinfo><format>DVD</format><label>Spex Magazine</label><year>2006</year></release><release id="1058967" status="Accepted" type="TrackAppearance"><title>Arts & Crafts Sampler Vol 4</title><trackinfo>TBTF, Cocaine Skin</trackinfo><format>CD, Smplr, Promo</format><label>Arts & Crafts International</label><year>2007</year></release><release id="928773" status="Accepted" type="TrackAppearance"><title>Rough Trade Shops - Counter Culture 06</title><trackinfo>Fire Eye'd Boy</trackinfo><format>2xCD, Comp, Mixed</format><label>V2 Records, Inc.</label><year>2007</year></release><release id="1039487" status="Accepted" type="TrackAppearance"><title>Untitled</title><trackinfo>Tbtf</trackinfo><format>CD</format><label>Spex Magazine</label><year>2007</year></release><release id="977346" status="Accepted" type="TrackAppearance"><title>Warm & Scratchy</title><trackinfo>Canada vs. America</trackinfo><format>File, MP3, 256</format><label>[adult swim]</label><year>2007</year></release></releases></artist></resp>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<resp stat="ok" version="1.0" requests="435"><label><images><image height="107" type="primary" uri="http://www.discogs.com/image/L-14492-001.jpg" uri150="http://www.discogs.com/image/L-150-14492-001.jpg" width="139" /></images><name>Noise Factory Records</name><contactinfo>Tel: 416 787 3330
|
2
|
+
Fax: 416 787 3326
|
3
|
+
|
4
|
+
info@noisefactoryrecords.com
|
5
|
+
</contactinfo><profile>Toronto based indie &amp; electronic label.</profile><urls><url>http://www.noisefactoryrecords.com/</url></urls><releases><release id="194316" status="Accepted"><catno>NOISECD1011</catno><artist>Various</artist><title>Noise Factory: The Sampler</title><format>CD</format></release><release id="249204" status="Accepted"><catno>NOISECD10112</catno><artist>Various</artist><title>Noise Factory: Sampler Vol. 2</title><format>CD</format></release><release id="729928" status="Accepted"><catno>NOISECD10113</catno><artist>Various</artist><title>Noise Factory: Sampler Vol. 3</title><format>CD</format></release><release id="181634" status="Accepted"><catno>NOISECD255</catno><artist>Sparrow Orange</artist><title>The Beauty of Strangeness</title><format>CD</format></release><release id="190233" status="Accepted"><catno>NOISECD265</catno><artist>Sparrow Orange</artist><title>Hands And Knees Music</title><format>CD</format></release><release id="190214" status="Accepted"><catno>NOISECD325</catno><artist>K.C. Accidental</artist><title>Anthems For The Could've Bin Pills</title><format>CD, Album</format></release><release id="190213" status="Accepted"><catno>NOISECD326</catno><artist>K.C. Accidental</artist><title>Captured Anthems For An Empty Bathtub</title><format>CD, Album</format></release><release id="158973" status="Accepted"><catno>NOISECD361</catno><artist>Beef Terminal</artist><title>The Grey Knowledge</title><format>CD</format></release><release id="214163" status="Accepted"><catno>NOISECD362</catno><artist>Beef Terminal</artist><title>The Isolationist</title><format>CD</format></release><release id="556945" status="Accepted"><catno>NOISECD363</catno><artist>Beef Terminal</artist><title>Anger Do Not Enter</title><format>CD</format></release><release id="773657" status="Accepted"><catno>NOISECD401</catno><artist>Minisystem</artist><title>Madingley</title><format>CD</format></release><release id="215536" status="Accepted"><catno>NOISECD425</catno><artist>Various</artist><title>Beautiful Noise (The Apocalypse)</title><format>CD</format></release><release id="188365" status="Accepted"><catno>NOISECD526</catno><artist>Broken Social Scene</artist><title>Feel Good Lost</title><format>CD</format></release><release id="189535" status="Accepted"><catno>NOISECD551</catno><artist>Beef Terminal</artist><title>20 GOTO 10</title><format>CD</format></release><release id="189550" status="Accepted"><catno>NOISECD624</catno><artist>Tinkertoy</artist><title>Transatlantic Love Machine</title><format>CD</format></release><release id="328877" status="Accepted"><catno>NOISECD625</catno><artist>Tinkertoy</artist><title>Electric Wilderness</title><format>CD</format></release><release id="292600" status="Accepted"><catno>NOISECD720</catno><artist>Robin Judge</artist><title>Pattern</title><format>CD</format></release><release id="453376" status="Accepted"><catno>NOISECD752</catno><artist>Hexes & Ohs</artist><title>Goodbye Friend, Hello Lover</title><format>CD</format></release><release id="158560" status="Accepted"><catno>NOISECD826</catno><artist>Naw</artist><title>The Resound of a Foggy Autumn Dawn</title><format>CD</format></release><release id="335666" status="Accepted"><catno>NOISECD862</catno><artist>Naw</artist><title>Green Nights Orange Days</title><format>CD</format></release><release id="1025905" status="Accepted"><catno>NOISECD863</catno><artist>Naw</artist><title>City Saturate</title><format>CD, Album</format></release><release id="1235671" status="Accepted"><catno>none</catno><artist>Neon Tetra</artist><title>Home</title><format>File, Album, MP3</format></release></releases></label></resp>
|
@@ -0,0 +1 @@
|
|
1
|
+
<resp stat="ok" version="1.0" requests="320"><release id="188365" status="Accepted"><images><image height="300" type="secondary" uri="http://www.discogs.com/image/R-188365-1132696112.jpeg" uri150="http://www.discogs.com/image/R-150-188365-1132696112.jpeg" width="300" /></images><artists><artist><name>Broken Social Scene</name></artist></artists><title>Feel Good Lost</title><labels><label catno="NOISECD526" name="Noise Factory Records" /></labels><extraartists><artist><name>Noah Mintz</name><role>Mastered By</role></artist><artist><name>Charles Spearin</name><role>Mixed By</role></artist><artist><name>Ohad Benchetrit</name><role>Mixed By</role></artist><artist><name>Brendan Canning</name><role>Producer</role></artist><artist><name>Kevin Drew</name><role>Producer</role></artist><artist><name>Kevin Drew</name><role>Recorded By</role></artist></extraartists><formats><format name="CD" qty="1" /></formats><genres><genre>Rock</genre></genres><styles><style>Indie Rock</style><style>Experimental</style></styles><country>Canada</country><released>2001</released><tracklist><track><position>1</position><title>I Slept With Bonhomme At The CBC</title><duration>5:26</duration></track><track><position>2</position><title>Guilty Cubicles</title><duration>3:04</duration></track><track><position>3</position><title>Love And Mathematics</title><duration>5:44</duration></track><track><position>4</position><title>Passport Radio</title><extraartists><artist><name>Feist</name><role>Vocals</role></artist></extraartists><duration>5:45</duration></track><track><position>5</position><title>Alive In 85</title><duration>5:14</duration></track><track><position>6</position><title>Prison Province</title><duration>1:42</duration></track><track><position>7</position><title>Blues For Uncle Gibb</title><duration>6:59</duration></track><track><position>8</position><title>Stomach Song</title><duration>4:29</duration></track><track><position>9</position><title>Mossbraker</title><duration>5:33</duration></track><track><position>10</position><title>Feel Good Lost</title><duration>1:51</duration></track><track><position>11</position><title>Last Place</title><duration>8:26</duration></track><track><position>12</position><title>Cranley's Gonna Make It</title><duration>5:24</duration></track></tracklist></release></resp>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<resp requests="455" stat="ok" version="1.0"><exactresults><result num="1" type="artist"><title>Macha</title><uri>http://www.discogs.com/artist/Macha</uri></result><result num="2" type="artist"><title>Macha (2)</title><uri>http://www.discogs.com/artist/Macha+(2)</uri></result><result num="3" type="artist"><title>Macha (3)</title><uri>http://www.discogs.com/artist/Macha+(3)</uri></result></exactresults><searchresults end="20" numResults="49" start="1"><result num="1" type="artist"><title>Macha</title><uri>http://www.discogs.com/artist/Macha</uri><summary>Macha </summary></result><result num="2" type="artist"><title>La Macha</title><uri>http://www.discogs.com/artist/La+Macha</uri><summary>La Macha </summary></result><result num="3" type="artist"><title>Manoel Macha</title><uri>http://www.discogs.com/artist/Manoel+Macha</uri><summary>Manoel Macha </summary></result><result num="4" type="artist"><title>Macha Kouznetsova</title><uri>http://www.discogs.com/artist/Macha+Kouznetsova</uri><summary>Macha Kouznetsova </summary></result><result num="5" type="artist"><title>Macha (2)</title><uri>http://www.discogs.com/artist/Macha+(2)</uri><summary>Macha (2) </summary></result><result num="6" type="artist"><title>Macha Iitaka</title><uri>http://www.discogs.com/artist/Macha+Iitaka</uri><summary>Macha Iitaka </summary></result><result num="7" type="artist"><title>Macha (3)</title><uri>http://www.discogs.com/artist/Macha+(3)</uri><summary>Macha (3) </summary></result><result num="8" type="release"><title>Macha (3) - Macha</title><uri>http://www.discogs.com/release/1119487</uri><summary>Macha (3) Macha Jetset Records TWA17CD CD Album US 1998 Folk, World, & Country Rock Post Rock ... Master Mixed By 9 Joshua McKay Mixed By 9 Kai Riedl Mixed By 9 Macha (3) Mixed By 1 to 8, 10, 11 Mark Nevers</summary></result><result num="9" type="artist"><title>La Macha (2)</title><uri>http://www.discogs.com/artist/La+Macha+(2)</uri><summary>La Macha (2) </summary></result><result num="10" type="artist"><title>Karel Hynek Mácha</title><uri>http://www.discogs.com/artist/Karel+Hynek+M%C3%A1cha</uri><summary>Karel Hynek Mácha </summary></result><result num="11" type="release"><title>Macha - Calanza</title><uri>http://www.discogs.com/release/565215</uri><summary>Macha Calanza Meet Records MEET 241 Vinyl 12" Italy 1989 Electronic Techno Maurino & Charlie</summary></result><result num="12" type="release"><title>Macha (3) & Bedhead - Macha Loved Bedhead - Bedhead Loved Macha</title><uri>http://www.discogs.com/release/1114030</uri><summary>Macha (3) & Bedhead Macha Loved Bedhead - Bedhead Loved Macha Jetset Records TWA27CD CD EP US 25 ... , Bedhead Says. From Them To Us, Macha Says." Recorded in the homes of the Kadanes, Macha and Chris Bishop</summary></result><result num="13" type="release"><title>Macha (3) - Forget Tomorrow</title><uri>http://www.discogs.com/release/1121128</uri><summary>Macha (3) Forget Tomorrow Jetset Records TWA57CD CD Album US 2003 Rock Post Rock Indie Rock</summary></result><result num="14" type="release"><title>Rita, The
|
2
|
+
|
3
|
+
/
|
4
|
+
|
5
|
+
|
6
|
+
Goat - Macha Magall / The Night I Crushed Your Face</title><uri>http://www.discogs.com/release/997491</uri><summary>Rita, The / Goat Macha Magall / The Night I Crushed Your Face Deadline Recordings none CDr Limited ... Edition US 2007 Electronic Noise Rita, The Macha Magall Goat The Night I Crushed Your Face</summary></result><result num="15" type="release"><title>Atom Smasher - Honka Fonka</title><uri>http://www.discogs.com/release/196106</uri><summary> Honka Fonka Macha B Ascentia</summary></result><result num="16" type="release"><title>Pier Bucci - Familia Remix EP 2</title><uri>http://www.discogs.com/release/804193</uri><summary> Rebels Music Ltd. Published by Freibank Distributed by Amato Hay Consuelo (Original Edit) Macha (2 ... ) Vocals Instinct Hay Consuelo (Samim Remix) Samim Winiger Remix, Producer [Additional] Samim Macha (2</summary></result><result num="17" type="release"><title>Medeski Martin & Wood - Bubblehouse</title><uri>http://www.discogs.com/release/159957</uri><summary> DJ Logic Remix Macha Spy Kiss (10:00 PM Whr. R. Your Chldrn Mix) We™ Remix </summary></result><result num="18" type="release"><title>Spear Of Longinus - Domni Satnasi</title><uri>http://www.discogs.com/release/382503</uri><summary> Black Metal Masts Of Macha (Queen Of War) The Nomad Heretik I Am War What Is It, Aton? My Side Itches</summary></result><result num="19" type="release"><title>Spear Of Longinus - Domni Satnasi</title><uri>http://www.discogs.com/release/727494</uri><summary> Originally released as Domni Satnasi LP (Burznazg, 1997) Masts Of Macha (Queen Of War) The Nomad Heretik I Am</summary></result><result num="20" type="release"><title>Pier Bucci - Hay Consuelo</title><uri>http://www.discogs.com/release/1053208</uri><summary> Bucci Producer, Written-By Macha (2) Vocals Under exclusive license from Crosstown Rebel Music Ltd</summary></result></searchresults></resp>
|
data/spec/label_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Label do
|
4
|
+
before do
|
5
|
+
label_file = File.join(File.dirname(__FILE__), 'fixtures', 'label.xml')
|
6
|
+
@label_data = File.read(label_file)
|
7
|
+
@label = Discogs::Label.new('Noise Factory Records')
|
8
|
+
@label.should_receive(:fetched).and_return(@label_data)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns name from xml" do
|
12
|
+
@label.name.should eql('Noise Factory Records')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns images from xml" do
|
16
|
+
mock_image = mock('Image')
|
17
|
+
Discogs::Image.should_receive(:new).and_return(mock_image)
|
18
|
+
@label.images.should eql([mock_image])
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns contact_info from xml" do
|
22
|
+
@label.contact_info.should eql("Tel: 416 787 3330\nFax: 416 787 3326\n\ninfo@noisefactoryrecords.com\n")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns profile from xml" do
|
26
|
+
@label.profile.should eql('Toronto based indie &amp; electronic label.')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns urls from xml" do
|
30
|
+
@label.urls.should eql(["http://www.noisefactoryrecords.com/"])
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns parent from xml" do
|
34
|
+
label = Discogs::Label.should_not_receive(:new)
|
35
|
+
@label.parent.should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns sublabels from xml" do
|
39
|
+
label = Discogs::Label.should_not_receive(:new)
|
40
|
+
@label.sublabels.should be_empty
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns releases from xml" do
|
44
|
+
mock_release = mock('Release')
|
45
|
+
Discogs::Release.should_receive(:new).at_least(22).times.and_return(mock_release)
|
46
|
+
@label.releases.should eql([mock_release]*22)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Artist do
|
4
|
+
before do
|
5
|
+
@release = Discogs::Release.new('188365')
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "getters" do
|
9
|
+
before do
|
10
|
+
release_file = File.join(File.dirname(__FILE__), 'fixtures', 'release.xml')
|
11
|
+
@release_data = File.read(release_file)
|
12
|
+
@release.should_receive(:fetched).and_return(@release_data)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns discog_status from xml" do
|
16
|
+
@release.discog_status.should eql('Accepted')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns title from xml" do
|
20
|
+
@release.title.should eql('Feel Good Lost')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns labels from xml" do
|
24
|
+
@release.labels.should eql(["Noise Factory Records"])
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns genres from xml" do
|
28
|
+
@release.genres.should eql(['Rock'])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns styles from xml" do
|
32
|
+
@release.styles.should eql(['Indie Rock', 'Experimental'])
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns country from xml" do
|
36
|
+
@release.country.should eql('Canada')
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns release date from xml" do
|
40
|
+
@release.released.should eql('2001')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns formats from xml" do
|
44
|
+
mock_format = mock('Format')
|
45
|
+
Discogs::Format.should_receive(:new).and_return(mock_format)
|
46
|
+
@release.formats.should eql([mock_format])
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns tracks from xml" do
|
50
|
+
mock_track = mock('Track')
|
51
|
+
Discogs::Track.should_receive(:new).at_least(12).times.and_return(mock_track)
|
52
|
+
@release.tracks.should eql([mock_track]*12)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns images from xml" do
|
56
|
+
mock_image = mock('Image')
|
57
|
+
Discogs::Image.should_receive(:new).and_return(mock_image)
|
58
|
+
@release.images.should eql([mock_image])
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns contributors from xml" do
|
62
|
+
mock_contributor = mock('Contributor')
|
63
|
+
Discogs::Contributor.should_receive(:new).at_least(7).times.and_return(mock_contributor)
|
64
|
+
@release.contributors.should eql([mock_contributor]*7)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
it "constructs a url for release request" do
|
69
|
+
@release.api_key = 'foo'
|
70
|
+
@release.discog_id = '1234'
|
71
|
+
@release.send(:request_url).should eql('http://www.discogs.com/release/1234?f=xml&api_key=foo')
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/spec/search_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Discogs::Search do
|
4
|
+
before do
|
5
|
+
search_file = File.join(File.dirname(__FILE__), 'fixtures', 'search.xml')
|
6
|
+
@search_data = File.read(search_file)
|
7
|
+
@search = Discogs::Search.new('macha')
|
8
|
+
@search.should_receive(:fetched).and_return(@search_data)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns exact results " do
|
12
|
+
mock_result = mock('SearchResult')
|
13
|
+
Discogs::SearchResult.should_receive(:new).at_least(3).times.and_return(mock_result)
|
14
|
+
@search.exactresults.should eql([mock_result]*3)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "returns fuzzy results" do
|
18
|
+
mock_result = mock('SearchResult')
|
19
|
+
Discogs::SearchResult.should_receive(:new).at_least(20).times.and_return(mock_result)
|
20
|
+
@search.results.should eql([mock_result]*20)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns exact result size" do
|
24
|
+
@search.exactresult_size.should eql(3)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns fuzzy result size" do
|
28
|
+
@search.result_size.should eql(20)
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
4
|
+
require 'base'
|
5
|
+
require 'artist'
|
6
|
+
require 'label'
|
7
|
+
require 'release'
|
8
|
+
require 'format'
|
9
|
+
require 'image'
|
10
|
+
require 'track'
|
11
|
+
require 'contributor'
|
12
|
+
require 'search'
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: discogs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Stephenson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-07-13 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.7.0
|
24
|
+
version:
|
25
|
+
description: API Wrapper for discogs.org http://www.discogs.com/help/api
|
26
|
+
email:
|
27
|
+
- josh@joshstephenson.net
|
28
|
+
executables:
|
29
|
+
- discogs
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- Rakefile
|
41
|
+
- bin/discogs
|
42
|
+
- lib/discogs.rb
|
43
|
+
- lib/artist.rb
|
44
|
+
- lib/base.rb
|
45
|
+
- lib/contributor.rb
|
46
|
+
- lib/format.rb
|
47
|
+
- lib/image.rb
|
48
|
+
- lib/label.rb
|
49
|
+
- lib/release.rb
|
50
|
+
- lib/search.rb
|
51
|
+
- lib/track.rb
|
52
|
+
- lib/util.rb
|
53
|
+
- spec/artist_spec.rb
|
54
|
+
- spec/base_spec.rb
|
55
|
+
- spec/fixtures
|
56
|
+
- spec/fixtures/artist.xml
|
57
|
+
- spec/fixtures/label.xml
|
58
|
+
- spec/fixtures/release.xml
|
59
|
+
- spec/fixtures/search.xml
|
60
|
+
- spec/label_spec.rb
|
61
|
+
- spec/release_spec.rb
|
62
|
+
- spec/search_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://discogs.rubyforge.org
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options:
|
68
|
+
- --main
|
69
|
+
- README.txt
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: "0"
|
83
|
+
version:
|
84
|
+
requirements: []
|
85
|
+
|
86
|
+
rubyforge_project: discogs
|
87
|
+
rubygems_version: 1.2.0
|
88
|
+
signing_key:
|
89
|
+
specification_version: 2
|
90
|
+
summary: API Wrapper for discogs.org http://www.discogs.com/help/api
|
91
|
+
test_files: []
|
92
|
+
|