1
0
Fork 0

Release format

This commit is contained in:
magnolia-fan 2011-09-20 20:23:36 +04:00
parent 93f89e1999
commit 673db862ea
3 changed files with 6 additions and 5 deletions

View File

@ -1 +1 @@
0.4.9
0.4.10

View File

@ -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'

View File

@ -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