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

24 lines
854 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 ArtistSearch
def parse(xml)
xml.xpath('./artist-list/artist').map do |xml|
{
id: (xml.attribute('id').value rescue nil),
mbid: (xml.attribute('id').value rescue nil), # Old shit
name: (xml.xpath('./name').text.gsub(/[`]/, "'") rescue nil),
sort_name: (xml.xpath('./sort-name').gsub(/[`]/, "'") rescue nil),
type: (xml.attribute('type').value rescue nil),
score: (xml.attribute('score').value.to_i rescue nil),
desc: (xml.xpath('./disambiguation').value rescue nil),
aliases: (xml.xpath('./alias-list/alias').map{ |xml| xml.text } rescue [])
} rescue nil
end.delete_if{ |item| item.nil? }
end
extend self
end
end
end