Sha256: 4a729a3f5e04a82fe852483f1671ac42770bf5b1f959e61b82ead254824f96f2

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

# 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
musicbrainz-0.7.7 lib/musicbrainz/bindings/track_search.rb
musicbrainz-0.7.6 lib/musicbrainz/bindings/track_search.rb
musicbrainz-0.7.5 lib/musicbrainz/bindings/track_search.rb