rbrainz 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +13 -1
- data/LICENSE +1 -1
- data/README +2 -2
- data/Rakefile +2 -2
- data/TODO +9 -2
- data/doc/README.rdoc +5 -5
- data/examples/getartist.rb +3 -2
- data/examples/getlabel.rb +3 -2
- data/examples/getrelease.rb +5 -2
- data/examples/getreleasegroup.rb +53 -0
- data/examples/gettrack.rb +3 -2
- data/examples/getuser.rb +2 -1
- data/examples/rate.rb +44 -0
- data/examples/searchartists.rb +3 -2
- data/examples/searchcdstubs.rb +41 -0
- data/examples/searchlabels.rb +3 -2
- data/examples/searchreleasegroups.rb +36 -0
- data/examples/searchreleases.rb +6 -4
- data/examples/searchtracks.rb +3 -2
- data/examples/submit_isrcs.rb +52 -0
- data/examples/tag.rb +3 -2
- data/lib/rbrainz.rb +2 -1
- data/lib/rbrainz/core_ext.rb +2 -1
- data/lib/rbrainz/core_ext/mbid.rb +2 -1
- data/lib/rbrainz/core_ext/net_http_digest.rb +3 -2
- data/lib/rbrainz/core_ext/range.rb +3 -2
- data/lib/rbrainz/core_ext/range/equality.rb +2 -1
- data/lib/rbrainz/data/countrynames.rb +6 -3
- data/lib/rbrainz/data/languagenames.rb +3 -2
- data/lib/rbrainz/data/releasetypenames.rb +3 -2
- data/lib/rbrainz/data/scriptnames.rb +3 -2
- data/lib/rbrainz/model.rb +3 -2
- data/lib/rbrainz/model/alias.rb +3 -2
- data/lib/rbrainz/model/artist.rb +11 -3
- data/lib/rbrainz/model/collection.rb +3 -2
- data/lib/rbrainz/model/default_factory.rb +18 -6
- data/lib/rbrainz/model/disc.rb +3 -2
- data/lib/rbrainz/model/entity.rb +2 -102
- data/lib/rbrainz/model/incomplete_date.rb +3 -2
- data/lib/rbrainz/model/individual.rb +11 -2
- data/lib/rbrainz/model/isrc.rb +100 -0
- data/lib/rbrainz/model/label.rb +5 -2
- data/lib/rbrainz/model/mbid.rb +28 -9
- data/lib/rbrainz/model/rateable.rb +34 -0
- data/lib/rbrainz/model/rating.rb +56 -0
- data/lib/rbrainz/model/relateable.rb +118 -0
- data/lib/rbrainz/model/relation.rb +2 -1
- data/lib/rbrainz/model/release.rb +17 -3
- data/lib/rbrainz/model/release_event.rb +3 -2
- data/lib/rbrainz/model/release_group.rb +97 -0
- data/lib/rbrainz/model/scored_collection.rb +3 -2
- data/lib/rbrainz/model/tag.rb +5 -4
- data/lib/rbrainz/model/taggable.rb +27 -0
- data/lib/rbrainz/model/track.rb +15 -2
- data/lib/rbrainz/model/user.rb +3 -2
- data/lib/rbrainz/utils.rb +2 -1
- data/lib/rbrainz/utils/data.rb +3 -2
- data/lib/rbrainz/utils/helper.rb +8 -2
- data/lib/rbrainz/version.rb +3 -2
- data/lib/rbrainz/webservice.rb +12 -7
- data/lib/rbrainz/webservice/filter.rb +53 -4
- data/lib/rbrainz/webservice/includes.rb +72 -11
- data/lib/rbrainz/webservice/mbxml.rb +129 -67
- data/lib/rbrainz/webservice/query.rb +156 -16
- data/lib/rbrainz/webservice/webservice.rb +104 -116
- data/test/lib/mock_webservice.rb +9 -2
- data/test/lib/test_entity.rb +2 -97
- data/test/lib/test_factory.rb +9 -1
- data/test/lib/test_rateable.rb +31 -0
- data/test/lib/test_relateable.rb +103 -0
- data/test/lib/test_taggable.rb +36 -0
- data/test/lib/testing_helper.rb +17 -2
- data/test/test-data/invalid/artist/ratings_1.xml +6 -0
- data/test/test-data/invalid/artist/ratings_2.xml +6 -0
- data/test/test-data/valid/artist/Tchaikovsky-2.xml +6 -0
- data/test/test-data/valid/label/Atlantic_Records_3.xml +6 -0
- data/test/test-data/valid/release-group/The_Cure_1.xml +36 -0
- data/test/test-data/valid/release/Highway_61_Revisited_2.xml +6 -0
- data/test/test-data/valid/track/Silent_All_These_Years_4.xml +3 -0
- data/test/test-data/valid/track/Silent_All_These_Years_6.xml +8 -0
- data/test/test_alias.rb +2 -1
- data/test/test_artist.rb +24 -2
- data/test/test_artist_filter.rb +2 -1
- data/test/test_artist_includes.rb +13 -3
- data/test/test_collection.rb +3 -2
- data/test/test_default_factory.rb +8 -1
- data/test/test_disc.rb +2 -1
- data/test/test_incomplete_date.rb +2 -1
- data/test/test_isrc.rb +87 -0
- data/test/test_label.rb +8 -1
- data/test/test_label_filter.rb +2 -1
- data/test/test_label_includes.rb +10 -3
- data/test/test_mbid.rb +2 -1
- data/test/test_mbxml.rb +93 -2
- data/test/test_query.rb +68 -5
- data/test/test_range_equality.rb +2 -1
- data/test/test_rating.rb +46 -0
- data/test/test_relation.rb +2 -1
- data/test/test_release.rb +37 -2
- data/test/test_release_event.rb +2 -1
- data/test/test_release_filter.rb +15 -2
- data/test/test_release_group.rb +104 -0
- data/test/test_release_group_filter.rb +61 -0
- data/test/test_release_group_includes.rb +46 -0
- data/test/test_release_includes.rb +16 -3
- data/test/test_scored_collection.rb +3 -2
- data/test/test_tag.rb +2 -1
- data/test/test_track.rb +28 -1
- data/test/test_track_filter.rb +2 -1
- data/test/test_track_includes.rb +13 -3
- data/test/test_utils.rb +2 -1
- data/test/test_webservice.rb +11 -1
- metadata +38 -20
- data/debian/changelog +0 -11
- data/debian/compat +0 -1
- data/debian/control +0 -13
- data/debian/copyright +0 -25
- data/debian/rules +0 -48
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: release.rb 278 2009-06-07 21:30:51Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -8,6 +9,9 @@
|
|
8
9
|
require 'rbrainz/model/entity'
|
9
10
|
require 'rbrainz/model/release_event'
|
10
11
|
require 'rbrainz/model/disc'
|
12
|
+
require 'rbrainz/model/rateable'
|
13
|
+
require 'rbrainz/model/relateable'
|
14
|
+
require 'rbrainz/model/taggable'
|
11
15
|
|
12
16
|
module MusicBrainz
|
13
17
|
module Model
|
@@ -26,6 +30,10 @@ module MusicBrainz
|
|
26
30
|
# for more information.
|
27
31
|
class Release < Entity
|
28
32
|
|
33
|
+
include Rateable
|
34
|
+
include Relateable
|
35
|
+
include Taggable
|
36
|
+
|
29
37
|
# A type for not a type. Currently unsupported by MusicBrainz
|
30
38
|
TYPE_NONE = NS_MMD_1 + 'None'
|
31
39
|
|
@@ -113,6 +121,9 @@ module MusicBrainz
|
|
113
121
|
# See:: Utils#get_script_name
|
114
122
|
attr_accessor :text_script
|
115
123
|
|
124
|
+
# The release group this release is part of.
|
125
|
+
attr_accessor :release_group
|
126
|
+
|
116
127
|
# The list of tracks.
|
117
128
|
attr_reader :tracks
|
118
129
|
|
@@ -138,6 +149,7 @@ module MusicBrainz
|
|
138
149
|
def initialize(id=nil, title=nil)
|
139
150
|
super id
|
140
151
|
self.title = title
|
152
|
+
@release_groups = Collection.new
|
141
153
|
@tracks = Collection.new
|
142
154
|
@release_events = Collection.new
|
143
155
|
@discs = Collection.new
|
@@ -153,9 +165,11 @@ module MusicBrainz
|
|
153
165
|
#
|
154
166
|
# Note that the release's artist has to be set (see #artist=)
|
155
167
|
# for this. The track artists may be unset.
|
168
|
+
#
|
169
|
+
# Raises:: RuntimeError
|
156
170
|
def single_artist_release?
|
157
171
|
raise 'Release Artist may not be None!' unless artist
|
158
|
-
tracks.all {|track| !track.artist || track.artist.id == artist.id }
|
172
|
+
tracks.all? {|track| !track.artist || track.artist.id == artist.id }
|
159
173
|
end
|
160
174
|
|
161
175
|
# Returns the earliest release date as an IncompleteDate.
|
@@ -194,4 +208,4 @@ module MusicBrainz
|
|
194
208
|
end
|
195
209
|
|
196
210
|
end
|
197
|
-
end
|
211
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: release_event.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -82,4 +83,4 @@ module MusicBrainz
|
|
82
83
|
end
|
83
84
|
|
84
85
|
end
|
85
|
-
end
|
86
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: release_group.rb 269 2009-05-24 22:15:27Z phw $
|
3
|
+
#
|
4
|
+
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
|
+
# Copyright:: Copyright (c) 2009, Philipp Wolfer
|
6
|
+
# License:: RBrainz is free software distributed under a BSD style license.
|
7
|
+
# See LICENSE[file:../LICENSE.html] for permissions.
|
8
|
+
|
9
|
+
require 'rbrainz/model/entity'
|
10
|
+
require 'rbrainz/model/release'
|
11
|
+
|
12
|
+
module MusicBrainz
|
13
|
+
module Model
|
14
|
+
|
15
|
+
#
|
16
|
+
# A release group in the MusicBrainz DB.
|
17
|
+
#
|
18
|
+
# A release group within MusicBrainz is an Entity which groups several
|
19
|
+
# different versions of releases (e.g. different editions of the same album).
|
20
|
+
#
|
21
|
+
# See:: http://wiki.musicbrainz.org/Release_Groups
|
22
|
+
class ReleaseGroup < Entity
|
23
|
+
|
24
|
+
# A type for not a type. Currently unsupported by MusicBrainz
|
25
|
+
TYPE_NONE = NS_MMD_1 + 'None'
|
26
|
+
|
27
|
+
# Special type for release groups that hold non-album track releases.
|
28
|
+
TYPE_NON_ALBUM_TRACKS = NS_MMD_1 + 'NonAlbum Track'
|
29
|
+
|
30
|
+
# An album, perhaps better defined as a "Long Play" (LP) release,
|
31
|
+
# generally consists of previously unreleased material. This includes
|
32
|
+
# release re-issues, with or without bonus tracks.
|
33
|
+
TYPE_ALBUM = NS_MMD_1 + 'Album'
|
34
|
+
# An audiobook is a book read by a narrator without music.
|
35
|
+
TYPE_AUDIOBOOK = NS_MMD_1 + 'Audiobook'
|
36
|
+
# A compilation is a collection of previously released tracks by one or
|
37
|
+
# more artists. Please note that this is a simplified description of a
|
38
|
+
# compilation.
|
39
|
+
TYPE_COMPILATION = NS_MMD_1 + 'Compilation'
|
40
|
+
# An EP is a so-called "Extended Play" release and often contains the
|
41
|
+
# letters EP in the title.
|
42
|
+
TYPE_EP = NS_MMD_1 + 'EP'
|
43
|
+
# An interview release contains an interview, generally with an Artist.
|
44
|
+
TYPE_INTERVIEW = NS_MMD_1 + 'Interview'
|
45
|
+
# A release that was recorded live.
|
46
|
+
TYPE_LIVE = NS_MMD_1 + 'Live'
|
47
|
+
# A release that primarily contains remixed material.
|
48
|
+
TYPE_REMIX = NS_MMD_1 + 'Remix'
|
49
|
+
# A single typically has one main song and possibly a handful of
|
50
|
+
# additional tracks or remixes of the main track. A single is usually
|
51
|
+
# named after its main song.
|
52
|
+
TYPE_SINGLE = NS_MMD_1 + 'Single'
|
53
|
+
# A soundtrack is the musical score to a movie, TV series, stage show,
|
54
|
+
# computer game etc.
|
55
|
+
TYPE_SOUNDTRACK = NS_MMD_1 + 'Soundtrack'
|
56
|
+
# Non-music spoken word releases.
|
57
|
+
TYPE_SPOKENWORD = NS_MMD_1 + 'Spokenword'
|
58
|
+
# Any release that does not fit or can't decisively be placed in any of
|
59
|
+
# the categories above.
|
60
|
+
TYPE_OTHER = NS_MMD_1 + 'Other'
|
61
|
+
|
62
|
+
# See Entity::ENTITY_TYPE.
|
63
|
+
ENTITY_TYPE = :release_group # :nodoc:
|
64
|
+
|
65
|
+
# The title of this release group.
|
66
|
+
attr_accessor :title
|
67
|
+
|
68
|
+
# A Collection of releases in this release group.
|
69
|
+
attr_reader :releases
|
70
|
+
|
71
|
+
# The artist of this release group.
|
72
|
+
attr_accessor :artist
|
73
|
+
|
74
|
+
# The list of types for this release.
|
75
|
+
#
|
76
|
+
# To test for release types, you can use the constants
|
77
|
+
# TYPE_ALBUM, TYPE_SINGLE, etc.
|
78
|
+
attr_reader :types
|
79
|
+
|
80
|
+
def initialize(id=nil, title=nil)
|
81
|
+
super id
|
82
|
+
@title = title
|
83
|
+
@releases = Collection.new
|
84
|
+
@types = Array.new
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns the string representation for this release group.
|
88
|
+
#
|
89
|
+
# Returns #title converted into a string.
|
90
|
+
def to_s
|
91
|
+
title.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: scored_collection.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -104,4 +105,4 @@ module MusicBrainz
|
|
104
105
|
end
|
105
106
|
|
106
107
|
end
|
107
|
-
end
|
108
|
+
end
|
data/lib/rbrainz/model/tag.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: tag.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -23,8 +24,8 @@ module MusicBrainz
|
|
23
24
|
attr_accessor :count
|
24
25
|
|
25
26
|
def initialize(text=nil, count=nil)
|
26
|
-
|
27
|
-
|
27
|
+
@text = text
|
28
|
+
@count = count
|
28
29
|
end
|
29
30
|
|
30
31
|
# Convert this tag into a String. Will return text.
|
@@ -35,4 +36,4 @@ module MusicBrainz
|
|
35
36
|
end
|
36
37
|
|
37
38
|
end
|
38
|
-
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: taggable.rb 266 2009-05-24 22:15:22Z phw $
|
3
|
+
#
|
4
|
+
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
5
|
+
# Copyright:: Copyright (c) 2009, Philipp Wolfer
|
6
|
+
# License:: RBrainz is free software distributed under a BSD style license.
|
7
|
+
# See LICENSE[file:../LICENSE.html] for permissions.
|
8
|
+
|
9
|
+
require 'rbrainz/model/tag'
|
10
|
+
|
11
|
+
module MusicBrainz
|
12
|
+
module Model
|
13
|
+
|
14
|
+
# Mixin module to add folksonomy tagging capabilities to Entity classes.
|
15
|
+
#
|
16
|
+
# see:: Tag
|
17
|
+
module Taggable
|
18
|
+
|
19
|
+
# Returns a Collection of Tag objects assigned to this entity.
|
20
|
+
def tags
|
21
|
+
@tags ||= Collection.new
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/rbrainz/model/track.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: track.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -6,6 +7,10 @@
|
|
6
7
|
# See LICENSE[file:../LICENSE.html] for permissions.
|
7
8
|
|
8
9
|
require 'rbrainz/model/entity'
|
10
|
+
require 'rbrainz/model/isrc'
|
11
|
+
require 'rbrainz/model/rateable'
|
12
|
+
require 'rbrainz/model/relateable'
|
13
|
+
require 'rbrainz/model/taggable'
|
9
14
|
|
10
15
|
module MusicBrainz
|
11
16
|
module Model
|
@@ -15,6 +20,10 @@ module MusicBrainz
|
|
15
20
|
# See:: http://musicbrainz.org/doc/Track.
|
16
21
|
class Track < Entity
|
17
22
|
|
23
|
+
include Rateable
|
24
|
+
include Relateable
|
25
|
+
include Taggable
|
26
|
+
|
18
27
|
# See Entity::ENTITY_TYPE.
|
19
28
|
ENTITY_TYPE = :track # :nodoc:
|
20
29
|
|
@@ -30,6 +39,9 @@ module MusicBrainz
|
|
30
39
|
# The list of associated PUIDs.
|
31
40
|
attr_reader :puids
|
32
41
|
|
42
|
+
# The list of associated ISRCs.
|
43
|
+
attr_reader :isrcs
|
44
|
+
|
33
45
|
# The releases on which this track appears.
|
34
46
|
attr_reader :releases
|
35
47
|
|
@@ -37,6 +49,7 @@ module MusicBrainz
|
|
37
49
|
super id
|
38
50
|
self.title = title
|
39
51
|
@puids = Collection.new
|
52
|
+
@isrcs = Collection.new
|
40
53
|
@releases = Collection.new
|
41
54
|
end
|
42
55
|
|
@@ -50,4 +63,4 @@ module MusicBrainz
|
|
50
63
|
end
|
51
64
|
|
52
65
|
end
|
53
|
-
end
|
66
|
+
end
|
data/lib/rbrainz/model/user.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: user.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Nigel Graham (mailto:nigel_graham@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -45,4 +46,4 @@ module MusicBrainz
|
|
45
46
|
end
|
46
47
|
|
47
48
|
end
|
48
|
-
end
|
49
|
+
end
|
data/lib/rbrainz/utils.rb
CHANGED
data/lib/rbrainz/utils/data.rb
CHANGED
data/lib/rbrainz/utils/helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: helper.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Nigel Graham, Philipp Wolfer
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -31,6 +32,11 @@ module MusicBrainz
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
# Converts an entity type constant symbol into the proper string representation
|
36
|
+
def entity_type_to_string(entity_type)
|
37
|
+
return entity_type.to_s.sub('_', '-')
|
38
|
+
end
|
39
|
+
|
34
40
|
# Check an options hash for required options.
|
35
41
|
# Raises an ArgumentError if unknown options are present in the hash.
|
36
42
|
def check_options(options, *optdecl) # :nodoc:
|
@@ -44,4 +50,4 @@ module MusicBrainz
|
|
44
50
|
end
|
45
51
|
|
46
52
|
end
|
47
|
-
end
|
53
|
+
end
|
data/lib/rbrainz/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: version.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Version information.
|
4
5
|
#
|
@@ -10,6 +11,6 @@
|
|
10
11
|
module MusicBrainz
|
11
12
|
|
12
13
|
# The version of the RBrainz library.
|
13
|
-
RBRAINZ_VERSION = '0.
|
14
|
+
RBRAINZ_VERSION = '0.5.0'
|
14
15
|
|
15
16
|
end
|
data/lib/rbrainz/webservice.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: webservice.rb 254 2009-05-13 20:04:36Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -20,20 +21,24 @@ module MusicBrainz # :nodoc:
|
|
20
21
|
#
|
21
22
|
# See:: Model
|
22
23
|
module Webservice
|
24
|
+
|
25
|
+
# Base exception class for all webservice errors.
|
26
|
+
class WebserviceError < ::Exception
|
27
|
+
end
|
23
28
|
|
24
29
|
# Connecting to the web service failed.
|
25
30
|
#
|
26
31
|
# This exception is raised if the connection to the server can not be
|
27
32
|
# established due to networking problems (e.g. wrong port number or
|
28
33
|
# server down).
|
29
|
-
class ConnectionError <
|
34
|
+
class ConnectionError < WebserviceError
|
30
35
|
end
|
31
36
|
|
32
37
|
# An invalid request was made.
|
33
38
|
#
|
34
39
|
# This exception is raised if the client made an invalid request. That could
|
35
40
|
# be syntactically invalid identifiers or unknown or invalid parameter values.
|
36
|
-
class RequestError <
|
41
|
+
class RequestError < WebserviceError
|
37
42
|
end
|
38
43
|
|
39
44
|
# Client requested a resource which requires authentication via HTTP
|
@@ -41,11 +46,11 @@ module MusicBrainz # :nodoc:
|
|
41
46
|
#
|
42
47
|
# If sent even though user name and password were given: user name and/or
|
43
48
|
# password are incorrect.
|
44
|
-
class AuthenticationError <
|
49
|
+
class AuthenticationError < WebserviceError
|
45
50
|
end
|
46
51
|
|
47
52
|
# The requested resource doesn't exist.
|
48
|
-
class ResourceNotFoundError <
|
53
|
+
class ResourceNotFoundError < WebserviceError
|
49
54
|
end
|
50
55
|
|
51
56
|
# The returned resource was invalid.
|
@@ -53,10 +58,10 @@ module MusicBrainz # :nodoc:
|
|
53
58
|
# This may be due to a malformed XML document or if the requested data
|
54
59
|
# wasn't part of the response. It can only occur in case of bugs in the web
|
55
60
|
# service itself.
|
56
|
-
class ResponseError <
|
61
|
+
class ResponseError < WebserviceError
|
57
62
|
end
|
58
63
|
|
59
64
|
end
|
60
65
|
end
|
61
66
|
|
62
|
-
require 'rbrainz/webservice/query'
|
67
|
+
require 'rbrainz/webservice/query'
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: filter.rb 264 2009-05-24 22:15:19Z phw $
|
2
3
|
#
|
3
4
|
# Author:: Philipp Wolfer (mailto:phw@rubyforge.org)
|
4
5
|
# Copyright:: Copyright (c) 2007, Nigel Graham, Philipp Wolfer
|
@@ -70,6 +71,50 @@ module MusicBrainz
|
|
70
71
|
|
71
72
|
end
|
72
73
|
|
74
|
+
# A filter for the release group collection.
|
75
|
+
class ReleaseGroupFilter < AbstractFilter
|
76
|
+
|
77
|
+
# The parameter _filter_ is a hash with filter options. At least one
|
78
|
+
# filter despite <tt>:limit</tt> and <tt>:offset</tt> must be specified.
|
79
|
+
#
|
80
|
+
# Available filter options:
|
81
|
+
# [:title] Fetch a list of release groups with a matching title.
|
82
|
+
# [:artist] The returned release groups should match the given artist name.
|
83
|
+
# [:artistid] The returned releasegroups should match the given artist ID
|
84
|
+
# (36 character ASCII representation). If this is given,
|
85
|
+
# the artist parameter is ignored.
|
86
|
+
# [:releasetypes] The returned release groups must match all of the given
|
87
|
+
# release types. This is either an array of release types
|
88
|
+
# as defined in Model::ReleaseGroup or a string of space separated
|
89
|
+
# values like Official, Bootleg, Album, Compilation etc.
|
90
|
+
# [:limit] The maximum number of release groups returned. Defaults
|
91
|
+
# to 25, the maximum allowed value is 100.
|
92
|
+
# [:offset] Return search results starting at a given offset. Used
|
93
|
+
# for paging through more than one page of results.
|
94
|
+
# [:query] A Lucene search query. The query parameter is a search
|
95
|
+
# string which will be passed to the underlying Lucene search
|
96
|
+
# engine. It must follow the syntax described in
|
97
|
+
# http://musicbrainz.org/doc/TextSearchSyntax.
|
98
|
+
def initialize(filter)
|
99
|
+
Utils.check_options filter,
|
100
|
+
:limit, :offset, :query, :title, :artist, :artistid, :releasetypes
|
101
|
+
super(filter)
|
102
|
+
@filter[:title] = filter[:title] if filter[:title]
|
103
|
+
@filter[:artist] = filter[:artist] if filter[:artist]
|
104
|
+
@filter[:artistid] = filter[:artistid] if filter[:artistid]
|
105
|
+
|
106
|
+
if releasetypes = filter[:releasetypes]
|
107
|
+
if releasetypes.respond_to?(:to_a)
|
108
|
+
releasetypes = releasetypes.to_a.map do |type|
|
109
|
+
Utils.remove_namespace(type)
|
110
|
+
end.join(' ')
|
111
|
+
end
|
112
|
+
@filter[:releasetypes] = releasetypes
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
73
118
|
# A filter for the release collection.
|
74
119
|
class ReleaseFilter < AbstractFilter
|
75
120
|
|
@@ -92,7 +137,9 @@ module MusicBrainz
|
|
92
137
|
# [:asin] The Amazon ASIN.
|
93
138
|
# [:lang] The language for this release.
|
94
139
|
# [:script] The script used in this release.
|
95
|
-
# [:
|
140
|
+
# [:cdstubs] Flag which indicates whether to include CD stubs or not (boolean).
|
141
|
+
# Defaults to false.
|
142
|
+
# [:limit] The maximum number of releases returned. Defaults
|
96
143
|
# to 25, the maximum allowed value is 100.
|
97
144
|
# [:offset] Return search results starting at a given offset. Used
|
98
145
|
# for paging through more than one page of results.
|
@@ -103,7 +150,7 @@ module MusicBrainz
|
|
103
150
|
def initialize(filter)
|
104
151
|
Utils.check_options filter,
|
105
152
|
:limit, :offset, :query, :title, :discid, :artist, :artistid,
|
106
|
-
:releasetypes, :count, :date, :asin, :lang, :script
|
153
|
+
:releasetypes, :count, :date, :asin, :lang, :script, :cdstubs
|
107
154
|
super(filter)
|
108
155
|
@filter[:title] = filter[:title] if filter[:title]
|
109
156
|
@filter[:discid] = filter[:discid] if filter[:discid]
|
@@ -115,6 +162,8 @@ module MusicBrainz
|
|
115
162
|
@filter[:lang] = filter[:lang] if filter[:lang]
|
116
163
|
@filter[:script] = filter[:script] if filter[:script]
|
117
164
|
|
165
|
+
@filter[:cdstubs] = filter[:cdstubs] ? 'yes' : 'no'
|
166
|
+
|
118
167
|
if releasetypes = filter[:releasetypes]
|
119
168
|
if releasetypes.respond_to?(:to_a)
|
120
169
|
releasetypes = releasetypes.to_a.map do |type|
|
@@ -218,4 +267,4 @@ module MusicBrainz
|
|
218
267
|
end
|
219
268
|
|
220
269
|
end
|
221
|
-
end
|
270
|
+
end
|