rscrobbler 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lastfm/album.rb +50 -112
- data/lib/lastfm/api/album.rb +140 -0
- data/lib/lastfm/api/artist.rb +243 -0
- data/lib/lastfm/api/auth.rb +35 -0
- data/lib/lastfm/api/chart.rb +63 -0
- data/lib/lastfm/api/event.rb +71 -0
- data/lib/lastfm/api/geo.rb +125 -0
- data/lib/lastfm/api/group.rb +69 -0
- data/lib/lastfm/api/library.rb +117 -0
- data/lib/lastfm/api/playlist.rb +40 -0
- data/lib/lastfm/api/radio.rb +41 -0
- data/lib/lastfm/api/tag.rb +120 -0
- data/lib/lastfm/api/tasteometer.rb +37 -0
- data/lib/lastfm/api/track.rb +272 -0
- data/lib/lastfm/api/user.rb +266 -0
- data/lib/lastfm/api/venue.rb +40 -0
- data/lib/lastfm/artist.rb +42 -204
- data/lib/lastfm/buylink.rb +34 -0
- data/lib/lastfm/event.rb +57 -66
- data/lib/lastfm/shout.rb +20 -0
- data/lib/lastfm/struct.rb +34 -0
- data/lib/lastfm/tag.rb +24 -89
- data/lib/lastfm/track.rb +51 -242
- data/lib/lastfm/venue.rb +21 -36
- data/lib/lastfm/wiki.rb +20 -0
- data/lib/rscrobbler.rb +24 -11
- data/test/test_album.rb +36 -0
- metadata +25 -45
- data/lib/lastfm/auth.rb +0 -35
- data/lib/lastfm/chart.rb +0 -63
- data/lib/lastfm/geo.rb +0 -125
- data/lib/lastfm/group.rb +0 -69
- data/lib/lastfm/library.rb +0 -117
- data/lib/lastfm/playlist.rb +0 -40
- data/lib/lastfm/radio.rb +0 -41
- data/lib/lastfm/tasteometer.rb +0 -37
- data/lib/lastfm/user.rb +0 -266
- data/test/unit/lib/lastfm/album_test.rb +0 -0
- data/test/unit/lib/lastfm/artist_test.rb +0 -0
- data/test/unit/lib/lastfm/auth_test.rb +0 -0
- data/test/unit/lib/lastfm/chart_test.rb +0 -0
- data/test/unit/lib/lastfm/event_test.rb +0 -0
- data/test/unit/lib/lastfm/geo_test.rb +0 -0
- data/test/unit/lib/lastfm/group_test.rb +0 -0
- data/test/unit/lib/lastfm/library_test.rb +0 -0
- data/test/unit/lib/lastfm/playlist_test.rb +0 -0
- data/test/unit/lib/lastfm/radio_test.rb +0 -0
- data/test/unit/lib/lastfm/tag_test.rb +0 -0
- data/test/unit/lib/lastfm/tasteometer_test.rb +0 -0
- data/test/unit/lib/lastfm/track_test.rb +0 -0
- data/test/unit/lib/lastfm/user_test.rb +0 -0
- data/test/unit/lib/lastfm/venue_test.rb +0 -0
- data/test/unit/lib/rscrobbler_test.rb +0 -0
data/lib/lastfm/track.rb
CHANGED
@@ -1,248 +1,57 @@
|
|
1
1
|
module LastFM
|
2
|
-
class Track
|
3
|
-
class << self
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
#
|
53
|
-
# @option params [String, required] :fingerprint_id the fingerprint id to look up
|
54
|
-
# @see http://www.last.fm/api/show?service=441
|
55
|
-
# @see https://github.com/lastfm/Fingerprinter
|
56
|
-
# @see http://blog.last.fm/2010/07/09/fingerprint-api-and-app-updated
|
57
|
-
def get_fingerprint_metadata( params )
|
58
|
-
LastFM.get( "#{TYPE}.getFingerPrintMetadata", params )
|
59
|
-
end
|
60
|
-
|
61
|
-
# Get the metadata for a track.
|
62
|
-
#
|
63
|
-
# @option params [String, required unless :mbid] :artist the artist name
|
64
|
-
# @option params [String, required unless :mbid] :track the track name
|
65
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
66
|
-
# @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
|
67
|
-
# @option params [String, optional] :username username whose playcount for, and whether they've loved, this track is to be returned in the reponse
|
68
|
-
# @see http://www.last.fm/api/show?service=356
|
69
|
-
def get_info( params )
|
70
|
-
LastFM.get( "#{TYPE}.getInfo", params )
|
71
|
-
end
|
72
|
-
|
73
|
-
# Get shouts for a track.
|
74
|
-
#
|
75
|
-
# @option params [String, required unless :mbid] :artist the artist name
|
76
|
-
# @option params [String, required unless :mbid] :track the track name
|
77
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
78
|
-
# @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
|
79
|
-
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
80
|
-
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
81
|
-
# @see http://www.last.fm/api/show?service=453
|
82
|
-
def get_shouts( params )
|
83
|
-
LastFM.get( "#{TYPE}.getShouts", params )
|
84
|
-
end
|
85
|
-
|
86
|
-
# Get similar tracks for a track on Last.fm, based on listening data.
|
87
|
-
#
|
88
|
-
# @option params [String, required unless :mbid] :artist the artist name
|
89
|
-
# @option params [String, required unless :mbid] :track the track name
|
90
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
91
|
-
# @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
|
92
|
-
# @option params [Fixnum, optional] :limit the number of results to fetch. defaults to 50
|
93
|
-
# @see http://www.last.fm/api/show?service=319
|
94
|
-
def get_similar( params )
|
95
|
-
LastFM.get( "#{TYPE}.getSimilar", params )
|
96
|
-
end
|
97
|
-
|
98
|
-
# Get the tags on a track.
|
99
|
-
#
|
100
|
-
# @option params [String, required unless :mbid] :artist the artist name
|
101
|
-
# @option params [String, required unless :mbid] :track the track name
|
102
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
103
|
-
# @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
|
104
|
-
# @option params [String, optional] :user if called in non-authenticated mode you must specify the user to look up
|
105
|
-
# @see http://www.last.fm/api/show?service=320
|
106
|
-
def get_tags( params )
|
107
|
-
secure = !params.include?(:user)
|
108
|
-
LastFM.requires_authentication if secure
|
109
|
-
LastFM.post( "#{TYPE}.getTags", params, secure )
|
110
|
-
end
|
111
|
-
|
112
|
-
# Get the top fans for a track, based on listening data.
|
113
|
-
#
|
114
|
-
# @option params [String, required unless :mbid] :artist the artist name
|
115
|
-
# @option params [String, required unless :mbid] :track the track name
|
116
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
117
|
-
# @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
|
118
|
-
# @see http://www.last.fm/api/show?service=312
|
119
|
-
def get_top_fans( params )
|
120
|
-
LastFM.get( "#{TYPE}.getTopFans", params )
|
121
|
-
end
|
122
|
-
|
123
|
-
# Get the top fans for a track, ordered by tag count.
|
124
|
-
#
|
125
|
-
# @option params [String, required unless :mbid] :artist the artist name
|
126
|
-
# @option params [String, required unless :mbid] :track the track name
|
127
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
128
|
-
# @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
|
129
|
-
# @see http://www.last.fm/api/show?service=289
|
130
|
-
def get_top_tags( params )
|
131
|
-
LastFM.get( "#{TYPE}.getTopTags", params )
|
132
|
-
end
|
133
|
-
|
134
|
-
# Love a track for the current user.
|
135
|
-
#
|
136
|
-
# @option params [String, required] :artist the artist name
|
137
|
-
# @option params [String, required] :track the track name
|
138
|
-
# @see http://www.last.fm/api/show?service=260
|
139
|
-
def love( params )
|
140
|
-
LastFM.requires_authentication
|
141
|
-
LastFM.post( "#{TYPE}.love", params )
|
142
|
-
end
|
143
|
-
|
144
|
-
# Remove a user's tag from a track.
|
145
|
-
#
|
146
|
-
# @option params [String, required] :artist the artist name
|
147
|
-
# @option params [String, required] :track the track name
|
148
|
-
# @option params [String, required] :tag a single user tag to remove from this track
|
149
|
-
# @see http://www.last.fm/api/show?service=316
|
150
|
-
def remove_tag( params )
|
151
|
-
LastFM.requires_authentication
|
152
|
-
LastFM.post( "#{TYPE}.removeTag", params )
|
153
|
-
end
|
154
|
-
|
155
|
-
# Used to add a track-play to a user's profile. Scrobble a track, or a batch of tracks.
|
156
|
-
# Single tracks may be passed using the Object types listed, batches of tracks must be
|
157
|
-
# passed in as Arrays of each Object type. Allows up to a maximum of 50 scrobbles per
|
158
|
-
# batch. For batch scrobbles, Array indices of optional parameters must line up with
|
159
|
-
# the indicies of their corresponding tracks.
|
160
|
-
#
|
161
|
-
# @option params [String, required unless :mbid] :artist artist name
|
162
|
-
# @option params [String, required unless :mbid] :track track name
|
163
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
164
|
-
# @option params [Time, optional] :timestamp time the track started playing
|
165
|
-
# @option params [String, optional] :album album name
|
166
|
-
# @option params [String, optional] :album_artist album artist, if this differend from the track artist
|
167
|
-
# @option params [Fixnum, optional] :track_number track number of the track on the album
|
168
|
-
# @option params [Fixnum, optional] :duration track length, in seconds
|
169
|
-
# @option params [String, optional] :stream_id track stream id, received from the radio.getPlaylist service
|
170
|
-
# @option params [Boolean, optional] :chosen_by_user whether or not the user chose the track
|
171
|
-
# @option params [String, optional] :context sub-client version (not public, only enabled for certain api keys)
|
172
|
-
# @see http://www.last.fm/api/show?service=443
|
173
|
-
def scrobble( params )
|
174
|
-
LastFM.requires_authentication
|
175
|
-
# Tracks are passed to the service using array notation for each of the above params
|
176
|
-
array_params = {}
|
177
|
-
params.each do |hkey, hval|
|
178
|
-
hval = hval.to_i if hval.is_a?(Time)
|
179
|
-
Array(hval).each_with_index do |aval, index|
|
180
|
-
array_params["#{hkey}[#{index}]"] = aval
|
3
|
+
# @attr [LastFM::Album] album
|
4
|
+
# @attr [LastFM::Artist, String] artist
|
5
|
+
# @attr [Fixnum] duration
|
6
|
+
# @attr [Fixnum] id
|
7
|
+
# @attr [Hash] images
|
8
|
+
# @attr [Fixnum] listeners
|
9
|
+
# @attr [String] mbid
|
10
|
+
# @attr [String] name
|
11
|
+
# @attr [Fixnum] playcount
|
12
|
+
# @attr [Fixnum] position
|
13
|
+
# @attr [Boolean] streamable
|
14
|
+
# @attr [Boolean] streamable_fulltrack
|
15
|
+
# @attr [Array] tags
|
16
|
+
# @attr [String] url
|
17
|
+
# @attr [LastFM::Wii] wiki
|
18
|
+
class Track < Struct.new(:album, :artist, :duration, :id, :images, :listeners, :mbid, :name, :playcount, :position, :streamable, :streamable_fulltrack, :tags, :url, :wiki)
|
19
|
+
|
20
|
+
def update_from_node(node)
|
21
|
+
case node.name.to_sym
|
22
|
+
when :name
|
23
|
+
self.name = node.content
|
24
|
+
when :id
|
25
|
+
self.id = node.content.to_i
|
26
|
+
when :duration
|
27
|
+
self.duration = node.content.to_i
|
28
|
+
when :mbid
|
29
|
+
self.mbid = node.content
|
30
|
+
when :url
|
31
|
+
self.url = node.content
|
32
|
+
when :listeners
|
33
|
+
self.listeners = node.content.to_i
|
34
|
+
when :playcount
|
35
|
+
self.playcount = node.content.to_i
|
36
|
+
when :streamable
|
37
|
+
self.streamable = (node.content == '1')
|
38
|
+
self.streamable_fulltrack = (node['fulltrack'] == '1')
|
39
|
+
when :image
|
40
|
+
self.images ||= {}
|
41
|
+
self.images.merge!({node['size'].to_sym => node.content})
|
42
|
+
when :artist
|
43
|
+
self.artist = (node.find('*').count == 0) ? node.content : LastFM::Artist.from_xml(node)
|
44
|
+
when :album
|
45
|
+
self.position = node['position'].to_i
|
46
|
+
self.album = LastFM::Album.from_xml(node)
|
47
|
+
when :toptags
|
48
|
+
self.tags = node.find('tag').map do |tag|
|
49
|
+
LastFM::Tag.from_xml(tag)
|
181
50
|
end
|
182
|
-
|
183
|
-
|
51
|
+
when :wiki
|
52
|
+
self.wiki = LastFM::Wiki.from_xml(node)
|
184
53
|
end
|
185
|
-
|
186
|
-
# Search for a track by track name. Returns track matches sorted by relevance.
|
187
|
-
#
|
188
|
-
# @option params [String, required] :track the track name
|
189
|
-
# @option params [String, optional] :artist narrow results based on an artist
|
190
|
-
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
191
|
-
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
192
|
-
# @see http://www.last.fm/api/show?service=286
|
193
|
-
def search( params )
|
194
|
-
LastFM.get( "#{TYPE}.search", params )
|
195
|
-
end
|
196
|
-
|
197
|
-
# Share a track twith one or more Last.fm users or other friends.
|
198
|
-
#
|
199
|
-
# @option params [String, required] :artist the artist name
|
200
|
-
# @option params [String, required] :track the track name
|
201
|
-
# @option params [Array, required] :recipient a list of email addresses or Last.fm usernames. maximum is 10
|
202
|
-
# @option params [String, optional] :message an optional message to send. if not supplied a default message will be used
|
203
|
-
# @option params [Boolean, optional] :public optionally show in the sharing users activity feed. defaults to false
|
204
|
-
# @see http://www.last.fm/api/show?service=305
|
205
|
-
def share( params )
|
206
|
-
LastFM.requires_authentication
|
207
|
-
LastFM.post( "#{TYPE}.share", params )
|
208
|
-
end
|
209
|
-
|
210
|
-
# Unban a track for the current user.
|
211
|
-
#
|
212
|
-
# @option params [String, required] :artist the artist name
|
213
|
-
# @option params [String, required] :track the track name
|
214
|
-
# @see http://www.last.fm/api/show?service=449
|
215
|
-
def unban( params )
|
216
|
-
LastFM.requires_authentication
|
217
|
-
LastFM.post( "#{TYPE}.unban", params )
|
218
|
-
end
|
219
|
-
|
220
|
-
# Unlove a track for the current user.
|
221
|
-
#
|
222
|
-
# @option params [String, required] :artist the artist name
|
223
|
-
# @option params [String, required] :track the track name
|
224
|
-
# @see http://www.last.fm/api/show?service=440
|
225
|
-
def unlove( params )
|
226
|
-
LastFM.requires_authentication
|
227
|
-
LastFM.post( "#{TYPE}.unlove", params )
|
228
|
-
end
|
229
|
-
|
230
|
-
# Used to notify Last.fm that a user has started listening to a track.
|
231
|
-
#
|
232
|
-
# @option params [String, required unless :mbid] :artist artist name
|
233
|
-
# @option params [String, required unless :mbid] :track track name
|
234
|
-
# @option params [String, optional] :mbid the musicbrainz id for the track
|
235
|
-
# @option params [String, optional] :album album name
|
236
|
-
# @option params [String, optional] :album_artist album artist, if this differend from the track artist
|
237
|
-
# @option params [Fixnum, optional] :track_number track number of the track on the album
|
238
|
-
# @option params [Fixnum, optional] :duration track length, in seconds
|
239
|
-
# @option params [String, optional] :context sub-client version (not public, only enabled for certain api keys)
|
240
|
-
# @see http://www.last.fm/api/show?service=454
|
241
|
-
def update_now_playing( params )
|
242
|
-
LastFM.requires_authentication
|
243
|
-
LastFM.post( "#{TYPE}.updateNowPlaying", params )
|
244
|
-
end
|
245
|
-
|
246
54
|
end
|
247
|
-
|
55
|
+
|
56
|
+
end
|
248
57
|
end
|
data/lib/lastfm/venue.rb
CHANGED
@@ -1,40 +1,25 @@
|
|
1
1
|
module LastFM
|
2
|
-
class Venue
|
3
|
-
class << self
|
2
|
+
class Venue < Struct.new(:id, :name, :location, :url, :website, :phone_number, :images)
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# @see http://www.last.fm/api/show?service=395
|
23
|
-
def get_past_events( params )
|
24
|
-
LastFM.get( "#{TYPE}.getPastEvents", params )
|
4
|
+
def update_from_node(node)
|
5
|
+
case node.name.to_sym
|
6
|
+
when :id
|
7
|
+
self.id = node.content.to_i
|
8
|
+
when :name
|
9
|
+
self.name = node.content
|
10
|
+
when :location
|
11
|
+
# ??? city, country, street, postalcode, geo:lat, geo:long
|
12
|
+
when :url
|
13
|
+
self.url = node.content
|
14
|
+
when :website
|
15
|
+
self.website = node.content
|
16
|
+
when :phoneNumber
|
17
|
+
self.phone_number = node.content
|
18
|
+
when :image
|
19
|
+
self.images ||= {}
|
20
|
+
self.images.merge!({node['size'].to_sym => node.content})
|
25
21
|
end
|
26
|
-
|
27
|
-
# Search for a venue by venue name.
|
28
|
-
#
|
29
|
-
# @option params [String, required] :venue the venue name to search for
|
30
|
-
# @option params [String, optional] :country a country name used to limit results, as defined by ISO 3166-1
|
31
|
-
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
32
|
-
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
33
|
-
# @see http://www.last.fm/api/show?service=396
|
34
|
-
def search( params )
|
35
|
-
LastFM.get( "#{TYPE}.search", params )
|
36
|
-
end
|
37
|
-
|
38
22
|
end
|
39
|
-
|
40
|
-
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/lastfm/wiki.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module LastFM
|
2
|
+
|
3
|
+
# @attr [Time] published Date the information in this entry was published
|
4
|
+
# @attr [String] summary Short summary of the information in this entry
|
5
|
+
# @attr [String] content Full content of this entry
|
6
|
+
class Wiki < Struct.new(:published, :summary, :content)
|
7
|
+
|
8
|
+
def update_from_node(node)
|
9
|
+
case node.name.to_sym
|
10
|
+
when :published
|
11
|
+
self.published = Time.parse(node.content)
|
12
|
+
when :summary #TODO: Remove CDATA wrapper
|
13
|
+
self.summary = node.content
|
14
|
+
when :content #TODO: Remove CDATA wrapper
|
15
|
+
self.content = node.content
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/rscrobbler.rb
CHANGED
@@ -1,28 +1,41 @@
|
|
1
1
|
require 'digest/md5'
|
2
2
|
require 'libxml'
|
3
3
|
require 'net/http'
|
4
|
+
require 'time'
|
4
5
|
require 'uri'
|
5
6
|
|
6
7
|
$:.unshift(File.dirname(__FILE__))
|
7
8
|
|
9
|
+
require 'lastfm/struct'
|
10
|
+
|
8
11
|
require 'lastfm/album'
|
9
12
|
require 'lastfm/artist'
|
10
|
-
require 'lastfm/
|
11
|
-
require 'lastfm/chart'
|
13
|
+
require 'lastfm/buylink'
|
12
14
|
require 'lastfm/event'
|
13
|
-
require 'lastfm/
|
14
|
-
require 'lastfm/group'
|
15
|
-
require 'lastfm/library'
|
16
|
-
require 'lastfm/playlist'
|
17
|
-
require 'lastfm/radio'
|
15
|
+
require 'lastfm/shout'
|
18
16
|
require 'lastfm/tag'
|
19
|
-
require 'lastfm/tasteometer'
|
20
17
|
require 'lastfm/track'
|
21
|
-
require 'lastfm/user'
|
22
18
|
require 'lastfm/venue'
|
19
|
+
require 'lastfm/wiki'
|
20
|
+
|
21
|
+
require 'lastfm/api/album'
|
22
|
+
require 'lastfm/api/artist'
|
23
|
+
require 'lastfm/api/auth'
|
24
|
+
require 'lastfm/api/chart'
|
25
|
+
require 'lastfm/api/event'
|
26
|
+
require 'lastfm/api/geo'
|
27
|
+
require 'lastfm/api/group'
|
28
|
+
require 'lastfm/api/library'
|
29
|
+
require 'lastfm/api/playlist'
|
30
|
+
require 'lastfm/api/radio'
|
31
|
+
require 'lastfm/api/tag'
|
32
|
+
require 'lastfm/api/tasteometer'
|
33
|
+
require 'lastfm/api/track'
|
34
|
+
require 'lastfm/api/user'
|
35
|
+
require 'lastfm/api/venue'
|
23
36
|
|
24
37
|
module LastFM
|
25
|
-
VERSION = '0.
|
38
|
+
VERSION = '0.2.0'
|
26
39
|
|
27
40
|
HOST = 'ws.audioscrobbler.com'
|
28
41
|
API_VERSION = '2.0'
|
@@ -62,7 +75,7 @@ module LastFM
|
|
62
75
|
[:api_key, :api_secret, :username, :auth_token].each do |cred|
|
63
76
|
raise AuthenticationError, "Missing credential: #{cred}" unless LastFM.send(cred)
|
64
77
|
end
|
65
|
-
self.session_key = Auth.get_mobile_session( username: username, auth_token: auth_token ).find_first('session/key').content
|
78
|
+
self.session_key = Api::Auth.get_mobile_session( username: username, auth_token: auth_token ).find_first('session/key').content
|
66
79
|
end
|
67
80
|
|
68
81
|
# Has the service been authenticated?
|
data/test/test_album.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
load 'lib/rscrobbler.rb'
|
3
|
+
|
4
|
+
def check_attributes(model, attrs)
|
5
|
+
attrs.each do |attr|
|
6
|
+
assert_not_nil model.send(attr), "#{attr} expected to be set."
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class LastFM::AlbumTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def setup
|
13
|
+
LastFM.api_key = 'b25b959554ed76058ac220b7b2e0a026'
|
14
|
+
@artist = 'Cher'
|
15
|
+
@album = 'Believe'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_search
|
19
|
+
albums = LastFM::Album.search :album => @album, :limit => 1
|
20
|
+
assert_equal 1, albums.size
|
21
|
+
assert albums.first.is_a? LastFM::Album
|
22
|
+
check_attributes albums.first, [:name, :artist, :id, :url, :images, :streamable, :mbid]
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_info
|
26
|
+
assert_raise LastFM::LastFMError do
|
27
|
+
LastFM::Album.get_info :album => @album
|
28
|
+
end
|
29
|
+
album = LastFM::Album.get_info :artist => @artist, :album => @album
|
30
|
+
assert_equal @artist, album.artist
|
31
|
+
assert_equal @album, album.name
|
32
|
+
assert album.wiki.is_a? LastFM::Wiki
|
33
|
+
check_attributes album, [:artist, :id, :images, :listeners, :mbid, :name, :playcount, :release_date, :tags, :tracks, :url, :wiki]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rscrobbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libxml-ruby
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152911920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152911920
|
25
25
|
description: rscrobbler is a Ruby gem for accessing Last.fm's API (http://www.last.fm/api).
|
26
26
|
email:
|
27
27
|
- sgt.floydpepper@gmail.com
|
@@ -31,37 +31,32 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- lib/lastfm/album.rb
|
34
|
+
- lib/lastfm/api/album.rb
|
35
|
+
- lib/lastfm/api/artist.rb
|
36
|
+
- lib/lastfm/api/auth.rb
|
37
|
+
- lib/lastfm/api/chart.rb
|
38
|
+
- lib/lastfm/api/event.rb
|
39
|
+
- lib/lastfm/api/geo.rb
|
40
|
+
- lib/lastfm/api/group.rb
|
41
|
+
- lib/lastfm/api/library.rb
|
42
|
+
- lib/lastfm/api/playlist.rb
|
43
|
+
- lib/lastfm/api/radio.rb
|
44
|
+
- lib/lastfm/api/tag.rb
|
45
|
+
- lib/lastfm/api/tasteometer.rb
|
46
|
+
- lib/lastfm/api/track.rb
|
47
|
+
- lib/lastfm/api/user.rb
|
48
|
+
- lib/lastfm/api/venue.rb
|
34
49
|
- lib/lastfm/artist.rb
|
35
|
-
- lib/lastfm/
|
36
|
-
- lib/lastfm/chart.rb
|
50
|
+
- lib/lastfm/buylink.rb
|
37
51
|
- lib/lastfm/event.rb
|
38
|
-
- lib/lastfm/
|
39
|
-
- lib/lastfm/
|
40
|
-
- lib/lastfm/library.rb
|
41
|
-
- lib/lastfm/playlist.rb
|
42
|
-
- lib/lastfm/radio.rb
|
52
|
+
- lib/lastfm/shout.rb
|
53
|
+
- lib/lastfm/struct.rb
|
43
54
|
- lib/lastfm/tag.rb
|
44
|
-
- lib/lastfm/tasteometer.rb
|
45
55
|
- lib/lastfm/track.rb
|
46
|
-
- lib/lastfm/user.rb
|
47
56
|
- lib/lastfm/venue.rb
|
57
|
+
- lib/lastfm/wiki.rb
|
48
58
|
- lib/rscrobbler.rb
|
49
|
-
- test/
|
50
|
-
- test/unit/lib/lastfm/artist_test.rb
|
51
|
-
- test/unit/lib/lastfm/auth_test.rb
|
52
|
-
- test/unit/lib/lastfm/chart_test.rb
|
53
|
-
- test/unit/lib/lastfm/event_test.rb
|
54
|
-
- test/unit/lib/lastfm/geo_test.rb
|
55
|
-
- test/unit/lib/lastfm/group_test.rb
|
56
|
-
- test/unit/lib/lastfm/library_test.rb
|
57
|
-
- test/unit/lib/lastfm/playlist_test.rb
|
58
|
-
- test/unit/lib/lastfm/radio_test.rb
|
59
|
-
- test/unit/lib/lastfm/tag_test.rb
|
60
|
-
- test/unit/lib/lastfm/tasteometer_test.rb
|
61
|
-
- test/unit/lib/lastfm/track_test.rb
|
62
|
-
- test/unit/lib/lastfm/user_test.rb
|
63
|
-
- test/unit/lib/lastfm/venue_test.rb
|
64
|
-
- test/unit/lib/rscrobbler_test.rb
|
59
|
+
- test/test_album.rb
|
65
60
|
- bin/generate_lastfm_auth_token
|
66
61
|
homepage: https://github.com/sgtFloyd/rscrobbler
|
67
62
|
licenses: []
|
@@ -88,20 +83,5 @@ signing_key:
|
|
88
83
|
specification_version: 3
|
89
84
|
summary: Last.fm API wrapper
|
90
85
|
test_files:
|
91
|
-
- test/
|
92
|
-
- test/unit/lib/lastfm/artist_test.rb
|
93
|
-
- test/unit/lib/lastfm/auth_test.rb
|
94
|
-
- test/unit/lib/lastfm/chart_test.rb
|
95
|
-
- test/unit/lib/lastfm/event_test.rb
|
96
|
-
- test/unit/lib/lastfm/geo_test.rb
|
97
|
-
- test/unit/lib/lastfm/group_test.rb
|
98
|
-
- test/unit/lib/lastfm/library_test.rb
|
99
|
-
- test/unit/lib/lastfm/playlist_test.rb
|
100
|
-
- test/unit/lib/lastfm/radio_test.rb
|
101
|
-
- test/unit/lib/lastfm/tag_test.rb
|
102
|
-
- test/unit/lib/lastfm/tasteometer_test.rb
|
103
|
-
- test/unit/lib/lastfm/track_test.rb
|
104
|
-
- test/unit/lib/lastfm/user_test.rb
|
105
|
-
- test/unit/lib/lastfm/venue_test.rb
|
106
|
-
- test/unit/lib/rscrobbler_test.rb
|
86
|
+
- test/test_album.rb
|
107
87
|
has_rdoc:
|
data/lib/lastfm/auth.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module LastFM
|
2
|
-
class Auth
|
3
|
-
class << self
|
4
|
-
|
5
|
-
TYPE = 'auth'
|
6
|
-
|
7
|
-
# Create a web service session for a user. Used for authenticating a user when the
|
8
|
-
# password can be inputted by the user. Only suitable for standalone mobile devices.
|
9
|
-
#
|
10
|
-
# @option params [String, required] :username last.fm username
|
11
|
-
# @option params [String, required] :auth_token md5 hash of the username + the password hash
|
12
|
-
# @see http://www.last.fm/api/show?service=266
|
13
|
-
def get_mobile_session( params )
|
14
|
-
LastFM.get( "#{TYPE}.getMobileSession", params, :secure )
|
15
|
-
end
|
16
|
-
|
17
|
-
# Fetch a session key for a user. The third step in the authentication process.
|
18
|
-
#
|
19
|
-
# @option params [String, required] :token md5 hash returned by step 1 of the authentication process
|
20
|
-
# @see http://www.last.fm/api/show?service=125
|
21
|
-
def get_session( params )
|
22
|
-
LastFM.get( "#{TYPE}.getSession", params, :secure )
|
23
|
-
end
|
24
|
-
|
25
|
-
# Fetch an unathorized request token for an API account. This is step 2 of
|
26
|
-
# the authentication process for desktop applications.
|
27
|
-
#
|
28
|
-
# @see http://www.last.fm/api/show?service=265
|
29
|
-
def get_token
|
30
|
-
LastFM.get( "#{TYPE}.getToken", {}, :secure )
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|