| Class | Scrobbler::Artist |
| In: |
lib/scrobbler/artist.rb
|
| Parent: | Base |
| chartposition | [RW] | |
| count | [RW] | |
| image | [RW] | |
| match | [RW] | used for similar artists |
| mbid | [RW] | |
| name | [RW] | |
| playcount | [RW] | |
| rank | [RW] | |
| reach | [RW] | |
| streamable | [RW] | |
| thumbnail | [RW] | |
| url | [RW] |
# File lib/scrobbler/artist.rb, line 92
92: def initialize(name)
93: raise ArgumentError, "Name is required" if name.blank?
94: @name = name
95: end
# File lib/scrobbler/artist.rb, line 68
68: def new_from_xml(xml, doc=nil)
69: name = (xml).at(:name).inner_html if (xml).at(:name)
70: # occasionally name can be found in root of artist element (<artist name="">) rather than as an element (<name>)
71: name = xml['name'] if name.nil? && xml['name']
72: a = Artist.new(name)
73: a.mbid = (xml).at(:mbid).inner_html if (xml).at(:mbid)
74: a.playcount = (xml).at(:playcount).inner_html if (xml).at(:playcount)
75: a.rank = (xml).at(:rank).inner_html if (xml).at(:rank)
76: a.url = (xml).at(:url).inner_html if (xml).at(:url)
77: a.thumbnail = (xml).at(:thumbnail).inner_html if (xml).at(:thumbnail)
78: a.thumbnail = (xml).at(:image_small).inner_html if a.thumbnail.nil? && (xml).at(:image_small)
79: a.image = (xml).at(:image).inner_html if (xml).at(:image)
80: a.reach = (xml).at(:reach).inner_html if (xml).at(:reach)
81: a.match = (xml).at(:match).inner_html if (xml).at(:match)
82: a.chartposition = (xml).at(:chartposition).inner_html if (xml).at(:chartposition)
83:
84: # in top artists for tag
85: a.count = xml['count'] if xml['count']
86: a.streamable = xml['streamable'] if xml['streamable']
87: a.streamable = (xml).at(:streamable).inner_html == '1' ? 'yes' : 'no' if a.streamable.nil? && (xml).at(:streamable)
88: a
89: end
# File lib/scrobbler/artist.rb, line 97
97: def api_path
98: "/#{API_VERSION}/artist/#{CGI::escape(name)}"
99: end
# File lib/scrobbler/artist.rb, line 101
101: def current_events(format=:ics)
102: format = :ics if format.to_s == 'ical'
103: raise ArgumentError unless ['ics', 'rss'].include?(format.to_s)
104: "#{API_URL.chop}#{api_path}/events.#{format}"
105: end
# File lib/scrobbler/artist.rb, line 107
107: def similar(force=false)
108: get_instance(:similar, :similar, :artist, force)
109: end
# File lib/scrobbler/artist.rb, line 119
119: def top_albums(force=false)
120: get_instance(:topalbums, :top_albums, :album, force)
121: end
# File lib/scrobbler/artist.rb, line 111
111: def top_fans(force=false)
112: get_instance(:fans, :top_fans, :user, force)
113: end
# File lib/scrobbler/artist.rb, line 123
123: def top_tags(force=false)
124: get_instance(:toptags, :top_tags, :tag, force)
125: end