rbrainz 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/CHANGES +13 -1
  2. data/LICENSE +1 -1
  3. data/README +2 -2
  4. data/Rakefile +2 -2
  5. data/TODO +9 -2
  6. data/doc/README.rdoc +5 -5
  7. data/examples/getartist.rb +3 -2
  8. data/examples/getlabel.rb +3 -2
  9. data/examples/getrelease.rb +5 -2
  10. data/examples/getreleasegroup.rb +53 -0
  11. data/examples/gettrack.rb +3 -2
  12. data/examples/getuser.rb +2 -1
  13. data/examples/rate.rb +44 -0
  14. data/examples/searchartists.rb +3 -2
  15. data/examples/searchcdstubs.rb +41 -0
  16. data/examples/searchlabels.rb +3 -2
  17. data/examples/searchreleasegroups.rb +36 -0
  18. data/examples/searchreleases.rb +6 -4
  19. data/examples/searchtracks.rb +3 -2
  20. data/examples/submit_isrcs.rb +52 -0
  21. data/examples/tag.rb +3 -2
  22. data/lib/rbrainz.rb +2 -1
  23. data/lib/rbrainz/core_ext.rb +2 -1
  24. data/lib/rbrainz/core_ext/mbid.rb +2 -1
  25. data/lib/rbrainz/core_ext/net_http_digest.rb +3 -2
  26. data/lib/rbrainz/core_ext/range.rb +3 -2
  27. data/lib/rbrainz/core_ext/range/equality.rb +2 -1
  28. data/lib/rbrainz/data/countrynames.rb +6 -3
  29. data/lib/rbrainz/data/languagenames.rb +3 -2
  30. data/lib/rbrainz/data/releasetypenames.rb +3 -2
  31. data/lib/rbrainz/data/scriptnames.rb +3 -2
  32. data/lib/rbrainz/model.rb +3 -2
  33. data/lib/rbrainz/model/alias.rb +3 -2
  34. data/lib/rbrainz/model/artist.rb +11 -3
  35. data/lib/rbrainz/model/collection.rb +3 -2
  36. data/lib/rbrainz/model/default_factory.rb +18 -6
  37. data/lib/rbrainz/model/disc.rb +3 -2
  38. data/lib/rbrainz/model/entity.rb +2 -102
  39. data/lib/rbrainz/model/incomplete_date.rb +3 -2
  40. data/lib/rbrainz/model/individual.rb +11 -2
  41. data/lib/rbrainz/model/isrc.rb +100 -0
  42. data/lib/rbrainz/model/label.rb +5 -2
  43. data/lib/rbrainz/model/mbid.rb +28 -9
  44. data/lib/rbrainz/model/rateable.rb +34 -0
  45. data/lib/rbrainz/model/rating.rb +56 -0
  46. data/lib/rbrainz/model/relateable.rb +118 -0
  47. data/lib/rbrainz/model/relation.rb +2 -1
  48. data/lib/rbrainz/model/release.rb +17 -3
  49. data/lib/rbrainz/model/release_event.rb +3 -2
  50. data/lib/rbrainz/model/release_group.rb +97 -0
  51. data/lib/rbrainz/model/scored_collection.rb +3 -2
  52. data/lib/rbrainz/model/tag.rb +5 -4
  53. data/lib/rbrainz/model/taggable.rb +27 -0
  54. data/lib/rbrainz/model/track.rb +15 -2
  55. data/lib/rbrainz/model/user.rb +3 -2
  56. data/lib/rbrainz/utils.rb +2 -1
  57. data/lib/rbrainz/utils/data.rb +3 -2
  58. data/lib/rbrainz/utils/helper.rb +8 -2
  59. data/lib/rbrainz/version.rb +3 -2
  60. data/lib/rbrainz/webservice.rb +12 -7
  61. data/lib/rbrainz/webservice/filter.rb +53 -4
  62. data/lib/rbrainz/webservice/includes.rb +72 -11
  63. data/lib/rbrainz/webservice/mbxml.rb +129 -67
  64. data/lib/rbrainz/webservice/query.rb +156 -16
  65. data/lib/rbrainz/webservice/webservice.rb +104 -116
  66. data/test/lib/mock_webservice.rb +9 -2
  67. data/test/lib/test_entity.rb +2 -97
  68. data/test/lib/test_factory.rb +9 -1
  69. data/test/lib/test_rateable.rb +31 -0
  70. data/test/lib/test_relateable.rb +103 -0
  71. data/test/lib/test_taggable.rb +36 -0
  72. data/test/lib/testing_helper.rb +17 -2
  73. data/test/test-data/invalid/artist/ratings_1.xml +6 -0
  74. data/test/test-data/invalid/artist/ratings_2.xml +6 -0
  75. data/test/test-data/valid/artist/Tchaikovsky-2.xml +6 -0
  76. data/test/test-data/valid/label/Atlantic_Records_3.xml +6 -0
  77. data/test/test-data/valid/release-group/The_Cure_1.xml +36 -0
  78. data/test/test-data/valid/release/Highway_61_Revisited_2.xml +6 -0
  79. data/test/test-data/valid/track/Silent_All_These_Years_4.xml +3 -0
  80. data/test/test-data/valid/track/Silent_All_These_Years_6.xml +8 -0
  81. data/test/test_alias.rb +2 -1
  82. data/test/test_artist.rb +24 -2
  83. data/test/test_artist_filter.rb +2 -1
  84. data/test/test_artist_includes.rb +13 -3
  85. data/test/test_collection.rb +3 -2
  86. data/test/test_default_factory.rb +8 -1
  87. data/test/test_disc.rb +2 -1
  88. data/test/test_incomplete_date.rb +2 -1
  89. data/test/test_isrc.rb +87 -0
  90. data/test/test_label.rb +8 -1
  91. data/test/test_label_filter.rb +2 -1
  92. data/test/test_label_includes.rb +10 -3
  93. data/test/test_mbid.rb +2 -1
  94. data/test/test_mbxml.rb +93 -2
  95. data/test/test_query.rb +68 -5
  96. data/test/test_range_equality.rb +2 -1
  97. data/test/test_rating.rb +46 -0
  98. data/test/test_relation.rb +2 -1
  99. data/test/test_release.rb +37 -2
  100. data/test/test_release_event.rb +2 -1
  101. data/test/test_release_filter.rb +15 -2
  102. data/test/test_release_group.rb +104 -0
  103. data/test/test_release_group_filter.rb +61 -0
  104. data/test/test_release_group_includes.rb +46 -0
  105. data/test/test_release_includes.rb +16 -3
  106. data/test/test_scored_collection.rb +3 -2
  107. data/test/test_tag.rb +2 -1
  108. data/test/test_track.rb +28 -1
  109. data/test/test_track_filter.rb +2 -1
  110. data/test/test_track_includes.rb +13 -3
  111. data/test/test_utils.rb +2 -1
  112. data/test/test_webservice.rb +11 -1
  113. metadata +38 -20
  114. data/debian/changelog +0 -11
  115. data/debian/compat +0 -1
  116. data/debian/control +0 -13
  117. data/debian/copyright +0 -25
  118. 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 219 2008-09-04 18:14:48Z phw $
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
- # $Id: Rakefile 226 2008-09-04 19:51:48Z phw $
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 usefull example for RBrainz.
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 129 2007-07-12 17:52:17Z phw $
19
+ $Id: TODO 277 2009-05-25 19:33:26Z phw $
@@ -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.2, including support
13
- for labels and extended release events.
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 191 2007-12-04 13:30:26Z phw $
103
+ $Id: README.rdoc 252 2009-05-13 19:21:28Z phw $
@@ -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 162 2007-07-29 17:44:11Z phw $
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
@@ -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 160 2007-07-27 13:18:04Z phw $
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
@@ -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 190 2007-12-04 12:51:17Z phw $
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
+
@@ -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 160 2007-07-27 13:18:04Z phw $
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
@@ -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 183 2007-10-16 22:13:33Z phw $
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.
@@ -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)
@@ -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 145 2007-07-19 13:11:44Z phw $
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
@@ -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 160 2007-07-27 13:18:04Z phw $
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
@@ -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 183 2007-10-16 22:13:33Z phw $
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 with the
17
- # title "Paradise Lost" and return a maximum of 10 releases.
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