Class: SunDawg::YahooMusicClient
- Inherits:
-
Object
- Object
- SunDawg::YahooMusicClient
- Defined in:
- lib/yahoo_music_client.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#service_host ⇒ Object
Returns the value of attribute service_host.
Instance Method Summary collapse
- #get_artists(name) ⇒ Object
- #get_similar_artists(name) ⇒ Object
- #get_similar_artists_by_id(yahoo_id, options = {}) ⇒ Object
-
#initialize ⇒ YahooMusicClient
constructor
A new instance of YahooMusicClient.
Constructor Details
#initialize ⇒ YahooMusicClient
Returns a new instance of YahooMusicClient.
9 10 11 |
# File 'lib/yahoo_music_client.rb', line 9 def initialize @service_host = "http://us.music.yahooapis.com" end |
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
7 8 9 |
# File 'lib/yahoo_music_client.rb', line 7 def app_id @app_id end |
#service_host ⇒ Object
Returns the value of attribute service_host.
7 8 9 |
# File 'lib/yahoo_music_client.rb', line 7 def service_host @service_host end |
Instance Method Details
#get_artists(name) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/yahoo_music_client.rb', line 13 def get_artists(name) endpoint = "/artist/v1/list/search/artist/#{CGI.escape(name)}" endpoint += SunDawg::Util.build_query_string("appid" => app_id) xml = SunDawg::Util.do_http_get(service_host, endpoint) doc = REXML::Document.new(xml) parse_artists(doc) end |
#get_similar_artists(name) ⇒ Object
21 22 23 24 |
# File 'lib/yahoo_music_client.rb', line 21 def get_similar_artists(name) artists = get_artists(name) get_similar_artists_by_id(artists.first.yahoo_id) end |
#get_similar_artists_by_id(yahoo_id, options = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/yahoo_music_client.rb', line 26 def get_similar_artists_by_id(yahoo_id, = {}) endpoint = "/artist/v1/list/similar/#{yahoo_id}" endpoint += SunDawg::Util.build_query_string(.merge("appid" => app_id)) xml = SunDawg::Util.do_http_get(service_host, endpoint) doc = REXML::Document.new(xml) parse_artists(doc) end |