Module: MusicBrainz::Bindings::Recording

Extended by:
Recording
Included in:
Recording
Defined in:
lib/musicbrainz/bindings/recording.rb

Instance Method Summary collapse

Instance Method Details

#parse(xml) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/musicbrainz/bindings/recording.rb', line 4

def parse(xml)
  xml = xml.xpath('./recording') unless xml.xpath('./recording').empty?
  {
    id: (xml.attribute('id').value rescue nil),
    mbid: (xml.attribute('id').value rescue nil), # Old shit
    title: (xml.xpath('./title').text.gsub(/[`’]/, "'") rescue nil),
    artist: (xml.xpath('./artist-credit/name-credit/artist/name').text rescue nil),
    releases: (xml.xpath('./release-list/release/title').map{ |xml| xml.text } rescue []),
    score: (xml.attribute('score').value.to_i rescue nil)
  }
end