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
data/CHANGES
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
|
+
== 0.5.0 (2009-06-14)
|
4
|
+
* NEW: Support for release groups
|
5
|
+
* NEW: Support for ISRCs, including ISRC submission
|
6
|
+
* NEW: Support for ratings, including rating submission
|
7
|
+
* NEW: Common exception class for all web service errors
|
8
|
+
* NEW: Updated language list
|
9
|
+
* NEW: Allow exclusion of CD stubs in ReleaseFilter
|
10
|
+
* BUG: Added source file encodings for Ruby 1.9 compatibillity
|
11
|
+
* BUG: Fixed Release#single_artist_release?
|
12
|
+
* BUG: Added all missing include options for artists
|
13
|
+
* BUG: Always raise a ConnectionError for unknown errors in the web service
|
14
|
+
|
3
15
|
== 0.4.2 (2008-09-04)
|
4
16
|
* BUG: Fixed proxy authentication
|
5
17
|
* BUG: Fixed raising of ResponseError in Query#get_user_by_name
|
@@ -65,4 +77,4 @@
|
|
65
77
|
== 0.1.0 (2007-05-23)
|
66
78
|
* Initial release
|
67
79
|
|
68
|
-
$Id: CHANGES
|
80
|
+
$Id: CHANGES 280 2009-06-14 20:58:18Z phw $
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
RBrainz is Copyright (c) 2007 Philipp Wolfer and Nigel Graham.
|
1
|
+
RBrainz is Copyright (c) 2007-2009 Philipp Wolfer and 2007 Nigel Graham.
|
2
2
|
|
3
3
|
Redistribution and use in source and binary forms, with or without
|
4
4
|
modification, are permitted provided that the following conditions
|
data/README
CHANGED
@@ -7,6 +7,6 @@ To generate the complete RBrainz documentation run
|
|
7
7
|
|
8
8
|
The documentation will be stored in doc/api.
|
9
9
|
|
10
|
-
RBrainz is Copyright (c) 2007 Philipp Wolfer and Nigel Graham.
|
10
|
+
RBrainz is Copyright (c) 2007-2009 Philipp Wolfer and 2007 Nigel Graham.
|
11
11
|
It is free softare distributed under a BSD style license. See
|
12
|
-
LICENSE for details.
|
12
|
+
LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# $Id: Rakefile 274 2009-05-24 22:44:42Z phw $
|
2
3
|
# Copyright (c) 2007, Philipp Wolfer
|
3
4
|
# All rights reserved.
|
4
5
|
# See LICENSE for permissions.
|
@@ -25,7 +26,6 @@ PKG_FILES = FileList[
|
|
25
26
|
"lib/**/*.rb",
|
26
27
|
"test/**/*.rb",
|
27
28
|
"test/test-data/**/*",
|
28
|
-
"debian/*"
|
29
29
|
]
|
30
30
|
PKG_EXTRA_RDOC_FILES = ['doc/README.rdoc', 'LICENSE', 'TODO', 'CHANGES']
|
31
31
|
|
data/TODO
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
= TODO
|
2
2
|
|
3
|
+
== 0.5 release
|
4
|
+
* Add i18n (nigel)
|
5
|
+
* Test all examples
|
6
|
+
|
3
7
|
== Short term tasks
|
8
|
+
* Add mass submission API for tags and ratings.
|
9
|
+
* CD stub submission
|
10
|
+
* Support music collection WS.
|
4
11
|
* Improve API documentation.
|
5
12
|
|
6
13
|
== Longer term tasks
|
7
14
|
* Implement a command line tool (+mbquery+) for querying the MusicBrainz
|
8
|
-
database which will serve as a
|
15
|
+
database which will serve as a useful example for RBrainz.
|
9
16
|
* Support for common extensions (this could be implemented by adding
|
10
17
|
additional extension libraries which extend the existing classes).
|
11
18
|
|
12
|
-
$Id: TODO
|
19
|
+
$Id: TODO 277 2009-05-25 19:33:26Z phw $
|
data/doc/README.rdoc
CHANGED
@@ -9,8 +9,8 @@ used to PythonMusicBrainz2 should already know most of RBrainz' interface.
|
|
9
9
|
However, RBrainz differs from PythonMusicBrainz2 wherever it makes the
|
10
10
|
library more Ruby like or easier to use.
|
11
11
|
|
12
|
-
RBrainz supports the MusicBrainz XML Metadata Version 1.
|
13
|
-
for labels
|
12
|
+
RBrainz supports the MusicBrainz XML Metadata Version 1.4, including support
|
13
|
+
for labels, extended release events, release groups and ratings.
|
14
14
|
|
15
15
|
== Installation
|
16
16
|
=== Installing with RubyGems
|
@@ -92,12 +92,12 @@ If you find bugs or if you have any feature requests please use the
|
|
92
92
|
RBrainz bug tracker[http://rubyforge.org/tracker/?group_id=3677].
|
93
93
|
|
94
94
|
== Authors
|
95
|
-
* Nigel Graham
|
96
95
|
* Philipp Wolfer
|
96
|
+
* Nigel Graham
|
97
97
|
|
98
98
|
== License
|
99
|
-
RBrainz is Copyright (c) 2007 Philipp Wolfer and Nigel Graham.
|
99
|
+
RBrainz is Copyright (c) 2007-2009 Philipp Wolfer and 2007 Nigel Graham.
|
100
100
|
It is free softare distributed under a BSD style license. See
|
101
101
|
LICENSE[link:files/LICENSE.html] for details.
|
102
102
|
|
103
|
-
$Id: README.rdoc
|
103
|
+
$Id: README.rdoc 252 2009-05-13 19:21:28Z phw $
|
data/examples/getartist.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which queries the database for an
|
4
5
|
# artist and displays the artist's data.
|
5
6
|
#
|
6
|
-
# $Id: getartist.rb
|
7
|
+
# $Id: getartist.rb 273 2009-05-24 22:29:04Z phw $
|
7
8
|
|
8
9
|
# Just make sure we can run this example from the command
|
9
10
|
# line even if RBrainz is not yet installed properly.
|
@@ -53,4 +54,4 @@ Begin date : #{artist.begin_date}
|
|
53
54
|
End date : #{artist.end_date}
|
54
55
|
Aliases : #{artist.aliases.to_a.join('; ')}
|
55
56
|
Releases : #{artist.releases.map{|r| r.title}.uniq.join("\r\n ")}
|
56
|
-
EOF
|
57
|
+
EOF
|
data/examples/getlabel.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which queries the database for an
|
4
5
|
# label and displays the label's data.
|
5
6
|
#
|
6
|
-
# $Id: getlabel.rb
|
7
|
+
# $Id: getlabel.rb 254 2009-05-13 20:04:36Z phw $
|
7
8
|
|
8
9
|
# Just make sure we can run this example from the command
|
9
10
|
# line even if RBrainz is not yet installed properly.
|
@@ -50,4 +51,4 @@ Type : #{label.type}
|
|
50
51
|
Begin date : #{label.begin_date}
|
51
52
|
End date : #{label.end_date}
|
52
53
|
Aliases : #{label.aliases.to_a.join('; ')}
|
53
|
-
EOF
|
54
|
+
EOF
|
data/examples/getrelease.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which queries the database for an
|
4
5
|
# release and displays the release's data.
|
5
6
|
#
|
6
|
-
# $Id: getrelease.rb
|
7
|
+
# $Id: getrelease.rb 278 2009-06-07 21:30:51Z phw $
|
7
8
|
|
8
9
|
# Just make sure we can run this example from the command
|
9
10
|
# line even if RBrainz is not yet installed properly.
|
@@ -28,6 +29,7 @@ mbid = Model::MBID.parse(id, :release)
|
|
28
29
|
release_includes = Webservice::ReleaseIncludes.new(
|
29
30
|
:artist => true,
|
30
31
|
:tracks => true,
|
32
|
+
:release_groups => true,
|
31
33
|
:release_events => true
|
32
34
|
)
|
33
35
|
|
@@ -47,10 +49,11 @@ print <<EOF
|
|
47
49
|
ID : #{release.id.uuid}
|
48
50
|
Title : #{release.title}
|
49
51
|
Artist : #{release.artist.unique_name}
|
52
|
+
Release Group : #{release.release_group.title}
|
50
53
|
Tracks : #{release.tracks.to_a.join("\r\n ")}
|
51
54
|
Release Events:
|
52
55
|
EOF
|
53
56
|
|
54
57
|
release.release_events.each do |event|
|
55
58
|
puts "#{event.date} #{Utils.get_country_name(event.country)}"
|
56
|
-
end
|
59
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# Example script which queries the database for a
|
5
|
+
# release group and displays the release group's data.
|
6
|
+
#
|
7
|
+
# $Id: getreleasegroup.rb 276 2009-05-24 23:37:18Z phw $
|
8
|
+
|
9
|
+
# Just make sure we can run this example from the command
|
10
|
+
# line even if RBrainz is not yet installed properly.
|
11
|
+
$: << 'lib/' << '../lib/'
|
12
|
+
|
13
|
+
# Load RBrainz and include the MusicBrainz namespace.
|
14
|
+
require 'rbrainz'
|
15
|
+
include MusicBrainz
|
16
|
+
|
17
|
+
# The release's MusicBrainz ID.
|
18
|
+
# Either read it from the command line as the first
|
19
|
+
# parameter or use a default one for demonstration.
|
20
|
+
id = $*[0] ? $*[0] : 'a07cbaff-aa79-35a9-9932-af7335f306eb'
|
21
|
+
|
22
|
+
# Generate a new release MBID object from the ID:
|
23
|
+
mbid = Model::MBID.parse(id, :release_group)
|
24
|
+
|
25
|
+
# Define what information about the release group
|
26
|
+
# should be included in the result.
|
27
|
+
# In this case the release group's artist and and
|
28
|
+
# releases will be fetched as well.
|
29
|
+
release_group_includes = Webservice::ReleaseGroupIncludes.new(
|
30
|
+
:artist => true,
|
31
|
+
:releases => true
|
32
|
+
)
|
33
|
+
|
34
|
+
# Create a new Query object which will provide
|
35
|
+
# us an interface to the MusicBrainz web service.
|
36
|
+
query = Webservice::Query.new
|
37
|
+
|
38
|
+
# Now query the MusicBrainz database for the release
|
39
|
+
# group with the MBID defined above.
|
40
|
+
# We could as well use the ID string directly instead
|
41
|
+
# of the MBID object.
|
42
|
+
release_group = query.get_release_group_by_id(mbid, release_group_includes)
|
43
|
+
|
44
|
+
# Display the fetched release group data together with all
|
45
|
+
# unique release titles.
|
46
|
+
print <<EOF
|
47
|
+
ID : #{release_group.id.uuid}
|
48
|
+
Title : #{release_group.title}
|
49
|
+
Types : #{release_group.types.to_a.join(", ")}
|
50
|
+
Artist : #{release_group.artist.unique_name}
|
51
|
+
Releases : #{release_group.releases.to_a.join("\r\n ")}
|
52
|
+
EOF
|
53
|
+
|
data/examples/gettrack.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which queries the database for an
|
4
5
|
# track and displays the track's data.
|
5
6
|
#
|
6
|
-
# $Id: gettrack.rb
|
7
|
+
# $Id: gettrack.rb 254 2009-05-13 20:04:36Z phw $
|
7
8
|
|
8
9
|
# Just make sure we can run this example from the command
|
9
10
|
# line even if RBrainz is not yet installed properly.
|
@@ -48,4 +49,4 @@ Title : #{track.title}
|
|
48
49
|
Duration : #{track.duration/1000} seconds
|
49
50
|
Artist : #{track.artist.unique_name}
|
50
51
|
Release : #{track.releases.to_a.join("\r\n ")}
|
51
|
-
EOF
|
52
|
+
EOF
|
data/examples/getuser.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which queries the database for a user.
|
4
5
|
#
|
5
|
-
# $Id: getuser.rb
|
6
|
+
# $Id: getuser.rb 273 2009-05-24 22:29:04Z phw $
|
6
7
|
|
7
8
|
# Just make sure we can run this example from the command
|
8
9
|
# line even if RBrainz is not yet installed properly.
|
data/examples/rate.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# Example script showing the use of ratings with RBrainz.
|
5
|
+
# It asks the user for his username and password and a MBID and queries the
|
6
|
+
# MusicBrainz server for the rating, the user has applied to the entitity with
|
7
|
+
# the given MBID. Afterwards the user can submit a new rating.
|
8
|
+
#
|
9
|
+
# $Id: rate.rb 273 2009-05-24 22:29:04Z phw $
|
10
|
+
|
11
|
+
# Just make sure we can run this example from the command
|
12
|
+
# line even if RBrainz is not yet installed properly.
|
13
|
+
$: << 'lib/' << '../lib/'
|
14
|
+
|
15
|
+
# Load RBrainz and include the MusicBrainz namespace.
|
16
|
+
require 'rbrainz'
|
17
|
+
include MusicBrainz
|
18
|
+
|
19
|
+
# Get the username and password
|
20
|
+
print 'Username: ' unless ARGV[0]
|
21
|
+
username = ARGV[0] ? ARGV[0] : STDIN.gets.strip
|
22
|
+
print 'Password: ' unless ARGV[1]
|
23
|
+
password = ARGV[1] ? ARGV[1] : STDIN.gets.strip
|
24
|
+
|
25
|
+
# Ask for a MBID to tag. The MBID must be a complete MusicBrainz identifier,
|
26
|
+
# e.g. http://musicbrainz.org/release/6785cad0-159c-40ec-9ee4-30d8745dd7f9
|
27
|
+
print 'Enter a MBID: '
|
28
|
+
mbid = Model::MBID.new(STDIN.gets.strip)
|
29
|
+
|
30
|
+
# Set the authentication for the webservice.
|
31
|
+
ws = Webservice::Webservice.new(:username=>username, :password=>password)
|
32
|
+
|
33
|
+
# Create a new Query object which will provide
|
34
|
+
# us an interface to the MusicBrainz web service.
|
35
|
+
query = Webservice::Query.new(ws, :client_id => 'RBrainz test ' + RBRAINZ_VERSION)
|
36
|
+
|
37
|
+
# Read and print the current rating for the given MBID.
|
38
|
+
rating = query.get_user_rating(mbid)
|
39
|
+
print "Current rating: #{rating.to_s}"
|
40
|
+
|
41
|
+
# Ask the user for a new rating and submit it.
|
42
|
+
print 'Enter new rating: '
|
43
|
+
new_rating = STDIN.gets.strip
|
44
|
+
query.submit_user_rating(mbid, new_rating.to_i)
|
data/examples/searchartists.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which searches the database for
|
4
5
|
# artists and displays the artist's data.
|
5
6
|
#
|
6
|
-
# $Id: searchartists.rb
|
7
|
+
# $Id: searchartists.rb 273 2009-05-24 22:29:04Z phw $
|
7
8
|
|
8
9
|
# Just make sure we can run this example from the command
|
9
10
|
# line even if RBrainz is not yet installed properly.
|
@@ -32,4 +33,4 @@ artists = query.get_artists(artist_filter)
|
|
32
33
|
# indicates how good the artist matches the search parameters.
|
33
34
|
artists.each do |entry|
|
34
35
|
print "%s (%i%%)\r\n" % [entry.entity.unique_name, entry.score]
|
35
|
-
end
|
36
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# Example script which searches the database for
|
5
|
+
# releases by disc ID, including CD stubs.
|
6
|
+
#
|
7
|
+
# For more information about CD stubs see http://wiki.musicbrainz.org/CDStub
|
8
|
+
#
|
9
|
+
# $Id: searchcdstubs.rb 273 2009-05-24 22:29:04Z phw $
|
10
|
+
|
11
|
+
# Just make sure we can run this example from the command
|
12
|
+
# line even if RBrainz is not yet installed properly.
|
13
|
+
$: << 'lib/' << '../lib/'
|
14
|
+
|
15
|
+
# Load RBrainz and include the MusicBrainz namespace.
|
16
|
+
require 'rbrainz'
|
17
|
+
include MusicBrainz
|
18
|
+
|
19
|
+
# Define the search parameters: Search for releases with the given disc ID
|
20
|
+
# (which is a special disc ID for DVD releases and only available as a CD stub),
|
21
|
+
# make sure to include CD stubs and return a maximum of 10 releases.
|
22
|
+
release_filter = Webservice::ReleaseFilter.new(
|
23
|
+
:discid => 'flplyXqMOiodZEDJeDw5Ci6OD_g-',
|
24
|
+
:cdstubs => true,
|
25
|
+
:limit => 10
|
26
|
+
)
|
27
|
+
|
28
|
+
# Create a new Query object which will provide
|
29
|
+
# us an interface to the MusicBrainz web service.
|
30
|
+
query = Webservice::Query.new
|
31
|
+
|
32
|
+
# Now query the MusicBrainz database for releases
|
33
|
+
# with the search parameters defined above.
|
34
|
+
releases = query.get_releases(release_filter)
|
35
|
+
|
36
|
+
# Display the fetched release titles and their tracks
|
37
|
+
releases.each do |entry|
|
38
|
+
release = entry.entity
|
39
|
+
puts "Title : #{release.title}"
|
40
|
+
puts "Tracks: #{release.tracks.to_a.join("\r\n ")}"
|
41
|
+
end
|
data/examples/searchlabels.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which searches the database for
|
4
5
|
# labels and displays the label's data.
|
5
6
|
#
|
6
|
-
# $Id: searchlabels.rb
|
7
|
+
# $Id: searchlabels.rb 254 2009-05-13 20:04:36Z phw $
|
7
8
|
|
8
9
|
# Just make sure we can run this example from the command
|
9
10
|
# line even if RBrainz is not yet installed properly.
|
@@ -32,4 +33,4 @@ labels = query.get_labels(label_filter)
|
|
32
33
|
# indicates how good the label matches the search parameters.
|
33
34
|
labels.each do |entry|
|
34
35
|
print "%s (%i%%)\r\n" % [entry.entity.unique_name, entry.score]
|
35
|
-
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# Example script which searches the database for
|
5
|
+
# release groups and displays the release group data.
|
6
|
+
#
|
7
|
+
# $Id: searchreleasegroups.rb 273 2009-05-24 22:29:04Z phw $
|
8
|
+
|
9
|
+
# Just make sure we can run this example from the command
|
10
|
+
# line even if RBrainz is not yet installed properly.
|
11
|
+
$: << 'lib/' << '../lib/'
|
12
|
+
|
13
|
+
# Load RBrainz and include the MusicBrainz namespace.
|
14
|
+
require 'rbrainz'
|
15
|
+
include MusicBrainz
|
16
|
+
|
17
|
+
# Define the search parameters: Search for release groups from the
|
18
|
+
# band "Paradise Lost" and return a maximum of 10 release groups.
|
19
|
+
release_group_filter = Webservice::ReleaseGroupFilter.new(
|
20
|
+
:artist => 'Paradise Lost',
|
21
|
+
:limit => 10
|
22
|
+
)
|
23
|
+
|
24
|
+
# Create a new Query object which will provide
|
25
|
+
# us an interface to the MusicBrainz web service.
|
26
|
+
query = Webservice::Query.new
|
27
|
+
|
28
|
+
# Now query the MusicBrainz database for release groups
|
29
|
+
# with the search parameters defined above.
|
30
|
+
release_groups = query.get_release_groups(release_group_filter)
|
31
|
+
|
32
|
+
# Display the fetched release group titles and the score, which
|
33
|
+
# indicates how good the release matches the search parameters.
|
34
|
+
release_groups.each do |entry|
|
35
|
+
print "%s (%i%%)\r\n" % [entry.entity.title, entry.score]
|
36
|
+
end
|
data/examples/searchreleases.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
2
3
|
#
|
3
4
|
# Example script which searches the database for
|
4
5
|
# releases and displays the release data.
|
5
6
|
#
|
6
|
-
# $Id: searchreleases.rb
|
7
|
+
# $Id: searchreleases.rb 260 2009-05-17 19:00:53Z phw $
|
7
8
|
|
8
9
|
# Just make sure we can run this example from the command
|
9
10
|
# line even if RBrainz is not yet installed properly.
|
@@ -13,8 +14,9 @@ $: << 'lib/' << '../lib/'
|
|
13
14
|
require 'rbrainz'
|
14
15
|
include MusicBrainz
|
15
16
|
|
16
|
-
# Define the search parameters: Search for releases
|
17
|
-
#
|
17
|
+
# Define the search parameters: Search for releases for the band
|
18
|
+
# "Paradise Lost" (which has the MusicBrainz ID 10bf95b6-30e3-44f1-817f-45762cdc0de0)
|
19
|
+
# and return a maximum of 10 releases.
|
18
20
|
release_filter = Webservice::ReleaseFilter.new(
|
19
21
|
:artistid => '10bf95b6-30e3-44f1-817f-45762cdc0de0',
|
20
22
|
:limit => 10
|
@@ -33,4 +35,4 @@ releases = query.get_releases(release_filter)
|
|
33
35
|
releases.each do |entry|
|
34
36
|
print "%s: %s (%i%%)\r\n" % [entry.entity.earliest_release_date,
|
35
37
|
entry.entity.title, entry.score]
|
36
|
-
end
|
38
|
+
end
|