rscrobbler 0.0.6 → 0.1.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/album.rb +78 -24
- data/lib/lastfm/artist.rb +149 -55
- data/lib/lastfm/auth.rb +19 -8
- data/lib/lastfm/chart.rb +41 -17
- data/lib/lastfm/event.rb +46 -17
- data/lib/lastfm/geo.rb +93 -32
- data/lib/lastfm/group.rb +47 -17
- data/lib/lastfm/library.rb +81 -30
- data/lib/lastfm/playlist.rb +23 -9
- data/lib/lastfm/radio.rb +24 -10
- data/lib/lastfm/tag.rb +57 -17
- data/lib/lastfm/tasteometer.rb +25 -3
- data/lib/lastfm/track.rb +185 -66
- data/lib/lastfm/user.rb +178 -53
- data/lib/lastfm/venue.rb +22 -6
- data/lib/rscrobbler.rb +29 -10
- 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
- metadata +37 -5
data/lib/lastfm/album.rb
CHANGED
@@ -4,58 +4,112 @@ module LastFM
|
|
4
4
|
|
5
5
|
TYPE = 'album'
|
6
6
|
|
7
|
+
# Tag an album using a list of user supplied tags.
|
8
|
+
#
|
9
|
+
# @option params [String, required] :artist the artist name
|
10
|
+
# @option params [String, required] :album the album name
|
11
|
+
# @option params [Array, required] :tags up to 10 tags to apply to this album
|
7
12
|
# @see http://www.last.fm/api/show?service=302
|
8
|
-
def add_tags(
|
13
|
+
def add_tags( params )
|
9
14
|
LastFM.requires_authentication
|
10
|
-
LastFM.post( "#{TYPE}.addTags",
|
15
|
+
LastFM.post( "#{TYPE}.addTags", params )
|
11
16
|
end
|
12
17
|
|
18
|
+
# Get a list of buy links for an album.
|
19
|
+
#
|
20
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
21
|
+
# @option params [String, required unless :mbid] :album the album name
|
22
|
+
# @option params [String, optional] :mbid the musicbrainz id for the album
|
23
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
24
|
+
# @option params [String, optional] :country a country name, as defined by ISO 3166-1
|
13
25
|
# @see http://www.last.fm/api/show?service=429
|
14
|
-
def get_buylinks(
|
15
|
-
|
16
|
-
LastFM.get( "#{TYPE}.getBuylinks", !:secure, 'country'=>country, 'artist'=>artist, 'album'=>album, 'mbid'=>mbid, 'autocorrect'=>autocorrect )
|
26
|
+
def get_buylinks( params )
|
27
|
+
LastFM.get( "#{TYPE}.getBuylinks", params )
|
17
28
|
end
|
18
29
|
|
30
|
+
# Get the metadata for an album.
|
31
|
+
#
|
32
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
33
|
+
# @option params [String, required unless :mbid] :album the album name
|
34
|
+
# @option params [String, optional] :mbid the musicbrainz id for the album
|
35
|
+
# @option params [String, optional] :lang the language to return the biography in, expressed as an ISO 639 alpha-2 code
|
36
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
37
|
+
# @option params [String, optional] :username username whose playcount for this album is to be returned in the reponse
|
19
38
|
# @see http://www.last.fm/api/show?service=290
|
20
|
-
def get_info(
|
21
|
-
|
22
|
-
LastFM.get( "#{TYPE}.getInfo", !:secure, 'artist'=>artist, 'album'=>album, 'mbid'=>mbid, 'lang'=>lang, 'autocorrect'=>autocorrect, 'username'=>username )
|
39
|
+
def get_info( params )
|
40
|
+
LastFM.get( "#{TYPE}.getInfo", params )
|
23
41
|
end
|
24
42
|
|
43
|
+
# Get shouts for an album.
|
44
|
+
#
|
45
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
46
|
+
# @option params [String, required unless :mbid] :album the album name
|
47
|
+
# @option params [String, optional] :mbid the musicbrainz id for the album
|
48
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
49
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
50
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
25
51
|
# @see http://www.last.fm/api/show?service=450
|
26
|
-
def get_shouts(
|
27
|
-
|
28
|
-
LastFM.get( "#{TYPE}.getShouts", !:secure, 'artist'=>artist, 'album'=>album, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'limit'=>limit, 'page'=>page )
|
52
|
+
def get_shouts( params )
|
53
|
+
LastFM.get( "#{TYPE}.getShouts", params )
|
29
54
|
end
|
30
55
|
|
56
|
+
# Get the tags applied by an individual user to an album.
|
57
|
+
#
|
58
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
59
|
+
# @option params [String, required unless :mbid] :album the album name
|
60
|
+
# @option params [String, optional] :mbid the musicbrainz id for the album
|
61
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
62
|
+
# @option params [String, optional] :user if called in non-authenticated mode you must specify the user to look up
|
31
63
|
# @see http://www.last.fm/api/show?service=317
|
32
|
-
def get_tags(
|
33
|
-
|
34
|
-
LastFM.requires_authentication
|
35
|
-
LastFM.get( "#{TYPE}.getTags",
|
64
|
+
def get_tags( params )
|
65
|
+
secure = !params.include?(:user)
|
66
|
+
LastFM.requires_authentication if secure
|
67
|
+
LastFM.get( "#{TYPE}.getTags", params, secure )
|
36
68
|
end
|
37
69
|
|
70
|
+
# Get the top tags for an album, ordered by popularity.
|
71
|
+
#
|
72
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
73
|
+
# @option params [String, required unless :mbid] :album the album name
|
74
|
+
# @option params [String, optional] :mbid the musicbrainz id for the album
|
75
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
38
76
|
# @see http://www.last.fm/api/show?service=438
|
39
|
-
def get_top_tags(
|
40
|
-
|
41
|
-
LastFM.get( "#{TYPE}.getTopTags", !:secure, 'artist'=>artist, 'album'=>album, 'mbid'=>mbid, 'autocorrect'=>autocorrect )
|
77
|
+
def get_top_tags( params )
|
78
|
+
LastFM.get( "#{TYPE}.getTopTags", params )
|
42
79
|
end
|
43
80
|
|
81
|
+
# Remove a user's tag from an album.
|
82
|
+
#
|
83
|
+
# @option params [String, required] :artist the artist name
|
84
|
+
# @option params [String, required] :album the album name
|
85
|
+
# @option params [String, required] :tag a single user tag to remove from this album
|
44
86
|
# @see http://www.last.fm/api/show?service=314
|
45
|
-
def remove_tag(
|
87
|
+
def remove_tag( params )
|
46
88
|
LastFM.requires_authentication
|
47
|
-
LastFM.post( "#{TYPE}.removeTag",
|
89
|
+
LastFM.post( "#{TYPE}.removeTag", params )
|
48
90
|
end
|
49
91
|
|
92
|
+
# Search for an album by name. Returns album matches sorted by relevance.
|
93
|
+
#
|
94
|
+
# @option params [String, required] :album the album name
|
95
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
96
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
50
97
|
# @see http://www.last.fm/api/show?service=357
|
51
|
-
def search(
|
52
|
-
LastFM.get( "#{TYPE}.search",
|
98
|
+
def search( params )
|
99
|
+
LastFM.get( "#{TYPE}.search", params )
|
53
100
|
end
|
54
101
|
|
102
|
+
# Share an album with one or more Last.fm users or other friends.
|
103
|
+
#
|
104
|
+
# @option params [String, required] :artist the artist name
|
105
|
+
# @option params [String, required] :album the album name
|
106
|
+
# @option params [Array, required] :recipient a list of email addresses or Last.fm usernames. maximum is 10
|
107
|
+
# @option params [String, optional] :message an optional message to send. if not supplied a default message will be used
|
108
|
+
# @option params [Boolean, optional] :public optionally show in the sharing users activity feed. defaults to false
|
55
109
|
# @see http://www.last.fm/api/show?service=436
|
56
|
-
def share(
|
110
|
+
def share( params )
|
57
111
|
LastFM.requires_authentication
|
58
|
-
LastFM.post( "#{TYPE}.share",
|
112
|
+
LastFM.post( "#{TYPE}.share", params )
|
59
113
|
end
|
60
114
|
|
61
115
|
end
|
data/lib/lastfm/artist.rb
CHANGED
@@ -4,111 +4,205 @@ module LastFM
|
|
4
4
|
|
5
5
|
TYPE = 'artist'
|
6
6
|
|
7
|
+
# Tag an artist with one or more user supplied tags.
|
8
|
+
#
|
9
|
+
# @option params [String, required] :artist the artist name
|
10
|
+
# @option params [Array, required] :tags up to 10 tags to apply to this artist
|
7
11
|
# @see http://www.last.fm/api/show/?service=303
|
8
|
-
def add_tags(
|
12
|
+
def add_tags( params )
|
9
13
|
LastFM.requires_authentication
|
10
|
-
LastFM.post( "#{TYPE}.addTags",
|
14
|
+
LastFM.post( "#{TYPE}.addTags", params )
|
11
15
|
end
|
12
16
|
|
17
|
+
# Check whether the supplied artist has a correction to a canonical artist.
|
18
|
+
#
|
19
|
+
# @option params [String, required] :artist the artist name
|
13
20
|
# @see http://www.last.fm/api/show/?service=446
|
14
|
-
def get_correction(
|
15
|
-
LastFM.get( "#{TYPE}.getCorrection",
|
16
|
-
end
|
17
|
-
|
21
|
+
def get_correction( params )
|
22
|
+
LastFM.get( "#{TYPE}.getCorrection", params )
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get a list of upcoming events for this artist.
|
26
|
+
#
|
27
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
28
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
29
|
+
# @option params [Boolean, optional] :festivalsonly whether only festivals should be returned, or all events
|
30
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
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
|
18
33
|
# @see http://www.last.fm/api/show/?service=117
|
19
|
-
def get_events(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
34
|
+
def get_events( params )
|
35
|
+
LastFM.get( "#{TYPE}.getEvents", params )
|
36
|
+
end
|
37
|
+
|
38
|
+
# Get images for this artist in a variety of sizes.
|
39
|
+
#
|
40
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
41
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
42
|
+
# @option params [Symbol, optional] :order sort ordering can be either :popularity (default) or :dateadded
|
43
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned 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
|
24
46
|
# @see http://www.last.fm/api/show/?service=407
|
25
|
-
def get_images(
|
26
|
-
|
27
|
-
LastFM.get( "#{TYPE}.getImages", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'order'=>order, 'limit'=>limit, 'page'=>page )
|
47
|
+
def get_images( params )
|
48
|
+
LastFM.get( "#{TYPE}.getImages", params )
|
28
49
|
end
|
29
50
|
|
51
|
+
# Get the metadata for an artist. Includes biography.
|
52
|
+
#
|
53
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
54
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
55
|
+
# @option params [String, optional] :lang the language to return the biography in, expressed as an ISO 639 alpha-2 code
|
56
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
57
|
+
# @option params [String, optional] :username username whose playcount for this artist is to be returned in the reponse
|
30
58
|
# @see http://www.last.fm/api/show/?service=267
|
31
|
-
def get_info(
|
32
|
-
|
33
|
-
LastFM.get( "#{TYPE}.getInfo", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'lang'=>lang, 'username'=>username )
|
59
|
+
def get_info( params )
|
60
|
+
LastFM.get( "#{TYPE}.getInfo", params )
|
34
61
|
end
|
35
62
|
|
63
|
+
# Get a paginated list of all the events this artist has played at in the past.
|
64
|
+
#
|
65
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
66
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
67
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
68
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
69
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
36
70
|
# @see http://www.last.fm/api/show/?service=428
|
37
|
-
def get_past_events(
|
38
|
-
|
39
|
-
LastFM.get( "#{TYPE}.getPastEvents", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'limit'=>limit, 'page'=>page )
|
71
|
+
def get_past_events( params )
|
72
|
+
LastFM.get( "#{TYPE}.getPastEvents", params )
|
40
73
|
end
|
41
74
|
|
75
|
+
# Get a podcast of free mp3s based on an artist.
|
76
|
+
#
|
77
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
78
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
79
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
42
80
|
# @see http://www.last.fm/api/show/?service=118
|
43
|
-
def get_podcast(
|
44
|
-
|
45
|
-
LastFM.get( "#{TYPE}.getPodcast", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect )
|
81
|
+
def get_podcast( params )
|
82
|
+
LastFM.get( "#{TYPE}.getPodcast", params )
|
46
83
|
end
|
47
84
|
|
85
|
+
# Get shouts for this artist.
|
86
|
+
#
|
87
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
88
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
89
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
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
|
48
92
|
# @see http://www.last.fm/api/show/?service=397
|
49
|
-
def get_shouts(
|
50
|
-
|
51
|
-
LastFM.get( "#{TYPE}.getShouts", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'limit'=>limit, 'page'=>page )
|
93
|
+
def get_shouts( params )
|
94
|
+
LastFM.get( "#{TYPE}.getShouts", params )
|
52
95
|
end
|
53
96
|
|
97
|
+
# Get all the artists similar to this artist.
|
98
|
+
#
|
99
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
100
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
101
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
102
|
+
# @option params [Fixnum, optional] :limit limit the number of results to fetch
|
54
103
|
# @see http://www.last.fm/api/show/?service=119
|
55
|
-
def get_similar(
|
56
|
-
|
57
|
-
LastFM.get( "#{TYPE}.getSimilar", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'limit'=>limit )
|
104
|
+
def get_similar( params )
|
105
|
+
LastFM.get( "#{TYPE}.getSimilar", params )
|
58
106
|
end
|
59
107
|
|
108
|
+
# Get the tags applied by an individual user to an artist on Last.fm. If accessed as an authenticated service
|
109
|
+
# and you don't supply a user parameter then this service will return tags for the authenticated user.
|
110
|
+
#
|
111
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
112
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
113
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
114
|
+
# @option params [String, optional] :user if called in non-authenticated mode you must specify the user to look up
|
60
115
|
# @see http://www.last.fm/api/show/?service=318
|
61
|
-
def get_tags(
|
62
|
-
|
63
|
-
LastFM.requires_authentication
|
64
|
-
LastFM.get( "#{TYPE}.getTags",
|
65
|
-
end
|
66
|
-
|
116
|
+
def get_tags( params )
|
117
|
+
secure = !params.include?(:user)
|
118
|
+
LastFM.requires_authentication if secure
|
119
|
+
LastFM.get( "#{TYPE}.getTags", params, secure )
|
120
|
+
end
|
121
|
+
|
122
|
+
# Get the top albums for an artist, ordered by popularity.
|
123
|
+
#
|
124
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
125
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
126
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
127
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
128
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
67
129
|
# @see http://www.last.fm/api/show/?service=287
|
68
|
-
def get_top_albums(
|
69
|
-
|
70
|
-
LastFM.get( "#{TYPE}.getTopAlbums", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'limit'=>limit, 'page'=>page )
|
130
|
+
def get_top_albums( params )
|
131
|
+
LastFM.get( "#{TYPE}.getTopAlbums", params )
|
71
132
|
end
|
72
133
|
|
134
|
+
# Get the top fans for an artist on Last.fm, based on listening data.
|
135
|
+
#
|
136
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
137
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
138
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
73
139
|
# @see http://www.last.fm/api/show/?service=310
|
74
|
-
def get_top_fans(
|
75
|
-
|
76
|
-
LastFM.get( "#{TYPE}.getTopFans", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect )
|
140
|
+
def get_top_fans( params )
|
141
|
+
LastFM.get( "#{TYPE}.getTopFans", params )
|
77
142
|
end
|
78
143
|
|
144
|
+
# Get the top tags for an artist, ordered by popularity.
|
145
|
+
#
|
146
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
147
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
148
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
79
149
|
# @see http://www.last.fm/api/show/?service=288
|
80
|
-
def get_top_tags(
|
81
|
-
|
82
|
-
LastFM.get( "#{TYPE}.getTopTags", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect )
|
150
|
+
def get_top_tags( params )
|
151
|
+
LastFM.get( "#{TYPE}.getTopTags", params )
|
83
152
|
end
|
84
153
|
|
154
|
+
# Get the top tracks by an artist, ordered by popularity.
|
155
|
+
#
|
156
|
+
# @option params [String, required unless :mbid] :artist the artist name
|
157
|
+
# @option params [String, optional] :mbid the musicbrainz id for the artist
|
158
|
+
# @option params [Boolean, optional] :autocorrect transform misspelled artist names into correct artist names to be returned in the response
|
159
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
160
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
85
161
|
# @see http://www.last.fm/api/show/?service=277
|
86
|
-
def get_top_tracks(
|
87
|
-
|
88
|
-
LastFM.get( "#{TYPE}.getTopTracks", !:secure, 'artist'=>artist, 'mbid'=>mbid, 'autocorrect'=>autocorrect, 'limit'=>limit, 'page'=>page )
|
162
|
+
def get_top_tracks( params )
|
163
|
+
LastFM.get( "#{TYPE}.getTopTracks", params )
|
89
164
|
end
|
90
165
|
|
166
|
+
# Remove a user's tag from an artist.
|
167
|
+
#
|
168
|
+
# @option params [String, required] :artist the artist name
|
169
|
+
# @option params [String, required] :tag a single user tag to remove from this artist
|
91
170
|
# @see http://www.last.fm/api/show/?service=315
|
92
|
-
def remove_tag(
|
171
|
+
def remove_tag( params )
|
93
172
|
LastFM.requires_authentication
|
94
|
-
LastFM.post( "#{TYPE}.removeTag",
|
173
|
+
LastFM.post( "#{TYPE}.removeTag", params )
|
95
174
|
end
|
96
175
|
|
176
|
+
# Search for an artist by name. Returns artist matches sorted by relevance.
|
177
|
+
#
|
178
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
179
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
180
|
+
# @option params [String, required] :artist the artist name
|
97
181
|
# @see http://www.last.fm/api/show/?service=272
|
98
|
-
def search(
|
99
|
-
LastFM.get( "#{TYPE}.search",
|
182
|
+
def search( params )
|
183
|
+
LastFM.get( "#{TYPE}.search", params )
|
100
184
|
end
|
101
185
|
|
186
|
+
# Share an artist with Last.fm users or other friends.
|
187
|
+
#
|
188
|
+
# @option params [String, required] :artist the artist name
|
189
|
+
# @option params [Array, required] :recipient a list of email addresses or Last.fm usernames. maximum is 10
|
190
|
+
# @option params [String, optional] :message an optional message to send. if not supplied a default message will be used
|
191
|
+
# @option params [Boolean, optional] :public optionally show in the sharing users activity feed. defaults to false
|
102
192
|
# @see http://www.last.fm/api/show/?service=306
|
103
|
-
def share(
|
193
|
+
def share( params )
|
104
194
|
LastFM.requires_authentication
|
105
|
-
LastFM.post( "#{TYPE}.share",
|
195
|
+
LastFM.post( "#{TYPE}.share", params )
|
106
196
|
end
|
107
197
|
|
198
|
+
# Shout in this artist's shoutbox.
|
199
|
+
#
|
200
|
+
# @option params [String, required] :artist name of the artist to shout on
|
201
|
+
# @option params [String, required] :message message to post to the shoutbox
|
108
202
|
# @see http://www.last.fm/api/show/?service=408
|
109
|
-
def shout(
|
203
|
+
def shout( params )
|
110
204
|
LastFM.requires_authentication
|
111
|
-
LastFM.post( "#{TYPE}.shout",
|
205
|
+
LastFM.post( "#{TYPE}.shout", params )
|
112
206
|
end
|
113
207
|
|
114
208
|
end
|
data/lib/lastfm/auth.rb
CHANGED
@@ -4,19 +4,30 @@ module LastFM
|
|
4
4
|
|
5
5
|
TYPE = 'auth'
|
6
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
|
7
12
|
# @see http://www.last.fm/api/show?service=266
|
8
|
-
def get_mobile_session(
|
9
|
-
LastFM.get( "#{TYPE}.getMobileSession", :secure
|
13
|
+
def get_mobile_session( params )
|
14
|
+
LastFM.get( "#{TYPE}.getMobileSession", params, :secure )
|
10
15
|
end
|
11
|
-
|
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
|
12
20
|
# @see http://www.last.fm/api/show?service=125
|
13
|
-
def get_session(
|
14
|
-
LastFM.get( "#{TYPE}.getSession", :secure )
|
21
|
+
def get_session( params )
|
22
|
+
LastFM.get( "#{TYPE}.getSession", params, :secure )
|
15
23
|
end
|
16
|
-
|
24
|
+
|
25
|
+
# Fetch an unathorized request token for an API account. This is step 2 of
|
26
|
+
# the authentication process for desktop applications.
|
27
|
+
#
|
17
28
|
# @see http://www.last.fm/api/show?service=265
|
18
|
-
def get_token
|
19
|
-
LastFM.get( "#{TYPE}.getToken", :secure )
|
29
|
+
def get_token
|
30
|
+
LastFM.get( "#{TYPE}.getToken", {}, :secure )
|
20
31
|
end
|
21
32
|
|
22
33
|
end
|
data/lib/lastfm/chart.rb
CHANGED
@@ -4,34 +4,58 @@ module LastFM
|
|
4
4
|
|
5
5
|
TYPE = 'chart'
|
6
6
|
|
7
|
+
# Get the hyped artists chart
|
8
|
+
#
|
9
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
10
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
7
11
|
# @see http://www.last.fm/api/show?service=493
|
8
|
-
def get_hyped_artists(
|
9
|
-
LastFM.get( "#{TYPE}.getHypedArtists",
|
12
|
+
def get_hyped_artists( params )
|
13
|
+
LastFM.get( "#{TYPE}.getHypedArtists", params )
|
10
14
|
end
|
11
|
-
|
15
|
+
|
16
|
+
# Get the hyped tracks chart
|
17
|
+
#
|
18
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
19
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
12
20
|
# @see http://www.last.fm/api/show?service=494
|
13
|
-
def get_hyped_tracks(
|
14
|
-
LastFM.get( "#{TYPE}.getHypedTracks",
|
21
|
+
def get_hyped_tracks( params )
|
22
|
+
LastFM.get( "#{TYPE}.getHypedTracks", params )
|
15
23
|
end
|
16
|
-
|
24
|
+
|
25
|
+
# Get the most loved tracks chart
|
26
|
+
#
|
27
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
28
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
17
29
|
# @see http://www.last.fm/api/show?service=495
|
18
|
-
def get_loved_tracks(
|
19
|
-
LastFM.get( "#{TYPE}.getLovedTracks",
|
30
|
+
def get_loved_tracks( params )
|
31
|
+
LastFM.get( "#{TYPE}.getLovedTracks", params )
|
20
32
|
end
|
21
|
-
|
33
|
+
|
34
|
+
# Get the top artists chart
|
35
|
+
#
|
36
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
37
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
22
38
|
# @see http://www.last.fm/api/show?service=496
|
23
|
-
def get_top_artists(
|
24
|
-
LastFM.get( "#{TYPE}.getTopArtists",
|
39
|
+
def get_top_artists( params )
|
40
|
+
LastFM.get( "#{TYPE}.getTopArtists", params )
|
25
41
|
end
|
26
|
-
|
42
|
+
|
43
|
+
# Get the top tags chart
|
44
|
+
#
|
45
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
46
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
27
47
|
# @see http://www.last.fm/api/show?service=497
|
28
|
-
def get_top_tags(
|
29
|
-
LastFM.get( "#{TYPE}.getTopTags",
|
48
|
+
def get_top_tags( params )
|
49
|
+
LastFM.get( "#{TYPE}.getTopTags", params )
|
30
50
|
end
|
31
|
-
|
51
|
+
|
52
|
+
# Get the top tracks chart
|
53
|
+
#
|
54
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
55
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
32
56
|
# @see http://www.last.fm/api/show?service=498
|
33
|
-
def get_top_tracks(
|
34
|
-
LastFM.get( "#{TYPE}.getTopTracks",
|
57
|
+
def get_top_tracks( params )
|
58
|
+
LastFM.get( "#{TYPE}.getTopTracks", params )
|
35
59
|
end
|
36
60
|
|
37
61
|
end
|
data/lib/lastfm/event.rb
CHANGED
@@ -4,37 +4,66 @@ module LastFM
|
|
4
4
|
|
5
5
|
TYPE = 'event'
|
6
6
|
|
7
|
+
# Set a user's attendance status for an event.
|
8
|
+
#
|
9
|
+
# @option params [Fixnum, required] :event numeric last.fm event id
|
10
|
+
# @option params [Symbol, required] :status attendance status. accepted values are :attending, :maybe_attending, and :not_attending
|
7
11
|
# @see http://www.last.fm/api/show?service=307
|
8
|
-
def attend(
|
12
|
+
def attend( params )
|
9
13
|
LastFM.requires_authentication
|
10
|
-
|
14
|
+
status_codes = { attending: 0, maybe_attending: 1, not_attending: 2 }
|
15
|
+
params[:status] = status_codes[params[:status]] if params.include?(:status)
|
16
|
+
LastFM.post( "#{TYPE}.attend", params )
|
11
17
|
end
|
12
|
-
|
18
|
+
|
19
|
+
# Get a list of attendees for an event.
|
20
|
+
#
|
21
|
+
# @option params [Fixnum, required] :event numeric last.fm event id
|
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
|
13
24
|
# @see http://www.last.fm/api/show?service=391
|
14
|
-
def get_attendees(
|
15
|
-
LastFM.get( "#{TYPE}.getAttendees",
|
25
|
+
def get_attendees( params )
|
26
|
+
LastFM.get( "#{TYPE}.getAttendees", params )
|
16
27
|
end
|
17
|
-
|
28
|
+
|
29
|
+
# Get the metadata for an event on Last.fm. Includes attendance and lineup information.
|
30
|
+
#
|
31
|
+
# @option params [Fixnum, required] :event numeric last.fm event id
|
18
32
|
# @see http://www.last.fm/api/show?service=292
|
19
|
-
def get_info(
|
20
|
-
LastFM.get( "#{TYPE}.getInfo",
|
33
|
+
def get_info( params )
|
34
|
+
LastFM.get( "#{TYPE}.getInfo", params )
|
21
35
|
end
|
22
|
-
|
36
|
+
|
37
|
+
# Get shouts for an event.
|
38
|
+
#
|
39
|
+
# @option params [Fixnum, required] :event numeric last.fm event id
|
40
|
+
# @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
|
41
|
+
# @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
|
23
42
|
# @see http://www.last.fm/api/show?service=399
|
24
|
-
def get_shouts(
|
25
|
-
LastFM.get( "#{TYPE}.getShouts",
|
43
|
+
def get_shouts( params )
|
44
|
+
LastFM.get( "#{TYPE}.getShouts", params )
|
26
45
|
end
|
27
|
-
|
46
|
+
|
47
|
+
# Share an event with one or more Last.fm users or other friends.
|
48
|
+
#
|
49
|
+
# @option params [Fixnum, required] :event numeric last.fm event id
|
50
|
+
# @option params [Array, required] :recipient a list of email addresses or Last.fm usernames. maximum is 10
|
51
|
+
# @option params [String, optional] :message an optional message to send. if not supplied a default message will be used
|
52
|
+
# @option params [Boolean, optional] :public optionally show in the sharing users activity feed. defaults to false
|
28
53
|
# @see http://www.last.fm/api/show?service=350
|
29
|
-
def share(
|
54
|
+
def share( params )
|
30
55
|
LastFM.requires_authentication
|
31
|
-
LastFM.post( "#{TYPE}.share",
|
56
|
+
LastFM.post( "#{TYPE}.share", params )
|
32
57
|
end
|
33
|
-
|
58
|
+
|
59
|
+
# Shout in an event's shoutbox.
|
60
|
+
#
|
61
|
+
# @option params [Fixnum, required] :event numeric last.fm event id
|
62
|
+
# @option params [String, required] :message message to post to the shoutbox
|
34
63
|
# @see http://www.last.fm/api/show?service=409
|
35
|
-
def shout(
|
64
|
+
def shout( params )
|
36
65
|
LastFM.requires_authentication
|
37
|
-
LastFM.post( "#{TYPE}.shout",
|
66
|
+
LastFM.post( "#{TYPE}.shout", params )
|
38
67
|
end
|
39
68
|
|
40
69
|
end
|