lastfm 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -34,6 +34,8 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
34
34
  * {artist.getInfo}[http://www.last.fm/api/show?service=267]
35
35
  * {artist.getSimilar}[http://www.last.fm/api/show?service=267]
36
36
  * {artist.getTags}[http://www.last.fm/api/show?service=267]
37
+ * {artist.getTopAlbums}[http://www.last.fm/api/show/artist.getTopAlbums]
38
+ * {artist.getTopTracks}[http://www.last.fm/api/show/artist.getTopTracks]
37
39
  * {artist.search}[http://www.lastfm.jp/api/show/artist.search]
38
40
 
39
41
  === Auth
@@ -80,6 +82,10 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
80
82
  * {user.getTopAlbums}[http://www.lastfm.jp/api/show/user.getTopAlbums]
81
83
  * {user.getTopTags}[http://www.lastfm.jp/api/show/user.getTopTags]
82
84
  * {user.getTopTracks}[http://www.lastfm.jp/api/show/user.getTopTracks]
85
+ * {user.getWeeklyAlbumList}[http://www.last.fm/api/show/user.getWeeklyAlbumChart]
86
+ * {user.getWeeklyArtistList}[http://www.last.fm/api/show/user.getWeeklyArtistChart]
87
+ * {user.getWeeklyChartList}[http://www.last.fm/api/show/group.getWeeklyChartList]
88
+ * {user.getWeeklyTrackList}[http://www.last.fm/api/show/user.getWeeklyTrackChart]
83
89
 
84
90
  === Geo
85
91
 
data/lastfm.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
13
  gem.name = %q{lastfm}
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "1.8.0"
15
+ gem.version = "1.9.0"
16
16
 
17
17
  gem.add_dependency "xml-simple"
18
18
  gem.add_dependency "httparty"
@@ -8,7 +8,7 @@ class Lastfm
8
8
  regular_method :get_top_albums, [:artist], [] do |response|
9
9
  response.xml['topalbums']['album']
10
10
  end
11
-
11
+
12
12
  regular_method :get_info, [:artist], [] do |response|
13
13
  response.xml['artist']
14
14
  end
@@ -20,7 +20,7 @@ class Lastfm
20
20
  regular_method :get_similar, [:artist], [] do |response|
21
21
  response.xml['similarartists']['artist']
22
22
  end
23
-
23
+
24
24
  regular_method :get_tags, [:artist], [[:user, nil], [:mbid, nil], [:autocorrect, nil]] do |response|
25
25
  response.xml['tags']['tag']
26
26
  end
@@ -52,6 +52,22 @@ class Lastfm
52
52
  regular_method :get_top_tracks, [:user], [[:period, nil], [:limit, nil], [:page, nil]] do |response|
53
53
  response.xml['toptracks']['track']
54
54
  end
55
+
56
+ regular_method :get_weekly_chart_list, [:user], [[:limit, nil]] do |response|
57
+ response.xml['weeklychartlist']['chart']
58
+ end
59
+
60
+ regular_method :get_weekly_artist_chart, [:user], [[:from, nil], [:to, nil], [:limit, nil]] do |response|
61
+ response.xml['weeklyartistchart']['artist']
62
+ end
63
+
64
+ regular_method :get_weekly_album_chart, [:user], [[:from, nil], [:to, nil], [:limit, nil]] do |response|
65
+ response.xml['weeklyalbumchart']['album']
66
+ end
67
+
68
+ regular_method :get_weekly_track_chart, [:user], [[:from, nil], [:to, nil], [:limit, nil]] do |response|
69
+ response.xml['weeklytrackchart']['track']
70
+ end
55
71
  end
56
72
  end
57
73
  end
@@ -0,0 +1,25 @@
1
+ <lfm status="ok">
2
+ <weeklyalbumchart user="RJ" from="1348401600" to="1349006400">
3
+ <album rank="1">
4
+ <artist mbid="65314b12-0e08-43fa-ba33-baaa7b874c15">Leonard Cohen</artist>
5
+ <name>Live In London</name>
6
+ <mbid>04297356-de27-4988-9871-af2d75a98740</mbid>
7
+ <playcount>25</playcount>
8
+ <url>http://www.last.fm/music/Leonard+Cohen/Live+In+London</url>
9
+ </album>
10
+ <album rank="2">
11
+ <artist mbid="e49f69da-17d5-4c5c-bac0-dadcb0e588f5">Mark Knopfler</artist>
12
+ <name>Privateering</name>
13
+ <mbid>767c253e-1454-46b3-b568-7142038c72e4</mbid>
14
+ <playcount>18</playcount>
15
+ <url>http://www.last.fm/music/Mark+Knopfler/Privateering</url>
16
+ </album>
17
+ <album rank="3">
18
+ <artist mbid="122d63fc-8671-43e4-9752-34e846d62a9c">Katy Perry</artist>
19
+ <name>Katy Perry - Teenage Dream: The Complete Confection</name>
20
+ <mbid/>
21
+ <playcount>18</playcount>
22
+ <url>http://www.last.fm/music/Katy+Perry/Katy+Perry+-+Teenage+Dream:+The+Complete+Confection</url>
23
+ </album>
24
+ </weeklyalbumchart>
25
+ </lfm>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <weeklyartistchart user="RJ" from="1348401600" to="1349006400">
4
+ <artist rank="1">
5
+ <name>Leonard Cohen</name>
6
+ <mbid>65314b12-0e08-43fa-ba33-baaa7b874c15</mbid>
7
+ <playcount>46</playcount>
8
+ <url>http://www.last.fm/music/Leonard+Cohen</url>
9
+ </artist>
10
+ <artist rank="2">
11
+ <name>Mark Knopfler</name>
12
+ <mbid>e49f69da-17d5-4c5c-bac0-dadcb0e588f5</mbid>
13
+ <playcount>44</playcount>
14
+ <url>http://www.last.fm/music/Mark+Knopfler</url>
15
+ </artist>
16
+ <artist rank="3">
17
+ <name>Katy Perry</name>
18
+ <mbid>122d63fc-8671-43e4-9752-34e846d62a9c</mbid>
19
+ <playcount>30</playcount>
20
+ <url>http://www.last.fm/music/Katy+Perry</url>
21
+ </artist>
22
+ <artist rank="4">
23
+ <name>Chris Rea</name>
24
+ <mbid>c707b37e-cb5c-4694-be4d-46beefcb2475</mbid>
25
+ <playcount>16</playcount>
26
+ <url>http://www.last.fm/music/Chris+Rea</url>
27
+ </artist>
28
+ </weeklyartistchart>
29
+ </lfm>
@@ -0,0 +1,12 @@
1
+ <lfm status="ok">
2
+ <weeklychartlist user="RJ">
3
+ <chart from="1108296002" to="1108900802"/>
4
+ <chart from="1108900801" to="1109505601"/>
5
+ <chart from="1109505601" to="1110110401"/>
6
+ <chart from="1110110401" to="1110715201"/>
7
+ <chart from="1110715201" to="1111320001"/>
8
+ <chart from="1111320001" to="1111924801"/>
9
+ <chart from="1111924801" to="1112529601"/>
10
+ <chart from="1112529601" to="1113134401"/>
11
+ </weeklychartlist>
12
+ </lfm>
@@ -0,0 +1,34 @@
1
+ <lfm status="ok">
2
+ <weeklytrackchart user="RJ" from="1348401600" to="1349006400">
3
+ <track rank="1">
4
+ <artist mbid="c0b2500e-0cef-4130-869d-732b23ed9df5">Tori Amos</artist>
5
+ <name>Crucify</name>
6
+ <mbid>00d460e6-bd75-499b-900e-51f889668480</mbid>
7
+ <playcount>2</playcount>
8
+ <image size="small">http://userserve-ak.last.fm/serve/34/45001803.png</image>
9
+ <image size="medium">http://userserve-ak.last.fm/serve/64/45001803.png</image>
10
+ <image size="large">http://userserve-ak.last.fm/serve/126/45001803.png</image>
11
+ <url>www.last.fm/music/Tori+Amos/_/Crucify</url>
12
+ </track>
13
+ <track rank="2">
14
+ <artist mbid="614e3804-7d34-41ba-857f-811bad7c2b7a">Dire Straits</artist>
15
+ <name>Money for Nothing</name>
16
+ <mbid>0430ad05-7580-4703-9649-e6f870457805</mbid>
17
+ <playcount>2</playcount>
18
+ <image size="small">http://userserve-ak.last.fm/serve/34/135149.jpg</image>
19
+ <image size="medium">http://userserve-ak.last.fm/serve/64/135149.jpg</image>
20
+ <image size="large">http://userserve-ak.last.fm/serve/126/135149.jpg</image>
21
+ <url>www.last.fm/music/Dire+Straits/_/Money+for+Nothing</url>
22
+ </track>
23
+ <track rank="3">
24
+ <artist mbid="614e3804-7d34-41ba-857f-811bad7c2b7a">Dire Straits</artist>
25
+ <name>So Far Away - Full Version</name>
26
+ <mbid/>
27
+ <playcount>2</playcount>
28
+ <image size="small">http://userserve-ak.last.fm/serve/34/135149.jpg</image>
29
+ <image size="medium">http://userserve-ak.last.fm/serve/64/135149.jpg</image>
30
+ <image size="large">http://userserve-ak.last.fm/serve/126/135149.jpg</image>
31
+ <url>www.last.fm/music/Dire+Straits/_/So+Far+Away+-+Full+Version</url>
32
+ </track>
33
+ </weeklytrackchart>
34
+ </lfm>
@@ -225,4 +225,66 @@ describe '#user' do
225
225
  tags.size.should == 5
226
226
  end
227
227
  end
228
+
229
+ describe '#get_weekly_chart_list' do
230
+ it 'should get user\'s weekly chart list' do
231
+ @lastfm.should_receive(:request).with('user.getWeeklyChartList', {
232
+ :user => 'test',
233
+ :limit => nil,
234
+ }).and_return(make_response('user_get_weekly_chart_list'))
235
+ weekly_charts = @lastfm.user.get_weekly_chart_list(:user => 'test')
236
+ weekly_charts[0]['from'].should == "1108296002"
237
+ weekly_charts[0]['to'].should == "1108900802"
238
+ weekly_charts[1]['from'].should == "1108900801"
239
+ weekly_charts.size.should == 8
240
+ end
241
+ end
242
+
243
+ describe '#get_weekly_artist_chart' do
244
+ it 'should get user\'s weekly artist chart' do
245
+ @lastfm.should_receive(:request).with('user.getWeeklyArtistChart', {
246
+ :user => 'test',
247
+ :limit => nil,
248
+ :to => nil,
249
+ :from => nil
250
+ }).and_return(make_response('user_get_weekly_artist_chart'))
251
+ weekly_artists = @lastfm.user.get_weekly_artist_chart(:user => 'test')
252
+ weekly_artists[0]['name'].should == "Leonard Cohen"
253
+ weekly_artists[0]['playcount'].should == "46"
254
+ weekly_artists[1]['playcount'].should == "44"
255
+ weekly_artists.size.should == 4
256
+ end
257
+ end
258
+
259
+ describe '#get_weekly_album_chart' do
260
+ it 'should get user\'s weekly album chart' do
261
+ @lastfm.should_receive(:request).with('user.getWeeklyAlbumChart', {
262
+ :user => 'test',
263
+ :limit => nil,
264
+ :to => nil,
265
+ :from => nil
266
+ }).and_return(make_response('user_get_weekly_album_chart'))
267
+ weekly_albums = @lastfm.user.get_weekly_album_chart(:user => 'test')
268
+ weekly_albums[0]['artist']['content'].should == "Leonard Cohen"
269
+ weekly_albums[0]['playcount'].should == "25"
270
+ weekly_albums[1]['playcount'].should == "18"
271
+ weekly_albums.size.should == 3
272
+ end
273
+ end
274
+
275
+ describe '#get_weekly_track_chart' do
276
+ it 'should get user\'s weekly track chart' do
277
+ @lastfm.should_receive(:request).with('user.getWeeklyTrackChart', {
278
+ :user => 'test',
279
+ :limit => nil,
280
+ :to => nil,
281
+ :from => nil
282
+ }).and_return(make_response('user_get_weekly_track_chart'))
283
+ weekly_tracks = @lastfm.user.get_weekly_track_chart(:user => 'test')
284
+ weekly_tracks[0]['artist']['content'].should == "Tori Amos"
285
+ weekly_tracks[0]['playcount'].should == "2"
286
+ weekly_tracks[1]['playcount'].should == "2"
287
+ weekly_tracks.size.should == 3
288
+ end
289
+ end
228
290
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lastfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-21 00:00:00.000000000 Z
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
@@ -155,6 +155,10 @@ files:
155
155
  - spec/fixtures/user_get_top_artists.xml
156
156
  - spec/fixtures/user_get_top_tags.xml
157
157
  - spec/fixtures/user_get_top_tracks.xml
158
+ - spec/fixtures/user_get_weekly_album_chart.xml
159
+ - spec/fixtures/user_get_weekly_artist_chart.xml
160
+ - spec/fixtures/user_get_weekly_chart_list.xml
161
+ - spec/fixtures/user_get_weekly_track_chart.xml
158
162
  - spec/lastfm_spec.rb
159
163
  - spec/method_category_spec.rb
160
164
  - spec/method_specs/album_spec.rb
@@ -182,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
186
  version: '0'
183
187
  segments:
184
188
  - 0
185
- hash: 2969465922410798528
189
+ hash: -2782955245738475169
186
190
  required_rubygems_version: !ruby/object:Gem::Requirement
187
191
  none: false
188
192
  requirements:
@@ -191,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
195
  version: '0'
192
196
  segments:
193
197
  - 0
194
- hash: 2969465922410798528
198
+ hash: -2782955245738475169
195
199
  requirements: []
196
200
  rubyforge_project:
197
201
  rubygems_version: 1.8.24
@@ -235,6 +239,10 @@ test_files:
235
239
  - spec/fixtures/user_get_top_artists.xml
236
240
  - spec/fixtures/user_get_top_tags.xml
237
241
  - spec/fixtures/user_get_top_tracks.xml
242
+ - spec/fixtures/user_get_weekly_album_chart.xml
243
+ - spec/fixtures/user_get_weekly_artist_chart.xml
244
+ - spec/fixtures/user_get_weekly_chart_list.xml
245
+ - spec/fixtures/user_get_weekly_track_chart.xml
238
246
  - spec/lastfm_spec.rb
239
247
  - spec/method_category_spec.rb
240
248
  - spec/method_specs/album_spec.rb