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/geo.rb CHANGED
@@ -4,59 +4,120 @@ module LastFM
4
4
 
5
5
  TYPE = 'geo'
6
6
 
7
+ # Get all events in a specific location by country or city name.
8
+ #
9
+ # @option params [String, optional] :location location to retrieve events for
10
+ # @option params [String, optional] :lat latitude value to retrieve events for
11
+ # @option params [String, optional] :long longitude value to retrieve events for
12
+ # @option params [Fixnum, optional] :distance find events within a specified radius (in kilometres)
13
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
14
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
7
15
  # @see http://www.last.fm/api/show?service=270
8
- def get_events( location = nil, lat = nil, long = nil, distance = nil, limit = nil, page = nil )
9
- LastFM.get( "#{TYPE}.getEvents", !:secure, 'location'=>location, 'lat'=>lat, 'long'=>long, 'distance'=>distance, 'limit'=>limit, 'page'=>page )
16
+ def get_events( params )
17
+ LastFM.get( "#{TYPE}.getEvents", !:secure, params )
10
18
  end
11
-
19
+
20
+ # Get a chart of artists for a metro.
21
+ #
22
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
23
+ # @option params [String, required] :metro the metro's name
24
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
25
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
12
26
  # @see http://www.last.fm/api/show?service=421
13
- def get_metro_artist_chart( country, metro, time_start = nil, time_end = nil )
14
- LastFM.get( "#{TYPE}.getMetroArtistChart", !:secure, 'country'=>country, 'metro'=>metro, 'start'=>time_start, 'end'=>time_end )
27
+ def get_metro_artist_chart( params )
28
+ LastFM.get( "#{TYPE}.getMetroArtistChart", params )
15
29
  end
16
-
30
+
31
+ # Get a chart of hyped (up and coming) artists for a metro.
32
+ #
33
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
34
+ # @option params [String, required] :metro the metro's name
35
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
36
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
17
37
  # @see http://www.last.fm/api/show?service=420
18
- def get_metro_hype_artist_chart( country, metro, time_start = nil, time_end = nil )
19
- LastFM.get( "#{TYPE}.getMetroHypeArtistChart", !:secure, 'country'=>country, 'metro'=>metro, 'start'=>time_start, 'end'=>time_end )
38
+ def get_metro_hype_artist_chart( params )
39
+ LastFM.get( "#{TYPE}.getMetroHypeArtistChart", params )
20
40
  end
21
-
41
+
42
+ # Get a chart of hyped (up and coming) tracks for a metro.
43
+ #
44
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
45
+ # @option params [String, required] :metro the metro's name
46
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
47
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
22
48
  # @see http://www.last.fm/api/show?service=422
23
- def get_metro_hype_track_chart( country, metro, time_start = nil, time_end = nil )
24
- LastFM.get( "#{TYPE}.getMetroHypeTrackChart", !:secure, 'country'=>country, 'metro'=>metro, 'start'=>time_start, 'end'=>time_end )
49
+ def get_metro_hype_track_chart( params )
50
+ LastFM.get( "#{TYPE}.getMetroHypeTrackChart", params )
25
51
  end
26
-
52
+
53
+ # Get a chart of tracks for a metro.
54
+ #
55
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
56
+ # @option params [String, required] :metro the metro's name
57
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
58
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
27
59
  # @see http://www.last.fm/api/show?service=423
28
- def get_metro_track_chart( country, metro, time_start = nil, time_end = nil )
29
- LastFM.get( "#{TYPE}.getMetroTrackChart", !:secure, 'country'=>country, 'metro'=>metro, 'start'=>time_start, 'end'=>time_end )
60
+ def get_metro_track_chart( params )
61
+ LastFM.get( "#{TYPE}.getMetroTrackChart", params )
30
62
  end
31
-
63
+
64
+ # Get a chart of the artists which make that metro unique
65
+ #
66
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
67
+ # @option params [String, required] :metro the metro's name
68
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
69
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
32
70
  # @see http://www.last.fm/api/show?service=424
33
- def get_metro_unique_artist_chart( country, metro, time_start = nil, time_end = nil )
34
- LastFM.get( "#{TYPE}.getMetroUniqueArtistChart", !:secure, 'country'=>country, 'metro'=>metro, 'start'=>time_start, 'end'=>time_end )
71
+ def get_metro_unique_artist_chart( params )
72
+ LastFM.get( "#{TYPE}.getMetroUniqueArtistChart", params )
35
73
  end
36
-
74
+
75
+ # Get a chart of the tracks which make that metro unique
76
+ #
77
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
78
+ # @option params [String, required] :metro the metro's name
79
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
80
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
37
81
  # @see http://www.last.fm/api/show?service=425
38
- def get_metro_unique_track_chart( country, metro, time_start = nil, time_end = nil )
39
- LastFM.get( "#{TYPE}.getMetroUniqueTrackChart", !:secure, 'country'=>country, 'metro'=>metro, 'start'=>time_start, 'end'=>time_end )
82
+ def get_metro_unique_track_chart( params )
83
+ LastFM.get( "#{TYPE}.getMetroUniqueTrackChart", params )
40
84
  end
41
-
85
+
86
+ # Get a list of available chart periods for this metro, expressed as date ranges which can be sent to the chart services.
87
+ #
88
+ # @option params [String, required] :metro metro name to fetch the charts list for
42
89
  # @see http://www.last.fm/api/show?service=426
43
- def get_metro_weekly_chartlist( metro )
44
- LastFM.get( "#{TYPE}.getMetroWeeklyChartlist", !:secure, 'metro'=>metro )
90
+ def get_metro_weekly_chartlist( params )
91
+ LastFM.get( "#{TYPE}.getMetroWeeklyChartlist", params )
45
92
  end
46
-
93
+
94
+ # Get a list of valid countries and metros for use in the other webservices
95
+ #
96
+ # @option params [String, optional] :country restrict results to metros from a particular country, as defined by ISO 3166-1
47
97
  # @see http://www.last.fm/api/show?service=435
48
- def get_metros( country = nil )
49
- LastFM.get( "#{TYPE}.getMetros", !:secure, 'country'=>country )
98
+ def get_metros( params )
99
+ LastFM.get( "#{TYPE}.getMetros", params )
50
100
  end
51
-
101
+
102
+ # Get the most popular artists on Last.fm by country
103
+ #
104
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
105
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
106
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
52
107
  # @see http://www.last.fm/api/show?service=297
53
- def get_top_artists( country, limit = nil, page = nil )
54
- LastFM.get( "#{TYPE}.getTopArtists", !:secure, 'country'=>country, 'limit'=>limit, 'page'=>page )
108
+ def get_top_artists( params )
109
+ LastFM.get( "#{TYPE}.getTopArtists", params )
55
110
  end
56
-
111
+
112
+ # Get the most popular tracks on Last.fm by country
113
+ #
114
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
115
+ # @option params [String, optional] :location location to fetch the charts for
116
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
117
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
57
118
  # @see http://www.last.fm/api/show?service=298
58
- def get_top_tracks( country, location = nil, limit = nil, page = nil )
59
- LastFM.get( "#{TYPE}.getTopTracks", !:secure, 'country'=>country, 'location'=>location, 'limit'=>limit, 'page'=>page )
119
+ def get_top_tracks( params )
120
+ LastFM.get( "#{TYPE}.getTopTracks", params )
60
121
  end
61
122
 
62
123
  end
data/lib/lastfm/group.rb CHANGED
@@ -4,34 +4,64 @@ module LastFM
4
4
 
5
5
  TYPE = 'group'
6
6
 
7
+ # Get the hype list for a group.
8
+ #
9
+ # @option params [String, required] :group the last.fm group name
7
10
  # @see http://www.last.fm/api/show?service=259
8
- def get_hype( group )
9
- LastFM.get( "#{TYPE}.getHype", !:secure, 'group'=>group )
11
+ def get_hype( params )
12
+ LastFM.get( "#{TYPE}.getHype", params )
10
13
  end
11
-
14
+
15
+ # Get the list of members for a group.
16
+ #
17
+ # @option params [String, required] :group the last.fm group name
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=379
13
- def get_members( group, limit = nil, page = nil )
14
- LastFM.get( "#{TYPE}.getMembers", !:secure, 'group'=>group, 'limit'=>limit, 'page'=>page )
21
+ def get_members( params )
22
+ LastFM.get( "#{TYPE}.getMembers", params )
15
23
  end
16
-
24
+
25
+ # Get an album chart for a group, for a given date range. If no date range
26
+ # is supplied, return the most recent.
27
+ #
28
+ # @option params [String, required] :group the last.fm group name
29
+ # @option params [Time, optional] :from date at which the chart should start from (see: Group.get_weekly_chart_list)
30
+ # @option params [Time, optional] :to date at which the chart should end on (see: Group.get_weekly_chart_list)
17
31
  # @see http://www.last.fm/api/show/?service=293
18
- def get_weekly_album_chart( group, date_from = nil, date_to = nil )
19
- LastFM.get( "#{TYPE}.getWeeklyAlbumChart", !:secure, 'group'=>group, 'from'=>date_from, 'to'=>date_to )
32
+ def get_weekly_album_chart( params )
33
+ LastFM.get( "#{TYPE}.getWeeklyAlbumChart", params )
20
34
  end
21
-
35
+
36
+ # Get an artist chart for a group, for a given date range. If no date range
37
+ # is supplied, return the most recent.
38
+ #
39
+ # @option params [String, required] :group the last.fm group name
40
+ # @option params [Time, optional] :from date at which the chart should start from (see: Group.get_weekly_chart_list)
41
+ # @option params [Time, optional] :to date at which the chart should end on (see: Group.get_weekly_chart_list)
22
42
  # @see http://www.last.fm/api/show/?service=294
23
- def get_weekly_artist_chart( group, date_from = nil, date_to = nil )
24
- LastFM.get( "#{TYPE}.getWeeklyArtistChart", !:secure, 'group'=>group, 'from'=>date_from, 'to'=>date_to )
43
+ def get_weekly_artist_chart( params )
44
+ LastFM.get( "#{TYPE}.getWeeklyArtistChart", params )
25
45
  end
26
-
46
+
47
+ # Get the list of available charts for a group, expressed as date ranges
48
+ # which can be sent to the chart services.
49
+ #
50
+ # @option params [String, required] :group the last.fm group name
27
51
  # @see http://www.last.fm/api/show/?service=295
28
- def get_weekly_chart_list( group )
29
- LastFM.get( "#{TYPE}.getWeeklyChartList", !:secure, 'group'=>group )
52
+ def get_weekly_chart_list( params )
53
+ LastFM.get( "#{TYPE}.getWeeklyChartList", params )
30
54
  end
31
-
55
+
56
+ # Get a track chart for a group, for a given date range. If no date range
57
+ # is supplied, return the most recent.
58
+ #
59
+ # @option params [String, required] :group the last.fm group name
60
+ # @option params [Time, optional] :from date at which the chart should start from (see: Group.get_weekly_chart_list)
61
+ # @option params [Time, optional] :to date at which the chart should end on (see: Group.get_weekly_chart_list)
32
62
  # @see http://www.last.fm/api/show/?service=296
33
- def get_weekly_track_chart( group, date_from = nil, date_to = nil )
34
- LastFM.get( "#{TYPE}.getWeeklyTrackChart", !:secure, 'group'=>group, 'from'=>date_from, 'to'=>date_to )
63
+ def get_weekly_track_chart( params )
64
+ LastFM.get( "#{TYPE}.getWeeklyTrackChart", params )
35
65
  end
36
66
 
37
67
  end
@@ -4,61 +4,112 @@ module LastFM
4
4
 
5
5
  TYPE = 'library'
6
6
 
7
- # see: http://www.last.fm/api/show?service=370
8
- def add_album( artist, album )
7
+ # Add an album or collection of albums to a user's Last.fm library.
8
+ #
9
+ # @option params [Array, required] :artists the artist or collection of artists to add
10
+ # @option params [Array, required] :albums the album or collection of albums to add. the indices of the albums that you pass MUST correspond to those of the artists
11
+ # @see http://www.last.fm/api/show?service=370
12
+ def add_album( params )
9
13
  LastFM.requires_authentication
10
- LastFM.post( "#{TYPE}.addAlbum", 'artist'=>artist, 'album'=>album )
14
+ # convert :artists and :albums to individual artist[i] and album[i]
15
+ Array(params.delete(:artists)).each_with_index{|val, i| params["artist[#{i}]"] = val}
16
+ Array(params.delete(:albums)).each_with_index{|val, i| params["album[#{i}]"] = val}
17
+ LastFM.post( "#{TYPE}.addAlbum", params )
11
18
  end
12
19
 
13
- # see: http://www.last.fm/api/show?service=371
14
- def add_artist( artist )
20
+ # Add an artist or collection of artists to a user's Last.fm library.
21
+ #
22
+ # @option params [Array, required] :artists the artist or collection of artists to add
23
+ # @see http://www.last.fm/api/show?service=371
24
+ def add_artist( params )
15
25
  LastFM.requires_authentication
16
- LastFM.post( "#{TYPE}.addArtist", 'artist'=>artist )
26
+ Array(params.delete(:artists)).each_with_index{|val, i| params["artist[#{i}]"] = val}
27
+ LastFM.post( "#{TYPE}.addArtist", params )
17
28
  end
18
29
 
19
- # see: http://www.last.fm/api/show?service=372
20
- def add_track( track, artist )
30
+ # Add a track or collection of tracks to a user's Last.fm library.
31
+ #
32
+ # @option params [Array, required] :artists the artist or collection of artists to add
33
+ # @option params [Array, required] :tracks the track or collection of tracks to add. the indices of the tracks that you pass MUST correspond to those of the artists
34
+ # @see http://www.last.fm/api/show?service=372
35
+ def add_track( params )
21
36
  LastFM.requires_authentication
22
- LastFM.post( "#{TYPE}.addTrack", 'track'=>track, 'artist'=>artist )
37
+ Array(params.delete(:artists)).each_with_index{|val, i| params["artist[#{i}]"] = val}
38
+ Array(params.delete(:tracks)).each_with_index{|val, i| params["track[#{i}]"] = val}
39
+ LastFM.post( "#{TYPE}.addTrack", params )
23
40
  end
24
41
 
25
- # see: http://www.last.fm/api/show?service=321
26
- def get_albums( user, artist = nil, limit = nil, page = nil )
27
- LastFM.get( "#{TYPE}.getAlbums", !:secure, 'user'=>user, 'artist'=>artist, 'limit'=>limit, 'page'=>page )
42
+ # A paginated list of all the albums in a user's library, with play counts and tag counts.
43
+ #
44
+ # @option params [String, requried] :user the user whose library you want to fetch
45
+ # @option params [String, optional] :artist an artist by which to filter albums
46
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
47
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
48
+ # @see http://www.last.fm/api/show?service=321
49
+ def get_albums( params )
50
+ LastFM.get( "#{TYPE}.getAlbums", params )
28
51
  end
29
52
 
30
- # see: http://www.last.fm/api/show?service=322
31
- def get_artists( user, limit = nil, page = nil )
32
- LastFM.get( "#{TYPE}.getArtists", !:secure, 'user'=>user, 'limit'=>limit, 'page'=>page )
53
+ # A paginated list of all the artists in a user's library, with play counts and tag counts.
54
+ #
55
+ # @option params [String, requried] :user the user whose library you want to fetch
56
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
57
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
58
+ # @see http://www.last.fm/api/show?service=322
59
+ def get_artists( params )
60
+ LastFM.get( "#{TYPE}.getArtists", params )
33
61
  end
34
62
 
35
- # see: http://www.last.fm/api/show?service=323
36
- def get_tracks( user, artist = nil, album = nil, limit = nil, page = nil )
37
- LastFM.get( "#{TYPE}.getTracks", !:secure, 'user'=>user, 'artist'=>artist, 'album'=>album, 'limit'=>limit, 'page'=>page )
63
+ # A paginated list of all the tracks in a user's library, with play counts and tag counts.
64
+ #
65
+ # @option params [String, requried] :user the user whose library you want to fetch
66
+ # @option params [String, optional] :artist an artist by which to filter track
67
+ # @option params [String, optional] :album an album by which to filter tracks (requires an associated artist)
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
70
+ # @see http://www.last.fm/api/show?service=323
71
+ def get_tracks( params )
72
+ LastFM.get( "#{TYPE}.getTracks", params )
38
73
  end
39
74
 
40
- # see: http://www.last.fm/api/show?service=523
41
- def remove_album( artist, album )
75
+ # Remove an album from a user's Last.fm library.
76
+ #
77
+ # @option params [String, required] :artist the artist that composed the album
78
+ # @option params [String, required] :album the name of the album to remove
79
+ # @see http://www.last.fm/api/show?service=523
80
+ def remove_album( params )
42
81
  LastFM.requires_authentication
43
- LastFM.post( "#{TYPE}.removeAlbum", 'artist'=>artist, 'album'=>album )
82
+ LastFM.post( "#{TYPE}.removeAlbum", params )
44
83
  end
45
84
 
46
- # see: http://www.last.fm/api/show?service=524
47
- def remove_artist( artist )
85
+ # Remove an artist from a user's Last.fm library.
86
+ #
87
+ # @option params [String, required] :artist the name of the artist to remove
88
+ # @see http://www.last.fm/api/show?service=524
89
+ def remove_artist( params )
48
90
  LastFM.requires_authentication
49
- LastFM.post( "#{TYPE}.removeArtist", 'artist'=>artist )
91
+ LastFM.post( "#{TYPE}.removeArtist", params )
50
92
  end
51
93
 
52
- # see: http://www.last.fm/api/show?service=525
53
- def remove_scrobble( track, artist, timestamp )
94
+ # Remove a scrobble from a user's Last.fm library.
95
+ #
96
+ # @option params [String, required] :artist the artist that composed the album
97
+ # @option params [String, required] :track the name of the track to remove
98
+ # @option params [Time, required] :timestamp the unix timestamp of the scrobble to remove
99
+ # @see http://www.last.fm/api/show?service=525
100
+ def remove_scrobble( params )
54
101
  LastFM.requires_authentication
55
- LastFM.post( "#{TYPE}.removeScrobble", 'track'=>track, 'artist'=>artist, 'timestamp'=>timestamp )
102
+ LastFM.post( "#{TYPE}.removeScrobble", params )
56
103
  end
57
104
 
58
- # see: http://www.last.fm/api/show?service=526
59
- def remove_track( track, artist )
105
+ # Remove a track from a user's Last.fm library.
106
+ #
107
+ # @option params [String, required] :artist the artist that composed the track
108
+ # @option params [String, required] :track the name of the track to remove
109
+ # @see http://www.last.fm/api/show?service=526
110
+ def remove_track( params )
60
111
  LastFM.requires_authentication
61
- LastFM.post( "#{TYPE}.removeTrack", 'track'=>track, 'artist'=>artist )
112
+ LastFM.post( "#{TYPE}.removeTrack", params )
62
113
  end
63
114
 
64
115
  end
@@ -4,21 +4,35 @@ module LastFM
4
4
 
5
5
  TYPE = 'playlist'
6
6
 
7
- # see: http://www.last.fm/api/show?service=337
8
- def add_track( playlist_id, artist, track )
7
+ # Add a track to a Last.fm user's playlist
8
+ #
9
+ # @option params [String, required] :playlist_id the id of the playlist (see: User.get_playlists)
10
+ # @option params [String, required] :track the track name to add to the playlist
11
+ # @option params [String, required] :artist the artist that corresponds to the track to be added
12
+ # @see http://www.last.fm/api/show?service=337
13
+ def add_track( params )
9
14
  LastFM.requires_authentication
10
- LastFM.post( "#{TYPE}.addTrack", 'playlistID'=>playlist_id, 'artist'=>artist, 'track'=>track )
15
+ LastFM.post( "#{TYPE}.addTrack", params )
11
16
  end
12
17
 
13
- # see: http://www.last.fm/api/show?service=365
14
- def create( title = nil, description = nil )
18
+ # Create a Last.fm playlist on behalf of a user.
19
+ #
20
+ # @option params [String, optional] :title title for the playlist
21
+ # @option params [String, optional] :description description for the playlist
22
+ # @see http://www.last.fm/api/show?service=365
23
+ def create( params )
15
24
  LastFM.requires_authentication
16
- LastFM.post( "#{TYPE}.create", 'title'=>title, 'description'=>description )
25
+ LastFM.post( "#{TYPE}.create", params )
17
26
  end
18
27
 
19
- # see: http://www.last.fm/api/show?service=271
20
- def fetch( playlist_url )
21
- LastFM.get( "#{TYPE}.fetch", !:secure, 'playlistURL'=>playlist_url )
28
+ # Fetch XSPF playlists using a lastfm playlist url.
29
+ #
30
+ # @option params [String, required] :playlist_url lastfm protocol playlist url (lastfm://playlist/...)
31
+ # @option params [Boolean, optional] :steaming whether to return mp3 links for song previews
32
+ # @see http://www.last.fm/api/show?service=271
33
+ # @deprecated documentation removed from last.fm/api, but method calls still work
34
+ def fetch( params )
35
+ LastFM.get( "#{TYPE}.fetch", params )
22
36
  end
23
37
 
24
38
  end
data/lib/lastfm/radio.rb CHANGED
@@ -4,22 +4,36 @@ module LastFM
4
4
 
5
5
  TYPE = 'radio'
6
6
 
7
- # see: http://www.last.fm/api/show?service=256
8
- def get_playlist( discovery = nil, rtp = nil, buylinks = nil, speed_multiplier = nil, bitrate = nil )
9
- raise ArgumentError unless [1.0, 2.0].include?(speed_multiplier) && [64, 128].include?(bitrate)
7
+ # Fetch new radio content periodically in an XSPF format.
8
+ #
9
+ # @option params [Boolean, optional] :discovery whether to request last.fm content in discovery mode
10
+ # @option params [Boolean, optional] :rtp whether the user is scrobbling or not during this session (helps content generation)
11
+ # @option params [Boolean, optional] :buylinks whether the response should contain links for purchase/download
12
+ # @option params [String, optional] :speed_multiplier the rate at which to provide the stream (supported multipliers are 1.0 and 2.0)
13
+ # @option params [String, optional] :bitrate what bitrate to stream content at, in kbps (supported bitrates are 64 and 128)
14
+ # @see http://www.last.fm/api/show?service=256
15
+ def get_playlist( params )
10
16
  LastFM.requires_authentication
11
- LastFM.get( "#{TYPE}.getPlaylist", :secure, 'discovery'=>discovery, 'rtp'=>rtp, 'buylinks'=>buylinks, 'speed_multiplier'=>speed_multiplier, 'bitrate'=>bitrate )
17
+ LastFM.get( "#{TYPE}.getPlaylist", params, :secure )
12
18
  end
13
19
 
14
- # see: http://www.last.fm/api/show?service=418
15
- def search( name )
16
- LastFM.get( "#{TYPE}.search", !:secure, 'name'=>name )
20
+ # Resolve the name of a resource into a station depending
21
+ # on which resource it is most likely to represent.
22
+ #
23
+ # @option params [String, required] :name the tag or artist name to resolve
24
+ # @see http://www.last.fm/api/show?service=418
25
+ def search( params )
26
+ LastFM.get( "#{TYPE}.search", params )
17
27
  end
18
28
 
19
- # see: http://www.last.fm/api/show?service=160
20
- def tune( station, lang = nil )
29
+ # Tune in to a Last.fm radio station.
30
+ #
31
+ # @option params [String, required] :station a 'lastfm://...' radio url
32
+ # @option params [String, optional] :lang the language to return the station name in, expressed as an ISO 639 alpha-2 code
33
+ # @see http://www.last.fm/api/show?service=160
34
+ def tune( params )
21
35
  LastFM.requires_authentication
22
- LastFM.post( "#{TYPE}.tune", 'station'=>station, 'lang'=>lang )
36
+ LastFM.post( "#{TYPE}.tune", params )
23
37
  end
24
38
 
25
39
  end
data/lib/lastfm/tag.rb CHANGED
@@ -4,49 +4,89 @@ module LastFM
4
4
 
5
5
  TYPE = 'tag'
6
6
 
7
+ # Get the metadata for a tag.
8
+ #
9
+ # @option params [String, required] :tag the tag name
10
+ # @option params [String, optinoal] :lang the language to return the summary in, expressed as an ISO 639 alpha-2 code
7
11
  # @see http://www.last.fm/api/show?service=452
8
- def get_info( tag, lang = nil )
9
- LastFM.get( "#{TYPE}.getInfo", !:secure, 'tag'=>tag, 'lang'=>lang )
12
+ def get_info( params )
13
+ LastFM.get( "#{TYPE}.getInfo", params )
10
14
  end
11
15
 
16
+ # Search for tags similar to this one. Returns tags ranked by similarity, based on listening data.
17
+ #
18
+ # @option params [String, required] tag the tag name
12
19
  # @see http://www.last.fm/api/show?service=311
13
- def get_similar( tag )
14
- LastFM.get( "#{TYPE}.getSimilar", !:secure, 'tag'=>tag )
20
+ def get_similar( params )
21
+ LastFM.get( "#{TYPE}.getSimilar", params )
15
22
  end
16
23
 
24
+ # Get the top albums tagged with a tag, ordered by tag count.
25
+ #
26
+ # @option params [String, required] :tag the tag name
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=283
18
- def get_top_albums( tag, limit = nil, page = nil )
19
- LastFM.get( "#{TYPE}.getTopAlbums", !:secure, 'tag'=>tag, 'limit'=>limit, 'page'=>page )
30
+ def get_top_albums( params )
31
+ LastFM.get( "#{TYPE}.getTopAlbums", params )
20
32
  end
21
33
 
34
+ # Get the top artists tagged with a tag, ordered by tag count.
35
+ #
36
+ # @option params [String, required] :tag the tag name
37
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
38
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
22
39
  # @see http://www.last.fm/api/show?service=284
23
- def get_top_artists( tag, limit = nil, page = nil )
24
- LastFM.get( "#{TYPE}.getTopArtists", !:secure, 'tag'=>tag, 'limit'=>limit, 'page'=>page )
40
+ def get_top_artists( params )
41
+ LastFM.get( "#{TYPE}.getTopArtists", params )
25
42
  end
26
43
 
44
+ # Fetches the top global tags on Last.fm, sorted by popularity (number of times used).
45
+ #
27
46
  # @see http://www.last.fm/api/show?service=276
28
47
  def get_top_tags
29
- LastFM.get( "#{TYPE}.getTopTags", !:secure )
48
+ LastFM.get( "#{TYPE}.getTopTags" )
30
49
  end
31
50
 
51
+ # Get the top tracks tagged with a tag, ordered by tag count.
52
+ #
53
+ # @option params [String, required] :tag the tag name
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=285
33
- def get_top_tracks( tag, limit = nil, page = nil )
34
- LastFM.get( "#{TYPE}.getTopTracks", !:secure, 'tag'=>tag, 'limit'=>limit, 'page'=>page )
57
+ def get_top_tracks( params )
58
+ LastFM.get( "#{TYPE}.getTopTracks", params )
35
59
  end
36
60
 
61
+ # Get an artist chart for a tag, for a given date range. If no date range is
62
+ # supplied, it will return the most recent artist chart for this tag.
63
+ #
64
+ # @option params [String, required] :tag the tag name
65
+ # @option params [String, optional] :from date at which the chart should start from (see: Tag.get_weekly_chart_list)
66
+ # @option params [String, optional] :to date at which the chart should end on (see: Tag.get_weekly_chart_list)
67
+ # @option params [Fixnum, optional] :limit the number of results to fetch. defaults to 50
37
68
  # @see http://www.last.fm/api/show?service=358
38
- def get_weekly_artist_chart( tag, time_from = nil, time_to = nil, limit = nil )
39
- LastFM.get( "#{TYPE}.getWeeklyArtistChart", !:secure, 'tag'=>tag, 'from'=>time_from, 'to'=>time_to, 'limit'=>limit )
69
+ def get_weekly_artist_chart( params )
70
+ LastFM.get( "#{TYPE}.getWeeklyArtistChart", params )
40
71
  end
41
72
 
73
+ # Get a list of available charts for this tag, expressed as date
74
+ # ranges which can be sent to the chart services.
75
+ #
76
+ # @option params [String, required] :tag the tag name
42
77
  # @see http://www.last.fm/api/show?service=359
43
- def get_weekly_chart_list( tag )
44
- LastFM.get( "#{TYPE}.getWeeklyChartList", !:secure, 'tag'=>tag )
78
+ def get_weekly_chart_list( params )
79
+ LastFM.get( "#{TYPE}.getWeeklyChartList", params )
45
80
  end
46
81
 
82
+ # Search for a tag by name. Returns matches sorted by relevance.
83
+ #
84
+ # @option params [String, required] :tag the tag name
85
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
86
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
47
87
  # @see http://www.last.fm/api/show?service=273
48
- def search( tag, limit = nil, page = nil )
49
- LastFM.get( "#{TYPE}.search", !:secure, 'tag'=>tag, 'limit'=>limit, 'page'=>page )
88
+ def search( params )
89
+ LastFM.get( "#{TYPE}.search", params )
50
90
  end
51
91
 
52
92
  end
@@ -4,10 +4,32 @@ module LastFM
4
4
 
5
5
  TYPE = 'tasteometer'
6
6
 
7
+ # Get a Tasteometer score from two inputs, along with a list of shared
8
+ # artists. If the input is a User some additional information is returned.
9
+ #
10
+ # @option params [Array, required] :types two types are required for comparison. accepted types are 'user' and 'artists'
11
+ # @option params [Array, required] :values values for the corresponding types. accepted values are Last.fm usernames, or arrays of artist names (up to 100 artists)
12
+ # @option params [Fixnum, optional] :limit how many shared artists to display. default is 5
7
13
  # @see http://www.last.fm/api/show?service=258
8
- def compare( type_1, type_2, value_1, value_2, limit = nil )
9
- raise ArgumentError unless [ 'user', 'artists', 'myspace' ].include?(type_1) && [ 'user', 'artists', 'myspace' ].include?(type_2)
10
- LastFM.get( "#{TYPE}.compare", !:secure, 'type1'=>type_1, 'type2'=>type_2, 'value1'=>value_1, 'value2'=>value_2 )
14
+ def compare( params )
15
+ Array(params.delete(:types)).each_with_index{|val, i| params["type[#{i}]"] = val}
16
+ Array(params.delete(:values)).each_with_index{|val, i| params["value[#{i}]"] = val}
17
+ LastFM.get( "#{TYPE}.compare", params )
18
+ end
19
+
20
+ # Get the scores between every user in a group of users, plus shared artists.
21
+ # Cuts off any similarities below a cutoff. Also returns a list of all users
22
+ # in the comparison and a small amount of metadata about each. Can take the
23
+ # list of users from a group, or a users friends.
24
+ #
25
+ # @option params [String, required] :source what source we're using for the comparison. accepted sources are 'user' and 'group'
26
+ # @option params [String, required] :value name of the source we're using. should be either a Last.fm username or group name
27
+ # @option params [Float, optional] :cutoff the minimum level over which comparisons should be returned. default is 0.2
28
+ # @option params [Fixnum, optional] :connection_limit the maximum number of connections each user should have. default is 6
29
+ # @see http://www.last.fm/api/show?service=500
30
+ # @deprecated This service has been deprecated and is no longer available
31
+ def compare_group(params)
32
+ LastFM.get( "#{TYPE}.compareGroup", params )
11
33
  end
12
34
 
13
35
  end