class Echonest::Artist
Attributes
foreign_ids[RW]
id[RW]
name[RW]
Public Class Methods
new(api_key, name = nil, foreign_ids = nil, id = nil)
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 15 def initialize(api_key, name = nil, foreign_ids = nil, id = nil) @id = id @name = name @api_key = api_key @foreign_ids = ForeignId.parse_array(foreign_ids) if foreign_ids end
Public Instance Methods
biographies(options = { results: 1 })
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 22 def biographies(options = { results: 1 }) response = get_response(results: options[:results], name: @name) response[:biographies].collect do |b| Biography.new(text: b[:text], site: b[:site], url: b[:url]) end end
blogs(options = { results: 1 })
click to toggle source
Stuff from blogspot, etc
# File lib/echonest-ruby-api/artist.rb, line 31 def blogs(options = { results: 1 }) response = get_response(results: options[:results], name: @name) response[:blogs].collect do |b| Blog.new(name: b[:name], site: b[:site], url: b[:url]) end end
familiarity()
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 60 def familiarity response = get_response(name: @name) response[entity_name.to_sym][__method__.to_sym] end
genres()
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 65 def genres genres = [] response = get('artist/profile', {name: @name, bucket: 'genre'}) return response[:artist][:genres].collect {|g| g[:name]} end
hotttnesss(options = {})
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 71 def hotttnesss(options = {}) response = get_response(name: @name, type: options.fetch(:type, 'overall')) response[entity_name.to_sym][__method__.to_sym] end
images(options = { results: 15 })
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 76 def images(options = { results: 15 }) response = get_response(results: options[:results], name: @name) images = [] response[:images].each do |i| images << i[:url] end images end
list_genres()
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 85 def list_genres get_response[:genres] end
news(options = { results: 1 })
click to toggle source
This appears to be from more “reputable” sources?
# File lib/echonest-ruby-api/artist.rb, line 40 def news(options = { results: 1 }) response = get_response(results: options[:results], name: @name) response[:news].collect do |b| Blog.new(name: b[:name], site: b[:site], url: b[:url]) end end
profile(options = {})
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 132 def profile(options = {}) options = (@id ? {id: @id} : {name: @name}).merge(options) artist_data = get_response(options)[:artist] Artist.new(@api_key, artist_data[:name], artist_data[:foreign_ids], artist_data[:id]) end
search(options = {})
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 89 def search(options = {}) options = {name: @name}.merge(options) artists = [] get_response(options)[:artists].each do |a| artists << Artist.new(@api_key, a[:name], a[:foreign_ids], a[:id]) end artists end
similar(options = { results: 20 })
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 98 def similar(options = { results: 20 }) artists = [] response = get('artist/similar', {name: @name, results: options[:results]}) response[:artists].each do |a| artists << a end return artists end
songs(options = { results: 15 })
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 124 def songs(options = { results: 15 }) songs = [] get_response(results: options[:results], name: @name)[:songs].each do |s| songs << { s[:id] => s[:title] } end songs end
suggest(options = {})
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 107 def suggest(options = {}) options = {name: @name}.merge(options) artists = [] get_response(options)[:artists].each do |a| artists << Artist.new(@api_key, a[:name], a[:foreign_ids], a[:id]) end artists end
terms(options = {})
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 138 def terms(options = {}) options = (@id ? { id: @id } : { name: @name }).merge(options) get_response(options)[:terms] end
top_hottt(options = {})
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 116 def top_hottt(options = {}) artists = [] get_response(options)[:artists].each do |a| artists << Artist.new(@api_key, a[:name], a[:foreign_ids], a[:id]) end artists end
urls()
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 56 def urls get_response(name: @name)[:urls] end
video(options = { results: 1 })
click to toggle source
# File lib/echonest-ruby-api/artist.rb, line 48 def video(options = { results: 1 }) response = get_response(results: options[:results], name: @name) response[:video].collect do |v| Video.new(title: v[:title], site: v[:site], url: v[:url], date_found: v[:date_found], image_url: v[:image_url]) end end