rscrobbler 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
- module LastFM
2
-
3
- # @attr [Symbol] type whether the link is for a physical purchase, or a download
4
- # @attr [Hash] supplier
5
- # @attr [Hash] price
6
- # @attr [String] link
7
- # @attr [Boolean] is_search
8
- class Buylink < Struct.new(:type, :supplier, :price, :link, :is_search)
9
-
10
- def update_from_node(node)
11
- case node.name.to_sym
12
- when :supplierName
13
- self.supplier ||= {}
14
- self.supplier[:name] = node.content
15
- when :supplierIcon
16
- self.supplier ||= {}
17
- self.supplier[:icon] = node.content
18
- when :price # nested price & currency
19
- node.find('*').each{|child| self.update_from_node(child)}
20
- when :amount
21
- self.price ||= {}
22
- self.price[:amount] = node.content.to_f
23
- when :currency
24
- self.price ||= {}
25
- self.price[:currency] = node.content
26
- when :buyLink
27
- self.link = node.content
28
- when :isSearch
29
- self.is_search = (node.content == '1')
30
- end
31
- end
32
-
33
- end
34
- end
1
+ module LastFM
2
+
3
+ # @attr [Symbol] type whether the link is for a physical purchase, or a download
4
+ # @attr [Hash] supplier
5
+ # @attr [Hash] price
6
+ # @attr [String] link
7
+ # @attr [Boolean] is_search
8
+ class Buylink < Struct.new(:type, :supplier, :price, :link, :is_search)
9
+
10
+ def update_from_node(node)
11
+ case node.name.to_sym
12
+ when :supplierName
13
+ self.supplier ||= {}
14
+ self.supplier[:name] = node.content
15
+ when :supplierIcon
16
+ self.supplier ||= {}
17
+ self.supplier[:icon] = node.content
18
+ when :price # nested price & currency
19
+ node.find('*').each{|child| self.update_from_node(child)}
20
+ when :amount
21
+ self.price ||= {}
22
+ self.price[:amount] = node.content.to_f
23
+ when :currency
24
+ self.price ||= {}
25
+ self.price[:currency] = node.content
26
+ when :buyLink
27
+ self.link = node.content
28
+ when :isSearch
29
+ self.is_search = (node.content == '1')
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,61 @@
1
+ module LastFM
2
+ class Chart
3
+ class << self
4
+
5
+ # Get the hyped artists chart
6
+ #
7
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
8
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
9
+ # @see http://www.last.fm/api/show?service=493
10
+ def get_hyped_artists( params )
11
+ LastFM.get( "chart.getHypedArtists", params )
12
+ end
13
+
14
+ # Get the hyped tracks chart
15
+ #
16
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
17
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
18
+ # @see http://www.last.fm/api/show?service=494
19
+ def get_hyped_tracks( params )
20
+ LastFM.get( "chart.getHypedTracks", params )
21
+ end
22
+
23
+ # Get the most loved tracks chart
24
+ #
25
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
26
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
27
+ # @see http://www.last.fm/api/show?service=495
28
+ def get_loved_tracks( params )
29
+ LastFM.get( "chart.getLovedTracks", params )
30
+ end
31
+
32
+ # Get the top artists chart
33
+ #
34
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
35
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
36
+ # @see http://www.last.fm/api/show?service=496
37
+ def get_top_artists( params )
38
+ LastFM.get( "chart.getTopArtists", params )
39
+ end
40
+
41
+ # Get the top tags chart
42
+ #
43
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
44
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
45
+ # @see http://www.last.fm/api/show?service=497
46
+ def get_top_tags( params )
47
+ LastFM.get( "chart.getTopTags", params )
48
+ end
49
+
50
+ # Get the top tracks chart
51
+ #
52
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
53
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
54
+ # @see http://www.last.fm/api/show?service=498
55
+ def get_top_tracks( params )
56
+ LastFM.get( "chart.getTopTracks", params )
57
+ end
58
+
59
+ end
60
+ end
61
+ end
data/lib/lastfm/event.rb CHANGED
@@ -1,62 +1,128 @@
1
- module LastFM
2
-
3
- # @attr [Fixnum] id
4
- # @attr [String] title
5
- # @attr [String] headliner
6
- # @attr [Array<String>] artists
7
- # @attr [LastFM::Venue] venue
8
- # @attr [Time] start_date
9
- # @attr [String] description
10
- # @attr [Hash] images
11
- # @attr [Fixnum] attendance
12
- # @attr [Fixnum] reviews
13
- # @attr [String] tag
14
- # @attr [String] url Last.fm url for the event
15
- # @attr [String] website Event website (different from Last.fm url)
16
- # @attr [Boolean] cancelled
17
- # @attr [Array<String>] tags
18
- class Event < Struct.new(:id, :title, :headliner, :artists, :venue, :start_date, :description, :images, :attendance, :reviews, :tag, :url, :website, :cancelled, :tags)
19
-
20
- def update_from_node(node)
21
- case node.name.to_sym
22
- when :id
23
- self.id = node.content.to_i
24
- when :title
25
- self.title = node.content
26
- when :artists # nested artists and headliner
27
- node.find('*').each{|child| self.update_from_node(child)}
28
- when :artist
29
- self.artists ||= []
30
- self.artists << node.content
31
- when :headliner
32
- self.headliner = node.content
33
- when :venue
34
- self.venue = LastFM::Venue.from_xml( node )
35
- when :startDate
36
- self.start_date = Time.parse(node.content) rescue nil
37
- when :description
38
- self.description = node.content
39
- when :image
40
- self.images ||= {}
41
- self.images.merge!({node['size'].to_sym => node.content})
42
- when :attendance
43
- self.attendance = node.content.to_i
44
- when :reviews
45
- self.reviews = node.content.to_i
46
- when :tag
47
- self.tag = node.content
48
- when :url
49
- self.url = node.content
50
- when :website
51
- self.website = node.content
52
- when :tickets
53
- # ???
54
- when :cancelled
55
- self.cancelled = (node.content == '1')
56
- when :tags
57
- self.tags = node.find('*').each{|tag| tag.content}
58
- end
59
- end
60
-
61
- end
62
- end
1
+ module LastFM
2
+
3
+ # @attr [Fixnum] id
4
+ # @attr [String] title
5
+ # @attr [String] headliner
6
+ # @attr [Array<String>] artists
7
+ # @attr [LastFM::Venue] venue
8
+ # @attr [Time] start_date
9
+ # @attr [String] description
10
+ # @attr [Hash] images
11
+ # @attr [Fixnum] attendance
12
+ # @attr [Fixnum] reviews
13
+ # @attr [String] tag
14
+ # @attr [String] url Last.fm url for the event
15
+ # @attr [String] website Event website (different from Last.fm url)
16
+ # @attr [Boolean] cancelled
17
+ # @attr [Array<String>] tags
18
+ class Event < Struct.new(:id, :title, :headliner, :artists, :venue, :start_date, :description, :images, :attendance, :reviews, :tag, :url, :website, :cancelled, :tags)
19
+
20
+ def update_from_node(node)
21
+ case node.name.to_sym
22
+ when :id
23
+ self.id = node.content.to_i
24
+ when :title
25
+ self.title = node.content
26
+ when :artists # nested artists and headliner
27
+ node.find('*').each{|child| self.update_from_node(child)}
28
+ when :artist
29
+ self.artists ||= []
30
+ self.artists << node.content
31
+ when :headliner
32
+ self.headliner = node.content
33
+ when :venue
34
+ self.venue = LastFM::Venue.from_xml( node )
35
+ when :startDate
36
+ self.start_date = Time.parse(node.content) rescue nil
37
+ when :description
38
+ self.description = node.content
39
+ when :image
40
+ self.images ||= {}
41
+ self.images.merge!({node['size'].to_sym => node.content})
42
+ when :attendance
43
+ self.attendance = node.content.to_i
44
+ when :reviews
45
+ self.reviews = node.content.to_i
46
+ when :tag
47
+ self.tag = node.content
48
+ when :url
49
+ self.url = node.content
50
+ when :website
51
+ self.website = node.content
52
+ when :tickets
53
+ # ???
54
+ when :cancelled
55
+ self.cancelled = (node.content == '1')
56
+ when :tags
57
+ self.tags = node.find('*').each{|tag| tag.content}
58
+ end
59
+ end
60
+
61
+ # API Methods
62
+ class << self
63
+
64
+ # Set a user's attendance status for an event.
65
+ #
66
+ # @option params [Fixnum, required] :event numeric last.fm event id
67
+ # @option params [Symbol, required] :status attendance status. accepted values are :attending, :maybe_attending, and :not_attending
68
+ # @see http://www.last.fm/api/show?service=307
69
+ def attend( params )
70
+ LastFM.requires_authentication
71
+ status_codes = { attending: 0, maybe_attending: 1, not_attending: 2 }
72
+ params[:status] = status_codes[params[:status]] if params.include?(:status)
73
+ LastFM.post( "event.attend", params )
74
+ end
75
+
76
+ # Get a list of attendees for an event.
77
+ #
78
+ # @option params [Fixnum, required] :event numeric last.fm event id
79
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
80
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
81
+ # @see http://www.last.fm/api/show?service=391
82
+ def get_attendees( params )
83
+ LastFM.get( "event.getAttendees", params )
84
+ end
85
+
86
+ # Get the metadata for an event on Last.fm. Includes attendance and lineup information.
87
+ #
88
+ # @option params [Fixnum, required] :event numeric last.fm event id
89
+ # @see http://www.last.fm/api/show?service=292
90
+ def get_info( params )
91
+ LastFM.get( "event.getInfo", params )
92
+ end
93
+
94
+ # Get shouts for an event.
95
+ #
96
+ # @option params [Fixnum, required] :event numeric last.fm event id
97
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
98
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
99
+ # @see http://www.last.fm/api/show?service=399
100
+ def get_shouts( params )
101
+ LastFM.get( "event.getShouts", params )
102
+ end
103
+
104
+ # Share an event with one or more Last.fm users or other friends.
105
+ #
106
+ # @option params [Fixnum, required] :event numeric last.fm event id
107
+ # @option params [Array, required] :recipient a list of email addresses or Last.fm usernames. maximum is 10
108
+ # @option params [String, optional] :message an optional message to send. if not supplied a default message will be used
109
+ # @option params [Boolean, optional] :public optionally show in the sharing users activity feed. defaults to false
110
+ # @see http://www.last.fm/api/show?service=350
111
+ def share( params )
112
+ LastFM.requires_authentication
113
+ LastFM.post( "event.share", params )
114
+ end
115
+
116
+ # Shout in an event's shoutbox.
117
+ #
118
+ # @option params [Fixnum, required] :event numeric last.fm event id
119
+ # @option params [String, required] :message message to post to the shoutbox
120
+ # @see http://www.last.fm/api/show?service=409
121
+ def shout( params )
122
+ LastFM.requires_authentication
123
+ LastFM.post( "event.shout", params )
124
+ end
125
+
126
+ end
127
+ end
128
+ end
data/lib/lastfm/geo.rb ADDED
@@ -0,0 +1,123 @@
1
+ module LastFM
2
+ class Geo
3
+ class << self
4
+
5
+ # Get all events in a specific location by country or city name.
6
+ #
7
+ # @option params [String, optional] :location location to retrieve events for
8
+ # @option params [String, optional] :lat latitude value to retrieve events for
9
+ # @option params [String, optional] :long longitude value to retrieve events for
10
+ # @option params [Fixnum, optional] :distance find events within a specified radius (in kilometres)
11
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
12
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
13
+ # @see http://www.last.fm/api/show?service=270
14
+ def get_events( params )
15
+ LastFM.get( "geo.getEvents", !:secure, params )
16
+ end
17
+
18
+ # Get a chart of artists for a metro.
19
+ #
20
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
21
+ # @option params [String, required] :metro the metro's name
22
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
23
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
24
+ # @see http://www.last.fm/api/show?service=421
25
+ def get_metro_artist_chart( params )
26
+ LastFM.get( "geo.getMetroArtistChart", params )
27
+ end
28
+
29
+ # Get a chart of hyped (up and coming) artists for a metro.
30
+ #
31
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
32
+ # @option params [String, required] :metro the metro's name
33
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
34
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
35
+ # @see http://www.last.fm/api/show?service=420
36
+ def get_metro_hype_artist_chart( params )
37
+ LastFM.get( "geo.getMetroHypeArtistChart", params )
38
+ end
39
+
40
+ # Get a chart of hyped (up and coming) tracks for a metro.
41
+ #
42
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
43
+ # @option params [String, required] :metro the metro's name
44
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
45
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
46
+ # @see http://www.last.fm/api/show?service=422
47
+ def get_metro_hype_track_chart( params )
48
+ LastFM.get( "geo.getMetroHypeTrackChart", params )
49
+ end
50
+
51
+ # Get a chart of tracks for a metro.
52
+ #
53
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
54
+ # @option params [String, required] :metro the metro's name
55
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
56
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
57
+ # @see http://www.last.fm/api/show?service=423
58
+ def get_metro_track_chart( params )
59
+ LastFM.get( "geo.getMetroTrackChart", params )
60
+ end
61
+
62
+ # Get a chart of the artists which make that metro unique
63
+ #
64
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
65
+ # @option params [String, required] :metro the metro's name
66
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
67
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
68
+ # @see http://www.last.fm/api/show?service=424
69
+ def get_metro_unique_artist_chart( params )
70
+ LastFM.get( "geo.getMetroUniqueArtistChart", params )
71
+ end
72
+
73
+ # Get a chart of the tracks which make that metro unique
74
+ #
75
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
76
+ # @option params [String, required] :metro the metro's name
77
+ # @option params [Time, optional] :start beginning timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
78
+ # @option params [Time, optional] :end ending timestamp of the weekly range requested (see: Geo.get_weekly_chart_list)
79
+ # @see http://www.last.fm/api/show?service=425
80
+ def get_metro_unique_track_chart( params )
81
+ LastFM.get( "geo.getMetroUniqueTrackChart", params )
82
+ end
83
+
84
+ # Get a list of available chart periods for this metro, expressed as date ranges which can be sent to the chart services.
85
+ #
86
+ # @option params [String, required] :metro metro name to fetch the charts list for
87
+ # @see http://www.last.fm/api/show?service=426
88
+ def get_metro_weekly_chartlist( params )
89
+ LastFM.get( "geo.getMetroWeeklyChartlist", params )
90
+ end
91
+
92
+ # Get a list of valid countries and metros for use in the other webservices
93
+ #
94
+ # @option params [String, optional] :country restrict results to metros from a particular country, as defined by ISO 3166-1
95
+ # @see http://www.last.fm/api/show?service=435
96
+ def get_metros( params )
97
+ LastFM.get( "geo.getMetros", params )
98
+ end
99
+
100
+ # Get the most popular artists on Last.fm by country
101
+ #
102
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
103
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
104
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
105
+ # @see http://www.last.fm/api/show?service=297
106
+ def get_top_artists( params )
107
+ LastFM.get( "geo.getTopArtists", params )
108
+ end
109
+
110
+ # Get the most popular tracks on Last.fm by country
111
+ #
112
+ # @option params [String, required] :country a country name, as defined by ISO 3166-1
113
+ # @option params [String, optional] :location location to fetch the charts for
114
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
115
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
116
+ # @see http://www.last.fm/api/show?service=298
117
+ def get_top_tracks( params )
118
+ LastFM.get( "geo.getTopTracks", params )
119
+ end
120
+
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,67 @@
1
+ module LastFM
2
+ class Group
3
+ class << self
4
+
5
+ # Get the hype list for a group.
6
+ #
7
+ # @option params [String, required] :group the last.fm group name
8
+ # @see http://www.last.fm/api/show?service=259
9
+ def get_hype( params )
10
+ LastFM.get( "group.getHype", params )
11
+ end
12
+
13
+ # Get the list of members for a group.
14
+ #
15
+ # @option params [String, required] :group the last.fm group name
16
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
17
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
18
+ # @see http://www.last.fm/api/show/?service=379
19
+ def get_members( params )
20
+ LastFM.get( "group.getMembers", params )
21
+ end
22
+
23
+ # Get an album chart for a group, for a given date range. If no date range
24
+ # is supplied, return the most recent.
25
+ #
26
+ # @option params [String, required] :group the last.fm group name
27
+ # @option params [Time, optional] :from date at which the chart should start from (see: Group.get_weekly_chart_list)
28
+ # @option params [Time, optional] :to date at which the chart should end on (see: Group.get_weekly_chart_list)
29
+ # @see http://www.last.fm/api/show/?service=293
30
+ def get_weekly_album_chart( params )
31
+ LastFM.get( "group.getWeeklyAlbumChart", params )
32
+ end
33
+
34
+ # Get an artist chart for a group, for a given date range. If no date range
35
+ # is supplied, return the most recent.
36
+ #
37
+ # @option params [String, required] :group the last.fm group name
38
+ # @option params [Time, optional] :from date at which the chart should start from (see: Group.get_weekly_chart_list)
39
+ # @option params [Time, optional] :to date at which the chart should end on (see: Group.get_weekly_chart_list)
40
+ # @see http://www.last.fm/api/show/?service=294
41
+ def get_weekly_artist_chart( params )
42
+ LastFM.get( "group.getWeeklyArtistChart", params )
43
+ end
44
+
45
+ # Get the list of available charts for a group, expressed as date ranges
46
+ # which can be sent to the chart services.
47
+ #
48
+ # @option params [String, required] :group the last.fm group name
49
+ # @see http://www.last.fm/api/show/?service=295
50
+ def get_weekly_chart_list( params )
51
+ LastFM.get( "group.getWeeklyChartList", params )
52
+ end
53
+
54
+ # Get a track chart for a group, for a given date range. If no date range
55
+ # is supplied, return the most recent.
56
+ #
57
+ # @option params [String, required] :group the last.fm group name
58
+ # @option params [Time, optional] :from date at which the chart should start from (see: Group.get_weekly_chart_list)
59
+ # @option params [Time, optional] :to date at which the chart should end on (see: Group.get_weekly_chart_list)
60
+ # @see http://www.last.fm/api/show/?service=296
61
+ def get_weekly_track_chart( params )
62
+ LastFM.get( "group.getWeeklyTrackChart", params )
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,115 @@
1
+ module LastFM
2
+ class Library
3
+ class << self
4
+
5
+ # Add an album or collection of albums to a user's Last.fm library.
6
+ #
7
+ # @option params [Array, required] :artists the artist or collection of artists to add
8
+ # @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
9
+ # @see http://www.last.fm/api/show?service=370
10
+ def add_album( params )
11
+ LastFM.requires_authentication
12
+ # convert :artists and :albums to individual artist[i] and album[i]
13
+ Array(params.delete(:artists)).each_with_index{|val, i| params["artist[#{i}]"] = val}
14
+ Array(params.delete(:albums)).each_with_index{|val, i| params["album[#{i}]"] = val}
15
+ LastFM.post( "library.addAlbum", params )
16
+ end
17
+
18
+ # Add an artist or collection of artists to a user's Last.fm library.
19
+ #
20
+ # @option params [Array, required] :artists the artist or collection of artists to add
21
+ # @see http://www.last.fm/api/show?service=371
22
+ def add_artist( params )
23
+ LastFM.requires_authentication
24
+ Array(params.delete(:artists)).each_with_index{|val, i| params["artist[#{i}]"] = val}
25
+ LastFM.post( "library.addArtist", params )
26
+ end
27
+
28
+ # Add a track or collection of tracks to a user's Last.fm library.
29
+ #
30
+ # @option params [Array, required] :artists the artist or collection of artists to add
31
+ # @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
32
+ # @see http://www.last.fm/api/show?service=372
33
+ def add_track( params )
34
+ LastFM.requires_authentication
35
+ Array(params.delete(:artists)).each_with_index{|val, i| params["artist[#{i}]"] = val}
36
+ Array(params.delete(:tracks)).each_with_index{|val, i| params["track[#{i}]"] = val}
37
+ LastFM.post( "library.addTrack", params )
38
+ end
39
+
40
+ # A paginated list of all the albums in a user's library, with play counts and tag counts.
41
+ #
42
+ # @option params [String, requried] :user the user whose library you want to fetch
43
+ # @option params [String, optional] :artist an artist by which to filter albums
44
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
45
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
46
+ # @see http://www.last.fm/api/show?service=321
47
+ def get_albums( params )
48
+ LastFM.get( "library.getAlbums", params )
49
+ end
50
+
51
+ # A paginated list of all the artists in a user's library, with play counts and tag counts.
52
+ #
53
+ # @option params [String, requried] :user the user whose library you want to fetch
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
56
+ # @see http://www.last.fm/api/show?service=322
57
+ def get_artists( params )
58
+ LastFM.get( "library.getArtists", params )
59
+ end
60
+
61
+ # A paginated list of all the tracks in a user's library, with play counts and tag counts.
62
+ #
63
+ # @option params [String, requried] :user the user whose library you want to fetch
64
+ # @option params [String, optional] :artist an artist by which to filter track
65
+ # @option params [String, optional] :album an album by which to filter tracks (requires an associated artist)
66
+ # @option params [Fixnum, optional] :page the page number to fetch. defaults to first page
67
+ # @option params [Fixnum, optional] :limit the number of results to fetch per page. defaults to 50
68
+ # @see http://www.last.fm/api/show?service=323
69
+ def get_tracks( params )
70
+ LastFM.get( "library.getTracks", params )
71
+ end
72
+
73
+ # Remove an album from a user's Last.fm library.
74
+ #
75
+ # @option params [String, required] :artist the artist that composed the album
76
+ # @option params [String, required] :album the name of the album to remove
77
+ # @see http://www.last.fm/api/show?service=523
78
+ def remove_album( params )
79
+ LastFM.requires_authentication
80
+ LastFM.post( "library.removeAlbum", params )
81
+ end
82
+
83
+ # Remove an artist from a user's Last.fm library.
84
+ #
85
+ # @option params [String, required] :artist the name of the artist to remove
86
+ # @see http://www.last.fm/api/show?service=524
87
+ def remove_artist( params )
88
+ LastFM.requires_authentication
89
+ LastFM.post( "library.removeArtist", params )
90
+ end
91
+
92
+ # Remove a scrobble from a user's Last.fm library.
93
+ #
94
+ # @option params [String, required] :artist the artist that composed the album
95
+ # @option params [String, required] :track the name of the track to remove
96
+ # @option params [Time, required] :timestamp the unix timestamp of the scrobble to remove
97
+ # @see http://www.last.fm/api/show?service=525
98
+ def remove_scrobble( params )
99
+ LastFM.requires_authentication
100
+ LastFM.post( "library.removeScrobble", params )
101
+ end
102
+
103
+ # Remove a track from a user's Last.fm library.
104
+ #
105
+ # @option params [String, required] :artist the artist that composed the track
106
+ # @option params [String, required] :track the name of the track to remove
107
+ # @see http://www.last.fm/api/show?service=526
108
+ def remove_track( params )
109
+ LastFM.requires_authentication
110
+ LastFM.post( "library.removeTrack", params )
111
+ end
112
+
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,38 @@
1
+ module LastFM
2
+ class Playlist
3
+ class << self
4
+
5
+ # Add a track to a Last.fm user's playlist
6
+ #
7
+ # @option params [String, required] :playlist_id the id of the playlist (see: User.get_playlists)
8
+ # @option params [String, required] :track the track name to add to the playlist
9
+ # @option params [String, required] :artist the artist that corresponds to the track to be added
10
+ # @see http://www.last.fm/api/show?service=337
11
+ def add_track( params )
12
+ LastFM.requires_authentication
13
+ LastFM.post( "playlist.addTrack", params )
14
+ end
15
+
16
+ # Create a Last.fm playlist on behalf of a user.
17
+ #
18
+ # @option params [String, optional] :title title for the playlist
19
+ # @option params [String, optional] :description description for the playlist
20
+ # @see http://www.last.fm/api/show?service=365
21
+ def create( params )
22
+ LastFM.requires_authentication
23
+ LastFM.post( "playlist.create", params )
24
+ end
25
+
26
+ # Fetch XSPF playlists using a lastfm playlist url.
27
+ #
28
+ # @option params [String, required] :playlist_url lastfm protocol playlist url (lastfm://playlist/...)
29
+ # @option params [Boolean, optional] :steaming whether to return mp3 links for song previews
30
+ # @see http://www.last.fm/api/show?service=271
31
+ # @deprecated documentation removed from last.fm/api, but method calls still work
32
+ def fetch( params )
33
+ LastFM.get( "playlist.fetch", params )
34
+ end
35
+
36
+ end
37
+ end
38
+ end