scrobbler-ng 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. data/.gitignore +11 -0
  2. data/MIT-LICENSE +19 -0
  3. data/README.rdoc +104 -0
  4. data/Rakefile +11 -0
  5. data/VERSION.yml +4 -0
  6. data/examples/album.rb +19 -0
  7. data/examples/artist.rb +13 -0
  8. data/examples/scrobble.rb +31 -0
  9. data/examples/tag.rb +11 -0
  10. data/examples/track.rb +6 -0
  11. data/examples/user.rb +14 -0
  12. data/lib/scrobbler/album.rb +165 -0
  13. data/lib/scrobbler/artist.rb +169 -0
  14. data/lib/scrobbler/auth.rb +47 -0
  15. data/lib/scrobbler/base.rb +124 -0
  16. data/lib/scrobbler/event.rb +105 -0
  17. data/lib/scrobbler/geo.rb +27 -0
  18. data/lib/scrobbler/helper/image.rb +52 -0
  19. data/lib/scrobbler/helper/streamable.rb +40 -0
  20. data/lib/scrobbler/library.rb +123 -0
  21. data/lib/scrobbler/playing.rb +49 -0
  22. data/lib/scrobbler/playlist.rb +45 -0
  23. data/lib/scrobbler/radio.rb +12 -0
  24. data/lib/scrobbler/rest.rb +47 -0
  25. data/lib/scrobbler/scrobble.rb +116 -0
  26. data/lib/scrobbler/session.rb +9 -0
  27. data/lib/scrobbler/shout.rb +21 -0
  28. data/lib/scrobbler/simpleauth.rb +60 -0
  29. data/lib/scrobbler/tag.rb +113 -0
  30. data/lib/scrobbler/track.rb +138 -0
  31. data/lib/scrobbler/user.rb +222 -0
  32. data/lib/scrobbler/venue.rb +67 -0
  33. data/lib/scrobbler.rb +34 -0
  34. data/tasks/jeweler.rake +18 -0
  35. data/tasks/rdoc.rake +7 -0
  36. data/tasks/tests.rake +13 -0
  37. data/tasks/yardoc.rake +8 -0
  38. data/test/fixtures/xml/album/info.xml +43 -0
  39. data/test/fixtures/xml/artist/fans.xml +52 -0
  40. data/test/fixtures/xml/artist/info.xml +58 -0
  41. data/test/fixtures/xml/artist/similar.xml +1004 -0
  42. data/test/fixtures/xml/artist/topalbums.xml +61 -0
  43. data/test/fixtures/xml/artist/toptags.xml +19 -0
  44. data/test/fixtures/xml/artist/toptracks.xml +62 -0
  45. data/test/fixtures/xml/auth/session.xml +7 -0
  46. data/test/fixtures/xml/auth/token.xml +3 -0
  47. data/test/fixtures/xml/event/attend.xml +3 -0
  48. data/test/fixtures/xml/event/attendees.xml +53 -0
  49. data/test/fixtures/xml/event/event.xml +35 -0
  50. data/test/fixtures/xml/event/shouts.xml +35 -0
  51. data/test/fixtures/xml/geo/events-distance-p1.xml +151 -0
  52. data/test/fixtures/xml/geo/events-lat-long.xml +167 -0
  53. data/test/fixtures/xml/geo/events-p1.xml +152 -0
  54. data/test/fixtures/xml/geo/events-p2.xml +380 -0
  55. data/test/fixtures/xml/geo/events-p3.xml +427 -0
  56. data/test/fixtures/xml/geo/top_artists-p1.xml +76 -0
  57. data/test/fixtures/xml/geo/top_tracks-p1.xml +77 -0
  58. data/test/fixtures/xml/library/albums-f30.xml +454 -0
  59. data/test/fixtures/xml/library/albums-p1.xml +754 -0
  60. data/test/fixtures/xml/library/albums-p2.xml +754 -0
  61. data/test/fixtures/xml/library/albums-p3.xml +754 -0
  62. data/test/fixtures/xml/library/albums-p4.xml +739 -0
  63. data/test/fixtures/xml/library/albums-p5.xml +754 -0
  64. data/test/fixtures/xml/library/albums-p6.xml +754 -0
  65. data/test/fixtures/xml/library/albums-p7.xml +739 -0
  66. data/test/fixtures/xml/library/albums-p8.xml +724 -0
  67. data/test/fixtures/xml/library/artists-f30.xml +334 -0
  68. data/test/fixtures/xml/library/artists-p1.xml +554 -0
  69. data/test/fixtures/xml/library/artists-p2.xml +554 -0
  70. data/test/fixtures/xml/library/artists-p3.xml +554 -0
  71. data/test/fixtures/xml/library/artists-p4.xml +554 -0
  72. data/test/fixtures/xml/library/artists-p5.xml +554 -0
  73. data/test/fixtures/xml/library/artists-p6.xml +554 -0
  74. data/test/fixtures/xml/library/artists-p7.xml +444 -0
  75. data/test/fixtures/xml/library/tracks-f30.xml +472 -0
  76. data/test/fixtures/xml/library/tracks-p1.xml +789 -0
  77. data/test/fixtures/xml/library/tracks-p10.xml +771 -0
  78. data/test/fixtures/xml/library/tracks-p11.xml +792 -0
  79. data/test/fixtures/xml/library/tracks-p12.xml +777 -0
  80. data/test/fixtures/xml/library/tracks-p13.xml +762 -0
  81. data/test/fixtures/xml/library/tracks-p14.xml +759 -0
  82. data/test/fixtures/xml/library/tracks-p15.xml +762 -0
  83. data/test/fixtures/xml/library/tracks-p16.xml +756 -0
  84. data/test/fixtures/xml/library/tracks-p17.xml +780 -0
  85. data/test/fixtures/xml/library/tracks-p18.xml +756 -0
  86. data/test/fixtures/xml/library/tracks-p19.xml +774 -0
  87. data/test/fixtures/xml/library/tracks-p2.xml +765 -0
  88. data/test/fixtures/xml/library/tracks-p20.xml +777 -0
  89. data/test/fixtures/xml/library/tracks-p21.xml +777 -0
  90. data/test/fixtures/xml/library/tracks-p22.xml +771 -0
  91. data/test/fixtures/xml/library/tracks-p23.xml +765 -0
  92. data/test/fixtures/xml/library/tracks-p24.xml +783 -0
  93. data/test/fixtures/xml/library/tracks-p25.xml +777 -0
  94. data/test/fixtures/xml/library/tracks-p26.xml +777 -0
  95. data/test/fixtures/xml/library/tracks-p27.xml +756 -0
  96. data/test/fixtures/xml/library/tracks-p28.xml +771 -0
  97. data/test/fixtures/xml/library/tracks-p29.xml +753 -0
  98. data/test/fixtures/xml/library/tracks-p3.xml +771 -0
  99. data/test/fixtures/xml/library/tracks-p30.xml +780 -0
  100. data/test/fixtures/xml/library/tracks-p31.xml +753 -0
  101. data/test/fixtures/xml/library/tracks-p32.xml +771 -0
  102. data/test/fixtures/xml/library/tracks-p33.xml +762 -0
  103. data/test/fixtures/xml/library/tracks-p34.xml +538 -0
  104. data/test/fixtures/xml/library/tracks-p4.xml +792 -0
  105. data/test/fixtures/xml/library/tracks-p5.xml +780 -0
  106. data/test/fixtures/xml/library/tracks-p6.xml +789 -0
  107. data/test/fixtures/xml/library/tracks-p7.xml +789 -0
  108. data/test/fixtures/xml/library/tracks-p8.xml +780 -0
  109. data/test/fixtures/xml/library/tracks-p9.xml +774 -0
  110. data/test/fixtures/xml/tag/similar.xml +254 -0
  111. data/test/fixtures/xml/tag/topalbums.xml +805 -0
  112. data/test/fixtures/xml/tag/topartists.xml +605 -0
  113. data/test/fixtures/xml/tag/toptags.xml +1254 -0
  114. data/test/fixtures/xml/tag/toptracks.xml +852 -0
  115. data/test/fixtures/xml/track/fans.xml +34 -0
  116. data/test/fixtures/xml/track/info.xml +53 -0
  117. data/test/fixtures/xml/track/toptags.xml +504 -0
  118. data/test/fixtures/xml/user/events.xml +401 -0
  119. data/test/fixtures/xml/user/friends.xml +30 -0
  120. data/test/fixtures/xml/user/lovedtracks.xml +678 -0
  121. data/test/fixtures/xml/user/neighbours.xml +23 -0
  122. data/test/fixtures/xml/user/playlists.xml +61 -0
  123. data/test/fixtures/xml/user/profile.xml +12 -0
  124. data/test/fixtures/xml/user/recentbannedtracks.xml +24 -0
  125. data/test/fixtures/xml/user/recentlovedtracks.xml +24 -0
  126. data/test/fixtures/xml/user/recenttracks.xml +124 -0
  127. data/test/fixtures/xml/user/systemrecs.xml +18 -0
  128. data/test/fixtures/xml/user/topalbums.xml +61 -0
  129. data/test/fixtures/xml/user/topartists.xml +41 -0
  130. data/test/fixtures/xml/user/toptags.xml +44 -0
  131. data/test/fixtures/xml/user/toptracks.xml +65 -0
  132. data/test/fixtures/xml/user/weeklyalbumchart.xml +256 -0
  133. data/test/fixtures/xml/user/weeklyartistchart.xml +220 -0
  134. data/test/fixtures/xml/user/weeklytrackchart.xml +746 -0
  135. data/test/fixtures/xml/venue/events.xml +151 -0
  136. data/test/fixtures/xml/venue/venue.xml +16 -0
  137. data/test/mocks/rest.rb +212 -0
  138. data/test/spec_helper.rb +7 -0
  139. data/test/test_helper.rb +20 -0
  140. data/test/unit/album_spec.rb +51 -0
  141. data/test/unit/artist_spec.rb +130 -0
  142. data/test/unit/auth_spec.rb +36 -0
  143. data/test/unit/event_spec.rb +109 -0
  144. data/test/unit/geo_spec.rb +148 -0
  145. data/test/unit/library_spec.rb +133 -0
  146. data/test/unit/playing_test.rb +53 -0
  147. data/test/unit/playlist_spec.rb +25 -0
  148. data/test/unit/radio_spec.rb +22 -0
  149. data/test/unit/scrobble_spec.rb +55 -0
  150. data/test/unit/scrobble_test.rb +69 -0
  151. data/test/unit/simpleauth_test.rb +45 -0
  152. data/test/unit/tag_spec.rb +101 -0
  153. data/test/unit/track_spec.rb +95 -0
  154. data/test/unit/user_spec.rb +264 -0
  155. data/test/unit/venue_spec.rb +104 -0
  156. metadata +253 -0
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../test_helper.rb'
2
+
3
+ class TestSimpleAuth < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @auth = Scrobbler::SimpleAuth.new(:user => 'chunky', :password => 'bacon')
7
+ end
8
+
9
+ test 'should require a user' do
10
+ assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:password => 'bacon') }
11
+ end
12
+
13
+ test 'should require a password' do
14
+ assert_raises(ArgumentError) { Scrobbler::SimpleAuth.new(:user => 'chunky') }
15
+ end
16
+
17
+ test 'should have the right client id' do
18
+ assert_equal('rbs', @auth.client_id)
19
+ end
20
+
21
+ test 'should have the right version' do
22
+ assert_equal('0.2.13', @auth.client_ver)
23
+ end
24
+
25
+ test 'should handshake successfully' do
26
+ @auth.handshake!
27
+ assert_equal('OK', @auth.status)
28
+ end
29
+
30
+ test 'should get a session id' do
31
+ @auth.handshake!
32
+ assert_equal('17E61E13454CDD8B68E8D7DEEEDF6170', @auth.session_id)
33
+ end
34
+
35
+ test 'should get a now playing url' do
36
+ @auth.handshake!
37
+ assert_equal('http://62.216.251.203:80/nowplaying', @auth.now_playing_url)
38
+ end
39
+
40
+ test 'should get a submission url' do
41
+ @auth.handshake!
42
+ assert_equal('http://62.216.251.205:80/protocol_1.2', @auth.submission_url)
43
+ end
44
+
45
+ end
@@ -0,0 +1,101 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::Tag do
4
+
5
+ before(:all) do
6
+ @tag = Scrobbler::Tag.new('rock')
7
+ end
8
+
9
+ it 'should know its name' do
10
+ @tag.name.should eql('rock')
11
+ end
12
+
13
+ it 'should implement all methods from the Last.fm 2.0 API' do
14
+ @tag.should respond_to(:similar)
15
+ @tag.should respond_to(:top_albums)
16
+ @tag.should respond_to(:top_artists)
17
+ Scrobbler::Tag.should respond_to(:top_tags)
18
+ @tag.should respond_to(:top_tracks)
19
+ @tag.should respond_to(:weekly_artist_chart)
20
+ @tag.should respond_to(:weekly_chart_list)
21
+ Scrobbler::Tag.should respond_to(:search)
22
+ end
23
+
24
+ it 'should be able to get similar tags' do
25
+ @tag.should have(50).similar
26
+ first = @tag.similar.first
27
+ first.should be_kind_of(Scrobbler::Tag)
28
+ first.name.should eql('classic rock')
29
+ first.url.should eql('http://www.last.fm/tag/classic%20rock')
30
+ first.streamable.should be_true
31
+ end
32
+
33
+ it 'should be able to find its top albums' do
34
+ @tag.top_albums.should be_kind_of(Array)
35
+ @tag.top_albums.should have(50).items
36
+ @tag.top_albums.first.should be_kind_of(Scrobbler::Album)
37
+ @tag.top_albums.first.rank.should eql(1)
38
+ @tag.top_albums.first.name.should eql('Overpowered')
39
+ @tag.top_albums.first.tagcount.should eql(105)
40
+ @tag.top_albums.first.mbid.should eql('')
41
+ @tag.top_albums.first.url.should eql('http://www.last.fm/music/R%C3%B3is%C3%ADn+Murphy/Overpowered')
42
+ @tag.top_albums.first.artist.should be_kind_of(Scrobbler::Artist)
43
+ @tag.top_albums.first.artist.name.should eql('Róisín Murphy')
44
+ @tag.top_albums.first.artist.mbid.should eql('4c56405d-ba8e-4283-99c3-1dc95bdd50e7')
45
+ @tag.top_albums.first.artist.url.should eql('http://www.last.fm/music/R%C3%B3is%C3%ADn+Murphy')
46
+ @tag.top_albums.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/26856969.png')
47
+ @tag.top_albums.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/26856969.png')
48
+ @tag.top_albums.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/26856969.png')
49
+ end
50
+
51
+ it 'should be able to find its top artists' do
52
+ @tag.top_artists.should be_kind_of(Array)
53
+ @tag.top_artists.should have(50).items
54
+ @tag.top_artists.first.should be_kind_of(Scrobbler::Artist)
55
+ @tag.top_artists.first.rank.should eql(1)
56
+ @tag.top_artists.first.name.should eql('ABBA')
57
+ @tag.top_artists.first.tagcount.should eql(1229)
58
+ @tag.top_artists.first.mbid.should eql('d87e52c5-bb8d-4da8-b941-9f4928627dc8')
59
+ @tag.top_artists.first.url.should eql('http://www.last.fm/music/ABBA')
60
+ @tag.top_artists.first.streamable.should be_true
61
+ @tag.top_artists.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/135930.jpg')
62
+ @tag.top_artists.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/135930.jpg')
63
+ @tag.top_artists.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/135930.jpg')
64
+ end
65
+
66
+ it 'should be able to find global top tags' do
67
+ Scrobbler::Tag.should have(250).top_tags
68
+ first = Scrobbler::Tag.top_tags.first
69
+ first.should be_kind_of(Scrobbler::Tag)
70
+ first.name.should eql('rock')
71
+ first.count.should eql(2267576)
72
+ first.url.should eql('www.last.fm/tag/rock')
73
+ end
74
+
75
+ it 'should be able to find its top tracks' do
76
+ @tag.top_tracks.should be_kind_of(Array)
77
+ @tag.top_tracks.should have(50).items
78
+ @tag.top_tracks.first.should be_kind_of(Scrobbler::Track)
79
+ @tag.top_tracks.first.rank.should eql(1)
80
+ @tag.top_tracks.first.name.should eql('Stayin\' Alive')
81
+ @tag.top_tracks.first.tagcount.should eql(422)
82
+ @tag.top_tracks.first.mbid.should eql('')
83
+ @tag.top_tracks.first.streamable.should be_true
84
+ @tag.top_tracks.first.url.should eql('http://www.last.fm/music/Bee+Gees/_/Stayin%27+Alive')
85
+ @tag.top_tracks.first.artist.should be_kind_of(Scrobbler::Artist)
86
+ @tag.top_tracks.first.artist.name.should eql('Bee Gees')
87
+ @tag.top_tracks.first.artist.mbid.should eql('bf0f7e29-dfe1-416c-b5c6-f9ebc19ea810')
88
+ @tag.top_tracks.first.artist.url.should eql('http://www.last.fm/music/Bee+Gees')
89
+ @tag.top_tracks.first.image(:small).should eql('http://images.amazon.com/images/P/B00069590Q.01._SCMZZZZZZZ_.jpg')
90
+ @tag.top_tracks.first.image(:medium).should eql('http://images.amazon.com/images/P/B00069590Q.01._SCMZZZZZZZ_.jpg')
91
+ @tag.top_tracks.first.image(:large).should eql('http://images.amazon.com/images/P/B00069590Q.01._SCMZZZZZZZ_.jpg')
92
+ end
93
+
94
+ it 'should be able to get the weekly artist chart'
95
+
96
+ it 'should be able to get the weekly chart list'
97
+
98
+ it 'should be able to search for a tag'
99
+
100
+ end
101
+
@@ -0,0 +1,95 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::Track do
4
+
5
+ before(:all) do
6
+ @track = Scrobbler::Track.new(Scrobbler::Artist.new('Carrie Underwood'), 'Before He Cheats')
7
+ end
8
+
9
+ it 'should know the artist' do
10
+ @track.artist.should be_kind_of(Scrobbler::Artist)
11
+ @track.artist.name.should eql('Carrie Underwood')
12
+ end
13
+
14
+ it 'should know the name' do
15
+ @track.name.should eql('Before He Cheats')
16
+ end
17
+
18
+ it 'should implement all methods from the Last.fm 2.0 API' do
19
+ @track.should respond_to(:add_tags)
20
+ @track.should respond_to(:ban)
21
+ @track.should respond_to(:load_info)
22
+ @track.should respond_to(:similar)
23
+ @track.should respond_to(:tags)
24
+ @track.should respond_to(:top_tags)
25
+ @track.should respond_to(:top_fans)
26
+ @track.should respond_to(:love)
27
+ @track.should respond_to(:remove_tag)
28
+ @track.should respond_to(:search)
29
+ @track.should respond_to(:share)
30
+ end
31
+
32
+ it 'should be able to add tags'
33
+
34
+ it 'should be able to be banned'
35
+
36
+ it 'should be able to load more information' do
37
+ @track.load_info
38
+ @track.id.should eql(1019817)
39
+ @track.mbid.should eql('')
40
+ @track.url.should eql('http://www.last.fm/music/Cher/_/Believe')
41
+ @track.duration.should eql(222000)
42
+ @track.streamable.should be_true
43
+ @track.listeners.should eql(114831)
44
+ @track.playcount.should eql(435094)
45
+ @track.artist.should be_kind_of(Scrobbler::Artist)
46
+ @track.artist.name.should eql('Cher')
47
+ @track.artist.mbid.should eql('bfcc6d75-a6a5-4bc6-8282-47aec8531818')
48
+ @track.artist.url.should eql('http://www.last.fm/music/Cher')
49
+ @track.album.should be_kind_of(Scrobbler::Album)
50
+ @track.album.position.should eql(1)
51
+ @track.album.artist.should be_kind_of(Scrobbler::Artist)
52
+ @track.album.artist.name.should eql('Cher')
53
+ @track.album.name.should eql('Believe')
54
+ @track.album.mbid.should eql('61bf0388-b8a9-48f4-81d1-7eb02706dfb0')
55
+ @track.album.url.should eql('http://www.last.fm/music/Cher/Believe')
56
+ @track.album.image(:small).should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
57
+ @track.album.image(:medium).should eql('http://userserve-ak.last.fm/serve/126/8674593.jpg')
58
+ @track.album.image(:large).should eql('http://userserve-ak.last.fm/serve/174s/8674593.jpg')
59
+ end
60
+
61
+ it 'should be able to get similar tracks'
62
+
63
+ it 'should be able to get the user\'s tags'
64
+
65
+ it 'should be able to get its top tags' do
66
+ @track.top_tags.should be_kind_of(Array)
67
+ @track.top_tags.should have(100).items
68
+ @track.top_tags.first.should be_kind_of(Scrobbler::Tag)
69
+ @track.top_tags.first.name.should eql('pop')
70
+ @track.top_tags.first.count.should eql(924808)
71
+ @track.top_tags.first.url.should eql('www.last.fm/tag/pop')
72
+ end
73
+
74
+ it 'should be able to get its top fans' do
75
+ @track.top_fans.should be_kind_of(Array)
76
+ @track.top_fans.should have(3).items
77
+ @track.top_fans.first.should be_kind_of(Scrobbler::User)
78
+ @track.top_fans.first.name.should eql('ccaron0')
79
+ @track.top_fans.first.url.should eql('http://www.last.fm/user/ccaron0')
80
+ @track.top_fans.first.image(:small).should eql('')
81
+ @track.top_fans.first.image(:medium).should eql('')
82
+ @track.top_fans.first.image(:large).should eql('')
83
+ @track.top_fans.first.weight.should eql(335873)
84
+ end
85
+
86
+ it 'should be able to love this track'
87
+
88
+ it 'should be able to remove a tag'
89
+
90
+ it 'should be able to search for a track'
91
+
92
+ it 'should be able to share a track'
93
+
94
+ end
95
+
@@ -0,0 +1,264 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::User do
4
+
5
+ before(:all) do
6
+ @user = Scrobbler::User.new('jnunemaker')
7
+ end
8
+
9
+ it 'should know its name' do
10
+ @user.name.should eql('jnunemaker')
11
+ end
12
+
13
+ it 'should implement all methods from the Last.fm 2.0 API' do
14
+ @user.should respond_to(:events)
15
+ @user.should respond_to(:friends)
16
+ @user.should respond_to(:load_info)
17
+ @user.should respond_to(:loved_tracks)
18
+ @user.should respond_to(:neighbours)
19
+ @user.should respond_to(:past_events)
20
+ @user.should respond_to(:playlists)
21
+ @user.should respond_to(:recent_tracks)
22
+ @user.should respond_to(:recommended_artists)
23
+ @user.should respond_to(:recommended_events)
24
+ @user.should respond_to(:shouts)
25
+ @user.should respond_to(:top_albums)
26
+ @user.should respond_to(:top_artists)
27
+ @user.should respond_to(:top_tags)
28
+ @user.should respond_to(:top_tracks)
29
+ @user.should respond_to(:weekly_album_chart)
30
+ @user.should respond_to(:weekly_artist_chart)
31
+ @user.should respond_to(:weekly_chart_list)
32
+ @user.should respond_to(:weekly_track_chart)
33
+ @user.should respond_to(:shout)
34
+ end
35
+
36
+ it 'should be able to get a list of upcoming events this user is attending' do
37
+ @user.events.should be_kind_of(Array)
38
+ @user.events.should have(7).items
39
+ @user.events.first.should be_kind_of(Scrobbler::Event)
40
+ @user.events.first.id.should eql(1030003)
41
+ @user.events.first.title.should eql('The Mars Volta')
42
+ @user.events.first.headliner.should be_kind_of(Scrobbler::Artist)
43
+ @user.events.first.headliner.name.should eql('The Mars Volta')
44
+ @user.events.first.artists.should be_kind_of(Array)
45
+ @user.events.first.artists.should have(1).items
46
+ @user.events.first.artists.first.should be_kind_of(Scrobbler::Artist)
47
+ @user.events.first.artists.first.name.should eql('The Mars Volta')
48
+ @user.events.first.venue.should be_kind_of(Scrobbler::Venue)
49
+ @user.events.first.venue.name.should eql('Somerset House')
50
+ @user.events.first.venue.id.should eql(8796717)
51
+ @user.events.first.venue.city.should eql('London')
52
+ @user.events.first.venue.country.should eql('United Kingdom')
53
+ @user.events.first.venue.street.should eql('Strand')
54
+ @user.events.first.venue.postalcode.should eql('WC2R 1LA')
55
+ @user.events.first.venue.geo_lat.should eql('51.510732')
56
+ @user.events.first.venue.geo_long.should eql('-0.116937')
57
+ @user.events.first.venue.url.should eql('http://www.last.fm/venue/8796717')
58
+ @user.events.first.start_date.should eql(Time.mktime(2009, 07, 13, 19, 30, 00))
59
+ @user.events.first.description.should eql('<div class="bbcode"><a href="http://www.nme.com/news/nme/44079" rel="nofollow">http://www.nme.com/news/nme/44079</a></div>')
60
+ end
61
+
62
+ it 'should be able to get a list of its friends' do
63
+ @user.friends.should be_kind_of(Array)
64
+ @user.friends.should have(3).items
65
+ @user.friends.first.should be_kind_of(Scrobbler::User)
66
+ @user.friends.first.name.should eql('lobsterclaw')
67
+ @user.friends.first.realname.should eql('Laura Weiss')
68
+ @user.friends.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/1733471.jpg')
69
+ @user.friends.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/1733471.jpg')
70
+ @user.friends.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/1733471.jpg')
71
+ @user.friends.first.url.should eql('http://www.last.fm/user/lobsterclaw')
72
+ end
73
+
74
+ it 'should be able to load additional information'
75
+
76
+ it 'should be able to get its loved tracks' do
77
+ @user.loved_tracks.should be_kind_of(Array)
78
+ @user.loved_tracks.should have(49).items
79
+ @user.loved_tracks.first.should be_kind_of(Scrobbler::Track)
80
+ @user.loved_tracks.first.name.should eql('Early Mornin\' Stoned Pimp')
81
+ @user.loved_tracks.first.mbid.should eql('')
82
+ @user.loved_tracks.first.url.should eql('www.last.fm/music/Kid+Rock/_/Early+Mornin%27+Stoned+Pimp')
83
+ @user.loved_tracks.first.date.should eql(Time.mktime(2009, 4, 28, 11, 38, 0))
84
+ @user.loved_tracks.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/3458313.jpg')
85
+ @user.loved_tracks.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/3458313.jpg')
86
+ @user.loved_tracks.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/3458313.jpg')
87
+ @user.loved_tracks.first.artist.should be_kind_of(Scrobbler::Artist)
88
+ @user.loved_tracks.first.artist.name.should eql('Kid Rock')
89
+ @user.loved_tracks.first.artist.mbid.should eql('ad0ecd8b-805e-406e-82cb-5b00c3a3a29e')
90
+ @user.loved_tracks.first.artist.url.should eql('http://www.last.fm/music/Kid+Rock')
91
+ end
92
+
93
+ it 'should be able to list the neighbours' do
94
+ @user.should have(2).neighbours
95
+ @user.neighbours.first.should be_kind_of(Scrobbler::User)
96
+ @user.neighbours.first.name.should eql('Driotheri')
97
+ @user.neighbours.first.url.should eql('http://www.last.fm/user/Driotheri')
98
+ @user.neighbours.first.match.should eql('0.00027966260677204')
99
+ @user.neighbours.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/6070771.jpg')
100
+ @user.neighbours.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/6070771.jpg')
101
+ @user.neighbours.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/6070771.jpg')
102
+ end
103
+
104
+ it 'should be able to list the attened events'
105
+
106
+ describe 'retrieving a users playlist' do
107
+
108
+ before do
109
+ @playlists = @user.playlists
110
+ @firstplaylist = @playlists.first
111
+ end
112
+
113
+ it 'should return 4 playlists' do
114
+ @playlists.size.should eql(4)
115
+ end
116
+
117
+ it 'should have the correct attributes in the first playlist' do
118
+ #@firstplaylist.id.should eql(5606)
119
+ require 'pp'
120
+ pp @firstplaylist.id
121
+ @firstplaylist.title.should eql('Misc gubbins')
122
+ @firstplaylist.description.should eql('This is a misc test playlist with a few random tracks in it.')
123
+ @firstplaylist.date.should eql(Time.mktime(2006, 11, 15, 13, 05, 48))
124
+ @firstplaylist.size.should eql(10)
125
+ @firstplaylist.duration.should eql(2771)
126
+ @firstplaylist.streamable.should be_false
127
+ @firstplaylist.creator.should eql('http://www.last.fm/user/RJ')
128
+ @firstplaylist.url.should eql('http://www.last.fm/user/RJ/library/playlists/4bq_misc_gubbins')
129
+ @firstplaylist.image(:small).should eql('http://userserve-ak.last.fm/serve/34/4218758.jpg')
130
+ @firstplaylist.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/4218758.jpg')
131
+ @firstplaylist.image(:large).should eql('http://userserve-ak.last.fm/serve/126/4218758.jpg')
132
+ end
133
+ end
134
+
135
+
136
+ it 'should be able to fetch the recent tracks' do
137
+ @user.should have(10).recent_tracks
138
+ @user.recent_tracks.first.should be_kind_of(Scrobbler::Track)
139
+ @user.recent_tracks.first.name.should eql('Empty Arms')
140
+ @user.recent_tracks.first.mbid.should eql('')
141
+ @user.recent_tracks.first.url.should eql('http://www.last.fm/music/Stevie+Ray+Vaughan/_/Empty+Arms')
142
+ @user.recent_tracks.first.date.should eql(Time.mktime(2009, 5, 6, 18, 16, 00))
143
+ @user.recent_tracks.first.now_playing.should be_true
144
+ @user.recent_tracks.first.streamable.should be_true
145
+ @user.recent_tracks.first.artist.should be_kind_of(Scrobbler::Artist)
146
+ @user.recent_tracks.first.artist.name.should eql('Stevie Ray Vaughan')
147
+ @user.recent_tracks.first.artist.mbid.should eql('f5426431-f490-4678-ad44-a75c71097bb4')
148
+ @user.recent_tracks.first.album.should be_kind_of(Scrobbler::Album)
149
+ @user.recent_tracks.first.album.mbid.should eql('dfb4ba34-6d3f-4d88-848f-e8cc1e7c24d7')
150
+ @user.recent_tracks.first.album.name.should eql('Sout To Soul')
151
+ @user.recent_tracks.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/4289298.jpg')
152
+ @user.recent_tracks.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/4289298.jpg')
153
+ @user.recent_tracks.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/4289298.jpg')
154
+ end
155
+
156
+ it 'should be able to list the recommended artists'
157
+
158
+ it 'should be able to list the recommended events'
159
+
160
+ it 'should be able to list the shouts'
161
+
162
+ it 'should be able to list the top albums' do
163
+ @user.should have(3).top_albums
164
+ @user.top_albums.first.should be_kind_of(Scrobbler::Album)
165
+ @user.top_albums.first.name.should eql('Slave To The Grid')
166
+ @user.top_albums.first.mbid.should eql('')
167
+ @user.top_albums.first.playcount.should eql(251)
168
+ @user.top_albums.first.rank.should eql(1)
169
+ @user.top_albums.first.artist.should be_kind_of(Scrobbler::Artist)
170
+ @user.top_albums.first.artist.name.should eql('Skid Row')
171
+ @user.top_albums.first.artist.mbid.should eql('6da0515e-a27d-449d-84cc-00713c38a140')
172
+ @user.top_albums.first.url.should eql('http://www.last.fm/music/Skid+Row/Slave+To+The+Grid')
173
+ @user.top_albums.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/12621887.jpg')
174
+ @user.top_albums.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/12621887.jpg')
175
+ @user.top_albums.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/12621887.jpg')
176
+ end
177
+
178
+ it 'should be able to list the top artists' do
179
+ @user.should have(3).top_artists
180
+ @user.top_artists.first.should be_kind_of(Scrobbler::Artist)
181
+ first = @user.top_artists.first
182
+ first.name.should eql('Dream Theater')
183
+ first.mbid.should eql('28503ab7-8bf2-4666-a7bd-2644bfc7cb1d')
184
+ first.playcount.should eql(1643)
185
+ first.rank.should eql(1)
186
+ first.url.should eql('http://www.last.fm/music/Dream+Theater')
187
+ first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/5535004.jpg')
188
+ first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/5535004.jpg')
189
+ first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/5535004.jpg')
190
+ first.streamable.should be_true
191
+ end
192
+
193
+ it 'should be able to list the top tags' do
194
+ @user.should have(7).top_tags
195
+ @user.top_tags.first.should be_kind_of Scrobbler::Tag
196
+ first = @user.top_tags.first
197
+ first.name.should eql 'rock'
198
+ first.count.should eql 16
199
+ first.url.should eql 'www.last.fm/tag/rock'
200
+ end
201
+
202
+ it 'should be able to list the top tracks' do
203
+ @user.should have(3).top_tracks
204
+ @user.top_tracks.first.should be_kind_of(Scrobbler::Track)
205
+ first = @user.top_tracks.first
206
+ first.name.should eql 'Learning to Live'
207
+ first.mbid.should eql ''
208
+ first.playcount.should eql 51
209
+ first.rank.should eql 1
210
+ first.url.should eql 'http://www.last.fm/music/Dream+Theater/_/Learning+to+Live'
211
+ first.image(:small).should eql 'http://userserve-ak.last.fm/serve/34s/12620339.jpg'
212
+ first.image(:medium).should eql 'http://userserve-ak.last.fm/serve/64s/12620339.jpg'
213
+ first.image(:large).should eql 'http://userserve-ak.last.fm/serve/126/12620339.jpg'
214
+ first.artist.should be_kind_of Scrobbler::Artist
215
+ first.artist.name.should eql 'Dream Theater'
216
+ first.artist.mbid.should eql '28503ab7-8bf2-4666-a7bd-2644bfc7cb1d'
217
+ first.artist.url.should eql 'http://www.last.fm/music/Dream+Theater'
218
+ first.streamable.should be_true
219
+ end
220
+
221
+ it 'should be able to get the weekly album chart' do
222
+ @user.weekly_album_chart.should have(36).items
223
+ first = @user.weekly_album_chart.first
224
+ first.should be_kind_of Scrobbler::Album
225
+ first.artist.should be_kind_of Scrobbler::Artist
226
+ first.artist.name.should eql 'Nine Inch Nails'
227
+ first.artist.mbid.should eql 'b7ffd2af-418f-4be2-bdd1-22f8b48613da'
228
+ first.mbid.should eql 'df025315-4897-4759-ba77-d2cd09b5b4b6'
229
+ first.name.should eql 'With Teeth'
230
+ first.playcount.should eql 13
231
+ first.rank.should eql 1
232
+ first.url.should eql 'http://www.last.fm/music/Nine+Inch+Nails/With+Teeth'
233
+ end
234
+
235
+ it 'should be able to get the weekly artist chart' do
236
+ @user.weekly_artist_chart.should have(36).items
237
+ first = @user.weekly_artist_chart.first
238
+ first.should be_kind_of Scrobbler::Artist
239
+ first.name.should eql 'Nine Inch Nails'
240
+ first.mbid.should eql 'b7ffd2af-418f-4be2-bdd1-22f8b48613da'
241
+ first.playcount.should eql 26
242
+ first.rank.should eql 1
243
+ first.url.should eql 'http://www.last.fm/music/Nine+Inch+Nails'
244
+ end
245
+
246
+ it 'should be able to get the weekly chart list'
247
+
248
+ it 'should be able to get the weekly track chart' do
249
+ @user.weekly_track_chart.should have(106).items
250
+ first = @user.weekly_track_chart.first
251
+ first.should be_kind_of Scrobbler::Track
252
+ first.name.should eql 'Three Minute Warning'
253
+ first.artist.should be_kind_of Scrobbler::Artist
254
+ first.artist.name.should eql 'Liquid Tension Experiment'
255
+ first.artist.mbid.should eql 'bc641be9-ca36-4c61-9394-5230433f6646'
256
+ first.mbid.should eql ''
257
+ first.playcount.should eql 5
258
+ first.rank.should eql 1
259
+ first.url.should eql 'www.last.fm/music/Liquid+Tension+Experiment/_/Three+Minute+Warning'
260
+ end
261
+
262
+ it 'should be able to leave a shout'
263
+
264
+ end
@@ -0,0 +1,104 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Scrobbler::Venue do
4
+ before do
5
+ xml = LibXML::XML::Document.file(File.dirname(__FILE__) + '/../fixtures/xml/venue/venue.xml')
6
+ @venue = Scrobbler::Venue.new_from_xml(xml.root)
7
+ @event_ids = [875740, 950267, 1082373, 1059277]
8
+ @event_titles = ["Kilians", "Convention of the Universe - International Depeche Mode Fan Event", "The Get Up Kids", "Philipp Poisel"]
9
+ end
10
+
11
+ describe 'should implement the method' do
12
+ [:events,:past_events].each do |method_name|
13
+ it "'#{method_name}'" do
14
+ @venue.should respond_to(method_name)
15
+ end
16
+ end
17
+
18
+ it 'search' do
19
+ Scrobbler::Venue.should respond_to(:search)
20
+ end
21
+ end
22
+
23
+ describe 'a Venue built from XML should have' do
24
+ it 'an ID' do
25
+ @venue.id.should eql(9027137)
26
+ end
27
+
28
+ it 'a name' do
29
+ @venue.name.should eql('Karrera Klub')
30
+ end
31
+
32
+ it 'a city' do
33
+ @venue.city.should eql('Berlin')
34
+ end
35
+
36
+ it 'a country' do
37
+ @venue.country.should eql('Germany')
38
+ end
39
+
40
+ it 'a street' do
41
+ @venue.street.should eql('Neue Promenade 10')
42
+ end
43
+
44
+ it 'a postalcode' do
45
+ @venue.postalcode.should eql('10178')
46
+ end
47
+
48
+ it 'a geo_lat' do
49
+ @venue.geo_lat.should eql('52.532019')
50
+ end
51
+
52
+ it 'a geo_long' do
53
+ @venue.geo_long.should eql('13.427965')
54
+ end
55
+
56
+ it 'a timezone' do
57
+ @venue.timezone.should eql('CET')
58
+ end
59
+
60
+ it 'a URL' do
61
+ @venue.url.should eql('http://www.last.fm/venue/9027137')
62
+ end
63
+ end
64
+
65
+ describe 'finding events for Postbahnhof, Berlin' do
66
+ before do
67
+ @events = @venue.events
68
+ end
69
+
70
+ it 'should find 4 events' do
71
+ @events.size.should eql 4
72
+ end
73
+
74
+ it "should have the correct event id's" do
75
+ @events.collect(&:id).should eql @event_ids
76
+ end
77
+
78
+ it 'should have the correct event titles' do
79
+ @events.collect(&:title).should eql @event_titles
80
+ end
81
+ end
82
+
83
+ describe 'finding past events for Postbahnhof, Berlin' do
84
+ before do
85
+ @events = @venue.past_events
86
+ end
87
+
88
+ it 'should find 4 events' do
89
+ @events.size.should eql 4
90
+ end
91
+
92
+ it "should have the correct event id's" do
93
+ @events.collect(&:id).should eql @event_ids
94
+ end
95
+
96
+ it 'should have the correct event titles' do
97
+ @events.collect(&:title).should eql @event_titles
98
+ end
99
+ end
100
+
101
+ describe 'searching for venues' do
102
+ #TODO
103
+ end
104
+ end