lastfm 0.1.0 → 0.2.0

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,8 @@ A Ruby interface for Last.fm Web Services v2.0
14
14
  lastfm.session = lastfm.auth.get_session(token)
15
15
 
16
16
  lastfm.track.love('Hujiko Pro', 'acid acid 7riddim')
17
+ lastfm.track.scrobble('Hujiko Pro', 'acid acid 7riddim')
18
+ lastfm.track.update_now_playing('Hujiko Pro', 'acid acid 7riddim')
17
19
 
18
20
  == Supported API Methods
19
21
 
@@ -35,8 +37,10 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
35
37
  * track.getTopTags
36
38
  * track.love
37
39
  * track.removeTag
40
+ * track.scrobble
38
41
  * track.search
39
42
  * track.share
43
+ * track.updateNowPlaying
40
44
 
41
45
  === Artist
42
46
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lastfm}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["youpy"]
12
- s.date = %q{2010-11-18}
12
+ s.date = %q{2010-12-06}
13
13
  s.description = %q{A ruby interface for Last.fm web services version 2.0}
14
14
  s.email = %q{youpy@buycheapviagraonlinenow.com}
15
15
  s.extra_rdoc_files = [
@@ -38,6 +38,10 @@ class Lastfm
38
38
  MethodCategory::Artist.new(self)
39
39
  end
40
40
 
41
+ def user
42
+ MethodCategory::User.new(self)
43
+ end
44
+
41
45
  def request(method, params = {}, http_method = :get, with_signature = false, with_session = false)
42
46
  params[:method] = method
43
47
  params[:api_key] = @api_key
@@ -6,6 +6,8 @@ class Lastfm
6
6
  write_method :ban, [:artist, :track]
7
7
  write_method :love, [:artist, :track]
8
8
  write_method :share, [:artist, :track, :recipient], [[:message, nil]]
9
+ write_method :scrobble, [:artist, :track], [[:album, nil], [:timestamp, Time.now.utc.to_i]]
10
+ write_method :update_now_playing, [:artist, :track]
9
11
 
10
12
  regular_method :get_info, [:artist, :track], [[:username, nil]] do |response|
11
13
  response.xml['track']
@@ -25,11 +25,11 @@
25
25
  <website></website>
26
26
  <phonenumber></phonenumber>
27
27
  <image size="small"></image>
28
- <image size="medium"></image>
29
- <image size="large"></image>
30
- <image size="extralarge"></image>
31
- <image size="mega"></image>
32
- </venue>
28
+ <image size="medium"></image>
29
+ <image size="large"></image>
30
+ <image size="extralarge"></image>
31
+ <image size="mega"></image>
32
+ </venue>
33
33
  <startDate>Sat, 23 Oct 2010 19:30:00</startDate>
34
34
  <description></description>
35
35
  <image size="small">http://userserve-ak.last.fm/serve/34/34814037.jpg</image>
@@ -38,7 +38,7 @@
38
38
  <image size="extralarge">http://userserve-ak.last.fm/serve/252/34814037.jpg</image>
39
39
  <attendance>2</attendance>
40
40
  <reviews>0</reviews>
41
- <tag>lastfm:event=1584537</tag>
41
+ <tag>lastfm:event=1584537</tag>
42
42
  <url>http://www.last.fm/event/1584537+Cher</url>
43
43
  <website></website>
44
44
  <tickets>
@@ -52,6 +52,6 @@
52
52
  <tag>80s</tag>
53
53
  <tag>cher</tag>
54
54
  </tags>
55
- </event>
55
+ </event>
56
56
  </events>
57
57
  </lfm>
@@ -293,8 +293,30 @@ XML
293
293
 
294
294
  @lastfm.track.share('foo artist', 'foo track', 'foo@example.com', 'this is a message').should be_true
295
295
  end
296
+
297
+ it 'should scrobble' do
298
+ time = Time.now
299
+ @lastfm.should_receive(:request).with('track.scrobble', {
300
+ :artist => 'foo artist',
301
+ :track => 'foo track',
302
+ :album => nil,
303
+ :timestamp => time
304
+ }, :post, true, true).and_return(@ok_response)
305
+
306
+ @lastfm.track.scrobble('foo artist', 'foo track', nil, time)
307
+ end
308
+
309
+
310
+ it 'should update now playing' do
311
+ @lastfm.should_receive(:request).with('track.updateNowPlaying', {
312
+ :artist => 'foo artist',
313
+ :track => 'foo track',
314
+ }, :post, true, true).and_return(@ok_response)
315
+
316
+ @lastfm.track.update_now_playing('foo artist', 'foo track')
317
+ end
296
318
  end
297
-
319
+
298
320
  describe '#artist' do
299
321
  it 'should return an instance of Lastfm::Artist' do
300
322
  @lastfm.artist.should be_an_instance_of(Lastfm::MethodCategory::Artist)
@@ -304,7 +326,7 @@ XML
304
326
  @lastfm.should_receive(:request).with('artist.getEvents', {
305
327
  :artist => 'Cher'
306
328
  }).and_return(make_response('artist_get_events'))
307
-
329
+
308
330
  events = @lastfm.artist.get_events('Cher')
309
331
  events.size.should eql(1)
310
332
  events[0]['title'].should eql('Cher')
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - youpy
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-18 00:00:00 +09:00
17
+ date: 2010-12-06 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency