From 673db862ea3873d8b4131c2ba194e58233aeb2b1 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Tue, 20 Sep 2011 20:23:36 +0400 Subject: [PATCH] Release format --- VERSION | 2 +- lib/models/music_brainz/release.rb | 7 ++++--- lib/models/music_brainz/release_group.rb | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 5cd6428..a2094f3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.9 \ No newline at end of file +0.4.10 \ No newline at end of file diff --git a/lib/models/music_brainz/release.rb b/lib/models/music_brainz/release.rb index 6b6a500..20257d8 100644 --- a/lib/models/music_brainz/release.rb +++ b/lib/models/music_brainz/release.rb @@ -1,12 +1,12 @@ module MusicBrainz class Release - attr_accessor :id, :title, :status, :date, :country + attr_accessor :id, :title, :status, :format, :date, :country @tracks def tracks if @tracks.nil? and not self.id.nil? @tracks = [] - Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/' + self.id + '?inc=recordings&limit=100')).css('medium-list > medium > track-list > track').each do |r| + Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/' + self.id + '?inc=recordings+media&limit=100')).css('medium-list > medium > track-list > track').each do |r| @tracks << MusicBrainz::Track.parse_xml(r) end end @@ -14,7 +14,7 @@ module MusicBrainz end def self.find mbid - xml = Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/' + mbid)).css('release').first + xml = Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/' + mbid + '?inc=media')).css('release').first self.parse_xml(xml) unless xml.nil? end @@ -23,6 +23,7 @@ module MusicBrainz @release.id = xml.attr('id') @release.title = xml.css('title').text unless xml.css('title').empty? @release.status = xml.css('status').text unless xml.css('status').empty? + @release.format = xml.css('medium-list > medium > format').first.text unless xml.css('medium-list > medium > format').empty? date = xml.css('date').empty? ? '2030-12-31' : xml.css('date').text if date.length == 0 date = '2030-12-31' diff --git a/lib/models/music_brainz/release_group.rb b/lib/models/music_brainz/release_group.rb index 167d237..45e4ad6 100644 --- a/lib/models/music_brainz/release_group.rb +++ b/lib/models/music_brainz/release_group.rb @@ -6,7 +6,7 @@ module MusicBrainz def releases if @releases.nil? and not self.id.nil? @releases = [] - Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/?release-group=' + self.id + '&limit=100')).css('release').each do |r| + Nokogiri::XML(MusicBrainz.load('http://musicbrainz.org/ws/2/release/?release-group=' + self.id + '&inc=media&limit=100')).css('release').each do |r| @releases << MusicBrainz::Release.parse_xml(r) end end