| Class | Scrobbler::Track |
| In: |
lib/scrobbler/track.rb
|
| Parent: | Base |
| album | [RW] | |
| album_mbid | [RW] | |
| artist | [RW] | |
| artist_mbid | [RW] | |
| chartposition | [RW] | for weekly top tracks |
| count | [RW] | only seems to be used on top tracks for tag |
| date | [RW] | |
| date_uts | [RW] | |
| image | [RW] | only seems to be used on top tracks for tag |
| mbid | [RW] | |
| name | [RW] | |
| playcount | [RW] | |
| rank | [RW] | |
| reach | [RW] | |
| streamable | [RW] | |
| thumbnail | [RW] | only seems to be used on top tracks for tag |
| url | [RW] |
# File lib/scrobbler/track.rb, line 77
77: def initialize(artist, name)
78: raise ArgumentError, "Artist is required" if artist.blank?
79: raise ArgumentError, "Name is required" if name.blank?
80: @artist = artist
81: @name = name
82: end
# File lib/scrobbler/track.rb, line 48
48: def new_from_xml(xml, doc=nil)
49: artist = (xml).at(:artist)['name'] if (xml).at(:artist) && (xml).at(:artist)['name']
50: artist = (xml).at(:artist).inner_html if artist.nil? && (xml).at(:artist)
51: artist = doc.root['artist'] if artist.nil? && doc.root['artist']
52: name = (xml).at(:name).inner_html if (xml).at(:name)
53: name = xml['name'] if name.nil? && xml['name']
54: t = Track.new(artist, name)
55: t.artist_mbid = (xml).at(:artist)['mbid'] if (xml).at(:artist) && (xml).at(:artist)['mbid']
56: t.artist_mbid = (xml).at(:artist).at(:mbid).inner_html if t.artist_mbid.nil? && (xml).at(:artist) && (xml).at(:artist).at(:mbid)
57: t.mbid = (xml).at(:mbid).inner_html if (xml).at(:mbid)
58: t.playcount = (xml).at(:playcount).inner_html if (xml).at(:playcount)
59: t.chartposition = (xml).at(:chartposition).inner_html if (xml).at(:chartposition)
60: t.rank = (xml).at(:rank).inner_html if (xml).at(:rank)
61: t.url = (xml/:url).last.inner_html if (xml/:url).size > 1
62: t.url = (xml).at(:url).inner_html if t.url.nil? && (xml).at(:url)
63: t.streamable = (xml).at(:track)['streamable'] if (xml).at(:track) && (xml).at(:track)['streamable']
64: t.streamable = xml['streamable'] if t.streamable.nil? && xml['streamable']
65: t.count = xml['count'] if xml['count']
66: t.album = (xml).at(:album).inner_html if (xml).at(:album)
67: t.album_mbid = (xml).at(:album)['mbid'] if (xml).at(:album) && (xml).at(:album)['mbid']
68: t.date = Time.parse((xml).at(:date).inner_html) if (xml).at(:date)
69: t.date_uts = (xml).at(:date)['uts'] if (xml).at(:date) && (xml).at(:date)['uts']
70: t.thumbnail = (xml).at(:thumbnail).inner_html if (xml).at(:thumbnail)
71: t.image = (xml).at(:image).inner_html if (xml).at(:image)
72: t.reach = (xml).at(:reach).inner_html if (xml).at(:reach)
73: t
74: end
# File lib/scrobbler/track.rb, line 84
84: def api_path
85: "/#{API_VERSION}/track/#{CGI::escape(artist)}/#{CGI::escape(name)}"
86: end
# File lib/scrobbler/track.rb, line 88
88: def fans(force=false)
89: get_instance(:fans, :fans, :user, force)
90: end