1
0
Fork 0
musicbrainz/lib/musicbrainz/bindings/track_search.rb

22 lines
733 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# encoding: UTF-8
module MusicBrainz
module Bindings
module TrackSearch
def parse(xml)
xml.xpath('./recording-list/recording').map do |xml|
{
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)
} rescue nil
end.delete_if{ |item| item.nil? }
end
extend self
end
end
end