rscrobbler 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/lastfm/track.rb CHANGED
@@ -1,57 +1,324 @@
1
- module LastFM
2
-
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)
50
- end
51
- when :wiki
52
- self.wiki = LastFM::Wiki.from_xml(node)
53
- end
54
- end
55
-
56
- end
57
- end
1
+ module LastFM
2
+
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)
50
+ end
51
+ when :wiki
52
+ self.wiki = LastFM::Wiki.from_xml(node)
53
+ end
54
+ end
55
+
56
+ # API Methods
57
+ class << self
58
+
59
+ # Add a list of user supplied tags to a track.
60
+ #
61
+ # @option params [String, required] :artist the artist name
62
+ # @option params [String, required] :track the track name
63
+ # @option params [Array, required] :tags array of tags to apply to this track. accepts a maximum of 10.
64
+ # @see http://www.last.fm/api/show?service=304
65
+ def add_tags( params )
66
+ LastFM.requires_authentication
67
+ LastFM.post( "track.addTags", params )
68
+ end
69
+
70
+ # Ban a track for the current user.
71
+ #
72
+ # @option params [String, required] :artist the artist name
73
+ # @option params [String, required] :track the track name
74
+ # @see http://www.last.fm/api/show?service=261
75
+ def ban( params )
76
+ LastFM.requires_authentication
77
+ LastFM.post( "track.ban", params )
78
+ end
79
+
80
+ # Get a list of buy Links for a track.
81
+ #
82
+ # @option params [String, required unless :mbid] :artist the artist name
83
+ # @option params [String, required unless :mbid] :track the track name
84
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
85
+ # @option params [String, optional] :mbid the musicbrainz id for the track
86
+ # @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
87
+ # @return [Array<LastFM::Buylink>] collection of links where this track can be bought or downloaded
88
+ # @see http://www.last.fm/api/show?service=431
89
+ def get_buylinks( params )
90
+ xml = LastFM.get( "track.getBuylinks", params )
91
+ [:physical, :download].each_with_object([]) do |type, buylinks|
92
+ xml.find("affiliations/#{type}s/affiliation").each do |buylink|
93
+ buylinks << LastFM::Buylink.from_xml( buylink, :type => type )
94
+ end
95
+ end
96
+ end
97
+
98
+ # Use the last.fm corrections data to check whether the supplied track has a correction to a canonical track
99
+ #
100
+ # @option params [String, required] :artist the artist name to correct
101
+ # @option params [String, required] :track the track name to correct
102
+ # @see http://www.last.fm/api/show?service=447
103
+ def get_correction( params )
104
+ LastFM.get( "track.getCorrection", params )
105
+ end
106
+
107
+ # Retrieve track metadata associated with a fingerprint id generated by the Last.fm Fingerprinter.
108
+ # Returns track elements, along with a 'rank' value between 0 and 1 reflecting the confidence for
109
+ # each match.
110
+ #
111
+ # @option params [String, required] :fingerprint_id the fingerprint id to look up
112
+ # @see http://www.last.fm/api/show?service=441
113
+ # @see https://github.com/lastfm/Fingerprinter
114
+ # @see http://blog.last.fm/2010/07/09/fingerprint-api-and-app-updated
115
+ def get_fingerprint_metadata( params )
116
+ LastFM.get( "track.getFingerPrintMetadata", params )
117
+ end
118
+
119
+ # Get the metadata for a track.
120
+ #
121
+ # @option params [String, required unless :mbid] :artist the artist name
122
+ # @option params [String, required unless :mbid] :track the track name
123
+ # @option params [String, optional] :mbid the musicbrainz id for the track
124
+ # @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
125
+ # @option params [String, optional] :username username whose playcount for, and whether they've loved, this track is to be returned in the reponse
126
+ # @return [LastFM::Track] track constructed from the metadata contained in the response
127
+ # @see http://www.last.fm/api/show?service=356
128
+ def get_info( params )
129
+ xml = LastFM.get( "track.getInfo", params )
130
+ LastFM::Track.from_xml( xml )
131
+ end
132
+
133
+ # Get shouts for a track.
134
+ #
135
+ # @option params [String, required unless :mbid] :artist the artist name
136
+ # @option params [String, required unless :mbid] :track the track name
137
+ # @option params [String, optional] :mbid the musicbrainz id for the track
138
+ # @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
139
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
140
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
141
+ # @return [Array<LastFM::Shout>] collection of shouts
142
+ # @see http://www.last.fm/api/show?service=453
143
+ def get_shouts( params )
144
+ xml = LastFM.get( "track.getShouts", params )
145
+ xml.find('shouts/shout').map do |shout|
146
+ LastFM::Shout.from_xml( shout )
147
+ end
148
+ end
149
+
150
+ # Get similar tracks for a track on Last.fm, based on listening data.
151
+ #
152
+ # @option params [String, required unless :mbid] :artist the artist name
153
+ # @option params [String, required unless :mbid] :track the track name
154
+ # @option params [String, optional] :mbid the musicbrainz id for the track
155
+ # @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
156
+ # @option params [Fixnum, optional] :limit the number of results to fetch. defaults to 50
157
+ # @return [Array<LastFM::Track>] similar tracks, ordered by similarity
158
+ # @see http://www.last.fm/api/show?service=319
159
+ def get_similar( params )
160
+ xml = LastFM.get( "track.getSimilar", params )
161
+ xml.find('similartracks/track').map do |track|
162
+ LastFM::Track.from_xml( track )
163
+ end
164
+ end
165
+
166
+ # Get the tags on a track.
167
+ #
168
+ # @option params [String, required unless :mbid] :artist the artist name
169
+ # @option params [String, required unless :mbid] :track the track name
170
+ # @option params [String, optional] :mbid the musicbrainz id for the track
171
+ # @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
172
+ # @option params [String, optional] :user if called in non-authenticated mode you must specify the user to look up
173
+ # @see http://www.last.fm/api/show?service=320
174
+ def get_tags( params )
175
+ secure = !params.include?(:user)
176
+ LastFM.requires_authentication if secure
177
+ LastFM.post( "track.getTags", params, secure )
178
+ end
179
+
180
+ # Get the top fans for a track, based on listening data.
181
+ #
182
+ # @option params [String, required unless :mbid] :artist the artist name
183
+ # @option params [String, required unless :mbid] :track the track name
184
+ # @option params [String, optional] :mbid the musicbrainz id for the track
185
+ # @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
186
+ # @see http://www.last.fm/api/show?service=312
187
+ def get_top_fans( params )
188
+ LastFM.get( "track.getTopFans", params )
189
+ end
190
+
191
+ # Get the top fans for a track, ordered by tag count.
192
+ #
193
+ # @option params [String, required unless :mbid] :artist the artist name
194
+ # @option params [String, required unless :mbid] :track the track name
195
+ # @option params [String, optional] :mbid the musicbrainz id for the track
196
+ # @option params [Boolean, optional] :autocorrect correct misspelled artist and track names to be returned in the response
197
+ # @return [Array<LastFM::Tag>] list of tags ordered by popularity
198
+ # @see http://www.last.fm/api/show?service=289
199
+ def get_top_tags( params )
200
+ xml = LastFM.get( "track.getTopTags", params )
201
+ xml.find('toptags/tag').map do |tag|
202
+ LastFM::Tag.from_xml( tag )
203
+ end
204
+ end
205
+
206
+ # Love a track for the current user.
207
+ #
208
+ # @option params [String, required] :artist the artist name
209
+ # @option params [String, required] :track the track name
210
+ # @see http://www.last.fm/api/show?service=260
211
+ def love( params )
212
+ LastFM.requires_authentication
213
+ LastFM.post( "track.love", params )
214
+ end
215
+
216
+ # Remove a user's tag from a track.
217
+ #
218
+ # @option params [String, required] :artist the artist name
219
+ # @option params [String, required] :track the track name
220
+ # @option params [String, required] :tag a single user tag to remove from this track
221
+ # @see http://www.last.fm/api/show?service=316
222
+ def remove_tag( params )
223
+ LastFM.requires_authentication
224
+ LastFM.post( "track.removeTag", params )
225
+ end
226
+
227
+ # Used to add a track-play to a user's profile. Scrobble a track, or a batch of tracks.
228
+ # Single tracks may be passed using the Object types listed, batches of tracks must be
229
+ # passed in as Arrays of each Object type. Allows up to a maximum of 50 scrobbles per
230
+ # batch. For batch scrobbles, Array indices of optional parameters must line up with
231
+ # the indicies of their corresponding tracks.
232
+ #
233
+ # @option params [String, required unless :mbid] :artist artist name
234
+ # @option params [String, required unless :mbid] :track track name
235
+ # @option params [String, optional] :mbid the musicbrainz id for the track
236
+ # @option params [Time, optional] :timestamp time the track started playing
237
+ # @option params [String, optional] :album album name
238
+ # @option params [String, optional] :album_artist album artist, if this differend from the track artist
239
+ # @option params [Fixnum, optional] :track_number track number of the track on the album
240
+ # @option params [Fixnum, optional] :duration track length, in seconds
241
+ # @option params [String, optional] :stream_id track stream id, received from the radio.getPlaylist service
242
+ # @option params [Boolean, optional] :chosen_by_user whether or not the user chose the track
243
+ # @option params [String, optional] :context sub-client version (not public, only enabled for certain api keys)
244
+ # @see http://www.last.fm/api/show?service=443
245
+ def scrobble( params )
246
+ LastFM.requires_authentication
247
+ # Tracks are passed to the service using array notation for each of the above params
248
+ array_params = {}
249
+ params.each do |hkey, hval|
250
+ hval = hval.to_i if hval.is_a?(Time)
251
+ Array(hval).each_with_index do |aval, index|
252
+ array_params["#{hkey}[#{index}]"] = aval
253
+ end
254
+ end
255
+ LastFM.post( "track.scrobble", array_params )
256
+ end
257
+
258
+ # Search for a track by track name. Returns track matches sorted by relevance.
259
+ #
260
+ # @option params [String, required] :track the track name
261
+ # @option params [String, optional] :artist narrow results based on an artist
262
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
263
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
264
+ # @return [Array<LastFM::Track>] list of tracks sorted by relevance
265
+ # @see http://www.last.fm/api/show?service=286
266
+ def search( params )
267
+ xml = LastFM.get( "track.search", params )
268
+ xml.find('results/trackmatches/track').map do |track|
269
+ LastFM::Track.from_xml( track )
270
+ end
271
+ end
272
+
273
+ # Share a track twith one or more Last.fm users or other friends.
274
+ #
275
+ # @option params [String, required] :artist the artist name
276
+ # @option params [String, required] :track the track name
277
+ # @option params [Array, required] :recipient a list of email addresses or Last.fm usernames. maximum is 10
278
+ # @option params [String, optional] :message an optional message to send. if not supplied a default message will be used
279
+ # @option params [Boolean, optional] :public optionally show in the sharing users activity feed. defaults to false
280
+ # @see http://www.last.fm/api/show?service=305
281
+ def share( params )
282
+ LastFM.requires_authentication
283
+ LastFM.post( "track.share", params )
284
+ end
285
+
286
+ # Unban a track for the current user.
287
+ #
288
+ # @option params [String, required] :artist the artist name
289
+ # @option params [String, required] :track the track name
290
+ # @see http://www.last.fm/api/show?service=449
291
+ def unban( params )
292
+ LastFM.requires_authentication
293
+ LastFM.post( "track.unban", params )
294
+ end
295
+
296
+ # Unlove a track for the current user.
297
+ #
298
+ # @option params [String, required] :artist the artist name
299
+ # @option params [String, required] :track the track name
300
+ # @see http://www.last.fm/api/show?service=440
301
+ def unlove( params )
302
+ LastFM.requires_authentication
303
+ LastFM.post( "track.unlove", params )
304
+ end
305
+
306
+ # Used to notify Last.fm that a user has started listening to a track.
307
+ #
308
+ # @option params [String, required unless :mbid] :artist artist name
309
+ # @option params [String, required unless :mbid] :track track name
310
+ # @option params [String, optional] :mbid the musicbrainz id for the track
311
+ # @option params [String, optional] :album album name
312
+ # @option params [String, optional] :album_artist album artist, if this differend from the track artist
313
+ # @option params [Fixnum, optional] :track_number track number of the track on the album
314
+ # @option params [Fixnum, optional] :duration track length, in seconds
315
+ # @option params [String, optional] :context sub-client version (not public, only enabled for certain api keys)
316
+ # @see http://www.last.fm/api/show?service=454
317
+ def update_now_playing( params )
318
+ LastFM.requires_authentication
319
+ LastFM.post( "track.updateNowPlaying", params )
320
+ end
321
+
322
+ end
323
+ end
324
+ end
@@ -0,0 +1,264 @@
1
+ module LastFM
2
+ class User
3
+ class << self
4
+
5
+ # Get a list of tracks by a given artist scrobbled by this user,
6
+ # including scrobble time. Can be limited to specific timeranges,
7
+ # defaults to all time.
8
+ #
9
+ # @option params [String, required] :user last.fm username to fetch the recent tracks for
10
+ # @option params [String, required] :artist the artist name to fetch tracks for
11
+ # @option params [Time, optional] :startTimestamp a unix timestamp to start at
12
+ # @option params [Time, optional] :endTimestamp a unix timestamp to end at
13
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
14
+ # @see http://www.last.fm/api/show?service=432
15
+ def get_artist_tracks( params )
16
+ LastFM.get( "user.getArtistTracks", params )
17
+ end
18
+
19
+ # Get a list of tracks banned by a user.
20
+ #
21
+ # @option params [String, required] :user last.fm username
22
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
23
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
24
+ # @see http://www.last.fm/api/show?service=448
25
+ def get_banned_tracks( params )
26
+ LastFM.get( "user.getBannedTracks", params )
27
+ end
28
+
29
+ # Get a list of upcoming events that this user is attending.
30
+ #
31
+ # @option params [String, required] :user last.fm username
32
+ # @option params [Boolean, optional] :festivalsonly whether only festivals should be returned, or all events
33
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
34
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
35
+ # @see http://www.last.fm/api/show?service=291
36
+ def get_events( params )
37
+ LastFM.get( "user.getEvents", params )
38
+ end
39
+
40
+ # Get a list of the user's friends on Last.fm.
41
+ #
42
+ # @option params [String, required] :user last.fm username
43
+ # @option params [Boolean, optional] :recenttracks whether or not to include information about friends' recent listening in the response.
44
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
45
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
46
+ # @see http://www.last.fm/api/show?service=263
47
+ def get_friends( params )
48
+ LastFM.get( "user.getFriends", params )
49
+ end
50
+
51
+ # Get information about a user profile.
52
+ #
53
+ # @option params [String, optional] :user user to fetch info for. defaults to the authenticated user
54
+ # @see http://www.last.fm/api/show?service=344
55
+ def get_info( params )
56
+ LastFM.get( "user.getInfo", params )
57
+ end
58
+
59
+ # Get a list of tracks loved by a user.
60
+ #
61
+ # @option params [String, required] :user last.fm username
62
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
63
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
64
+ # @see http://www.last.fm/api/show?service=329
65
+ def get_loved_tracks( params )
66
+ LastFM.get( "user.getLovedTracks", params )
67
+ end
68
+
69
+ # Get a list of a user's neighbours on Last.fm.
70
+ #
71
+ # @option params [String, required] :user last.fm username
72
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
73
+ # @see http://www.last.fm/api/show?service=264
74
+ def get_neighbors( params )
75
+ LastFM.get( "user.getNeighbonrs", params )
76
+ end
77
+
78
+ # Gets a list of upcoming releases based on a user's musical taste.
79
+ #
80
+ # @option params [String, required] :user last.fm username
81
+ # @option params [Boolean, optional] :userecs if true, return new releases based on artist recommendations. otherwise, it is based on their library (the default)
82
+ # @see http://www.last.fm/api/show?service=444
83
+ def get_new_releases( params )
84
+ LastFM.get( "user.getNewReleases", params )
85
+ end
86
+
87
+ # Get a list of all events a user has attended in the past.
88
+ #
89
+ # @option params [String, required] :user last.fm username
90
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
91
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
92
+ # @see http://www.last.fm/api/show?service=343
93
+ def get_past_events( params )
94
+ LastFM.get( "user.getPastEvents", params )
95
+ end
96
+
97
+ # Get the user's personal tags.
98
+ #
99
+ # @option params [String, required] :user last.fm username
100
+ # @option params [String, required] :tag the tag you're interested in
101
+ # @option params [String, required] :taggingtype the type of items which have been tagged. accepted types are 'artist', 'album', or 'track'
102
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
103
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
104
+ # @see http://www.last.fm/api/show?service=455
105
+ def get_personal_tags( params )
106
+ LastFM.get( "user.getPersonalTags", params )
107
+ end
108
+
109
+ # Get a list of a user's playlists.
110
+ #
111
+ # @option params [String, required] :user last.fm username
112
+ # @see http://www.last.fm/api/show?service=313
113
+ def get_playlists( params )
114
+ LastFM.get( "user.getPlaylists", params )
115
+ end
116
+
117
+ # Get a list of the recent Stations listened to by a user.
118
+ #
119
+ # @option params [String, required] :user last.fm username
120
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
121
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
122
+ # @see http://www.last.fm/api/show?service=414
123
+ def get_recent_stations( params )
124
+ LastFM.requires_authentication
125
+ LastFM.get( "user.getRecentStations", params, :secure )
126
+ end
127
+
128
+ # Get a list of the recent tracks listened to by a user. Also includes
129
+ # the currently playing track with the nowplaying="true" attribute if
130
+ # the user is currently listening.
131
+ #
132
+ # @option params [String, required] :user last.fm username
133
+ # @option params [Time, optional] :from display scrobbles after this time, formatted as unix UTC integer timestamp
134
+ # @option params [Time, optional] :to display scrobbles before this time, formatted as unix UTC integer timestamp
135
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
136
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
137
+ # @see http://www.last.fm/api/show?service=278
138
+ def get_recent_tracks( params )
139
+ LastFM.get( "user.getRecentTracks", params )
140
+ end
141
+
142
+ # Get Last.fm artist recommendations for a user.
143
+ #
144
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
145
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
146
+ # @see http://www.last.fm/api/show?service=388
147
+ def get_recommended_artists( params )
148
+ LastFM.requires_authentication
149
+ LastFM.get( "user.getRecommendedArtists", params, :secure )
150
+ end
151
+
152
+ # Get a paginated list of all events recommended to a user by Last.fm, based on their listening profile.
153
+ #
154
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
155
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
156
+ # @see http://www.last.fm/api/show?service=375
157
+ def get_recommended_events( params )
158
+ LastFM.requires_authentication
159
+ LastFM.get( "user.getRecommendedEvents", params, :secure )
160
+ end
161
+
162
+ # Get shouts for a user.
163
+ #
164
+ # @option params [String, required] :user last.fm username
165
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
166
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
167
+ # @see http://www.last.fm/api/show?service=401
168
+ def get_shouts( params )
169
+ LastFM.get( "user.getShouts", params, :secure )
170
+ end
171
+
172
+ # Get the top albums listened to by a user, based on an optional time period.
173
+ #
174
+ # @option params [String, required] :user last.fm username
175
+ # @option params [String, optional] :period time period over which to retrieve top albums for. accepted values are 'overall', '7day', '3month', '6month' or '12month'
176
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
177
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
178
+ # @see http://www.last.fm/api/show?service=299
179
+ def get_top_albums( params )
180
+ LastFM.get( "user.getTopAlbums", params )
181
+ end
182
+
183
+ # Get the top artists listened to by a user, based on an optional time period.
184
+ #
185
+ # @option params [String, required] :user last.fm username
186
+ # @option params [String, optional] :period time period over which to retrieve top artists for. accepted values are 'overall', '7day', '3month', '6month' or '12month'
187
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
188
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
189
+ # @see http://www.last.fm/api/show?service=300
190
+ def get_top_artists( params )
191
+ LastFM.get( "user.getTopArtists", params )
192
+ end
193
+
194
+ # Get the top tags used by a user.
195
+ #
196
+ # @option params [String, required] :user last.fm username
197
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
198
+ # @see http://www.last.fm/api/show?service=123
199
+ def get_top_tags( params )
200
+ LastFM.get( "user.getTopTags", params )
201
+ end
202
+
203
+ # Get the top tracks listened to by a user, based on an optional time period.
204
+ #
205
+ # @option params [String, required] :user last.fm username
206
+ # @option params [String, optional] :period time period over which to retrieve top tracks for. accepted values are 'overall', '7day', '3month', '6month' or '12month'
207
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
208
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
209
+ # @see http://www.last.fm/api/show?service=301
210
+ def get_top_tracks( params )
211
+ LastFM.get( "user.getTopTracks", params )
212
+ end
213
+
214
+ # Get an album chart for a user, for a given date range. Defaults to the most recent chart.
215
+ #
216
+ # @option params [String, required] :user last.fm username
217
+ # @option params [String, optional] :from date at which the chart should start. (see: User.get_weekly_chart_list)
218
+ # @option params [String, optional] :to date at which the chart should end. (see: User.get_weekly_chart_list)
219
+ # @see http://www.last.fm/api/show?service=279
220
+ def get_weekly_album_chart( params )
221
+ LastFM.get( "user.getWeeklyAlbumChart", params )
222
+ end
223
+
224
+ # Get an artist chart for a user, for a given date range. Defaults to the most recent chart.
225
+ #
226
+ # @option params [String, required] :user last.fm username
227
+ # @option params [String, optional] :from date at which the chart should start. (see: User.get_weekly_chart_list)
228
+ # @option params [String, optional] :to date at which the chart should end. (see: User.get_weekly_chart_list)
229
+ # @see http://www.last.fm/api/show?service=281
230
+ def get_weekly_artist_chart( params )
231
+ LastFM.get( "user.getWeeklyArtistChart", params )
232
+ end
233
+
234
+ # Get a list of available charts for this user, expressed as date ranges which can be sent to the chart services.
235
+ #
236
+ # @option params [String, required] :user last.fm username
237
+ # @see http://www.last.fm/api/show?service=280
238
+ def get_weekly_chart_list( params )
239
+ LastFM.get( "user.getWeeklyChartList", params )
240
+ end
241
+
242
+ # Get a track chart for a user, for a given date range. Defaults to the most recent chart.
243
+ #
244
+ # @option params [String, required] :user last.fm username
245
+ # @option params [String, optional] :from date at which the chart should start. (see: User.get_weekly_chart_list)
246
+ # @option params [String, optional] :to date at which the chart should end. (see: User.get_weekly_chart_list)
247
+ # @see http://www.last.fm/api/show?service=282
248
+ def get_weekly_track_chart( params )
249
+ LastFM.get( "user.getWeeklyTrackChart", params )
250
+ end
251
+
252
+ # Shout on a user's shoutbox.
253
+ #
254
+ # @option params [String, required] :user user to shout on
255
+ # @option params [String, required] :message message to post to the shoutbox
256
+ # @see http://www.last.fm/api/show?service=411
257
+ def shout( params )
258
+ LastFM.requires_authentication
259
+ LastFM.post( "user.shout", params )
260
+ end
261
+
262
+ end
263
+ end
264
+ end