rscrobbler 0.1.0 → 0.2.0

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