Sha256: a7c8719a88d0d94856daf11bfbd8911304a15858dec4c50c8f8dd754d527fdbb
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
module MusicBrainz class Artist < BaseModel field :id, String field :type, String field :name, String field :country, String field :date_begin, Date field :date_end, Date field :urls, Hash def release_groups @release_groups ||= client.load(:release_group, { artist: id }, { binding: :artist_release_groups, create_models: :release_group, sort: :first_release_date }) unless @id.nil? end class << self def find(id) client.load(:artist, { id: id, inc: [:url_rels] }, { binding: :artist, create_model: :artist }) end def search(name) name = CGI.escape(name).gsub(/\!/, '\!') client.load(:artist, { query: "artist:#{name}", limit: 10 }, { binding: :artist_search }) end def discography(mbid) artist = find(mbid) artist.release_groups.each { |rg| rg.releases.each { |r| r.tracks } } artist end def find_by_name(name) matches = search(name) matches.empty? ? nil : find(matches.first[:id]) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
musicbrainz-0.7.4 | lib/musicbrainz/models/artist.rb |
musicbrainz-0.7.3 | lib/musicbrainz/models/artist.rb |
musicbrainz-0.7.2 | lib/musicbrainz/models/artist.rb |