hornairs-scrobbler 0.2.3
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.
- data/.gitignore +13 -0
- data/.loadpath +5 -0
- data/History.txt +5 -0
- data/MIT-LICENSE +19 -0
- data/Manifest +75 -0
- data/README.rdoc +104 -0
- data/Rakefile +10 -0
- data/VERSION.yml +5 -0
- data/examples/album.rb +20 -0
- data/examples/artist.rb +13 -0
- data/examples/playlist.rb +7 -0
- data/examples/scrobble.rb +31 -0
- data/examples/tag.rb +11 -0
- data/examples/track.rb +12 -0
- data/examples/user.rb +15 -0
- data/lib/scrobbler.rb +33 -0
- data/lib/scrobbler/album.rb +181 -0
- data/lib/scrobbler/artist.rb +165 -0
- data/lib/scrobbler/auth.rb +47 -0
- data/lib/scrobbler/base.rb +105 -0
- data/lib/scrobbler/event.rb +105 -0
- data/lib/scrobbler/geo.rb +27 -0
- data/lib/scrobbler/helper/image.rb +52 -0
- data/lib/scrobbler/helper/streamable.rb +40 -0
- data/lib/scrobbler/library.rb +112 -0
- data/lib/scrobbler/playing.rb +49 -0
- data/lib/scrobbler/playlist.rb +87 -0
- data/lib/scrobbler/radio.rb +12 -0
- data/lib/scrobbler/rest.rb +47 -0
- data/lib/scrobbler/scrobble.rb +116 -0
- data/lib/scrobbler/session.rb +9 -0
- data/lib/scrobbler/shout.rb +21 -0
- data/lib/scrobbler/simpleauth.rb +60 -0
- data/lib/scrobbler/tag.rb +113 -0
- data/lib/scrobbler/track.rb +152 -0
- data/lib/scrobbler/user.rb +222 -0
- data/lib/scrobbler/venue.rb +67 -0
- data/setup.rb +1585 -0
- data/tasks/jeweler.rake +15 -0
- data/tasks/rdoc.rake +7 -0
- data/tasks/tests.rake +13 -0
- data/tasks/yardoc.rake +8 -0
- data/test/fixtures/xml/album/info.xml +43 -0
- data/test/fixtures/xml/artist/fans.xml +52 -0
- data/test/fixtures/xml/artist/info.xml +58 -0
- data/test/fixtures/xml/artist/similar.xml +1004 -0
- data/test/fixtures/xml/artist/topalbums.xml +61 -0
- data/test/fixtures/xml/artist/toptags.xml +19 -0
- data/test/fixtures/xml/artist/toptracks.xml +62 -0
- data/test/fixtures/xml/auth/session.xml +7 -0
- data/test/fixtures/xml/auth/token.xml +3 -0
- data/test/fixtures/xml/event/attend.xml +3 -0
- data/test/fixtures/xml/event/attendees.xml +53 -0
- data/test/fixtures/xml/event/event.xml +35 -0
- data/test/fixtures/xml/event/shouts.xml +35 -0
- data/test/fixtures/xml/geo/events-distance-p1.xml +151 -0
- data/test/fixtures/xml/geo/events-lat-long.xml +167 -0
- data/test/fixtures/xml/geo/events-p1.xml +152 -0
- data/test/fixtures/xml/geo/events-p2.xml +380 -0
- data/test/fixtures/xml/geo/events-p3.xml +427 -0
- data/test/fixtures/xml/geo/top_artists-p1.xml +76 -0
- data/test/fixtures/xml/geo/top_tracks-p1.xml +77 -0
- data/test/fixtures/xml/library/albums-f30.xml +454 -0
- data/test/fixtures/xml/library/albums-p1.xml +754 -0
- data/test/fixtures/xml/library/albums-p2.xml +754 -0
- data/test/fixtures/xml/library/albums-p3.xml +754 -0
- data/test/fixtures/xml/library/albums-p4.xml +739 -0
- data/test/fixtures/xml/library/albums-p5.xml +754 -0
- data/test/fixtures/xml/library/albums-p6.xml +754 -0
- data/test/fixtures/xml/library/albums-p7.xml +739 -0
- data/test/fixtures/xml/library/albums-p8.xml +724 -0
- data/test/fixtures/xml/library/artists-f30.xml +334 -0
- data/test/fixtures/xml/library/artists-p1.xml +554 -0
- data/test/fixtures/xml/library/artists-p2.xml +554 -0
- data/test/fixtures/xml/library/artists-p3.xml +554 -0
- data/test/fixtures/xml/library/artists-p4.xml +554 -0
- data/test/fixtures/xml/library/artists-p5.xml +554 -0
- data/test/fixtures/xml/library/artists-p6.xml +554 -0
- data/test/fixtures/xml/library/artists-p7.xml +444 -0
- data/test/fixtures/xml/library/tracks-f30.xml +472 -0
- data/test/fixtures/xml/library/tracks-p1.xml +789 -0
- data/test/fixtures/xml/library/tracks-p10.xml +771 -0
- data/test/fixtures/xml/library/tracks-p11.xml +792 -0
- data/test/fixtures/xml/library/tracks-p12.xml +777 -0
- data/test/fixtures/xml/library/tracks-p13.xml +762 -0
- data/test/fixtures/xml/library/tracks-p14.xml +759 -0
- data/test/fixtures/xml/library/tracks-p15.xml +762 -0
- data/test/fixtures/xml/library/tracks-p16.xml +756 -0
- data/test/fixtures/xml/library/tracks-p17.xml +780 -0
- data/test/fixtures/xml/library/tracks-p18.xml +756 -0
- data/test/fixtures/xml/library/tracks-p19.xml +774 -0
- data/test/fixtures/xml/library/tracks-p2.xml +765 -0
- data/test/fixtures/xml/library/tracks-p20.xml +777 -0
- data/test/fixtures/xml/library/tracks-p21.xml +777 -0
- data/test/fixtures/xml/library/tracks-p22.xml +771 -0
- data/test/fixtures/xml/library/tracks-p23.xml +765 -0
- data/test/fixtures/xml/library/tracks-p24.xml +783 -0
- data/test/fixtures/xml/library/tracks-p25.xml +777 -0
- data/test/fixtures/xml/library/tracks-p26.xml +777 -0
- data/test/fixtures/xml/library/tracks-p27.xml +756 -0
- data/test/fixtures/xml/library/tracks-p28.xml +771 -0
- data/test/fixtures/xml/library/tracks-p29.xml +753 -0
- data/test/fixtures/xml/library/tracks-p3.xml +771 -0
- data/test/fixtures/xml/library/tracks-p30.xml +780 -0
- data/test/fixtures/xml/library/tracks-p31.xml +753 -0
- data/test/fixtures/xml/library/tracks-p32.xml +771 -0
- data/test/fixtures/xml/library/tracks-p33.xml +762 -0
- data/test/fixtures/xml/library/tracks-p34.xml +538 -0
- data/test/fixtures/xml/library/tracks-p4.xml +792 -0
- data/test/fixtures/xml/library/tracks-p5.xml +780 -0
- data/test/fixtures/xml/library/tracks-p6.xml +789 -0
- data/test/fixtures/xml/library/tracks-p7.xml +789 -0
- data/test/fixtures/xml/library/tracks-p8.xml +780 -0
- data/test/fixtures/xml/library/tracks-p9.xml +774 -0
- data/test/fixtures/xml/tag/similar.xml +254 -0
- data/test/fixtures/xml/tag/topalbums.xml +805 -0
- data/test/fixtures/xml/tag/topartists.xml +605 -0
- data/test/fixtures/xml/tag/toptags.xml +1254 -0
- data/test/fixtures/xml/tag/toptracks.xml +852 -0
- data/test/fixtures/xml/track/fans.xml +34 -0
- data/test/fixtures/xml/track/info.xml +53 -0
- data/test/fixtures/xml/track/toptags.xml +504 -0
- data/test/fixtures/xml/user/events.xml +401 -0
- data/test/fixtures/xml/user/friends.xml +30 -0
- data/test/fixtures/xml/user/lovedtracks.xml +678 -0
- data/test/fixtures/xml/user/neighbours.xml +23 -0
- data/test/fixtures/xml/user/playlists.xml +61 -0
- data/test/fixtures/xml/user/profile.xml +12 -0
- data/test/fixtures/xml/user/recentbannedtracks.xml +24 -0
- data/test/fixtures/xml/user/recentlovedtracks.xml +24 -0
- data/test/fixtures/xml/user/recenttracks.xml +124 -0
- data/test/fixtures/xml/user/systemrecs.xml +18 -0
- data/test/fixtures/xml/user/topalbums.xml +61 -0
- data/test/fixtures/xml/user/topartists.xml +41 -0
- data/test/fixtures/xml/user/toptags.xml +44 -0
- data/test/fixtures/xml/user/toptracks.xml +65 -0
- data/test/fixtures/xml/user/weeklyalbumchart.xml +256 -0
- data/test/fixtures/xml/user/weeklyartistchart.xml +220 -0
- data/test/fixtures/xml/user/weeklytrackchart.xml +746 -0
- data/test/fixtures/xml/venue/events.xml +151 -0
- data/test/fixtures/xml/venue/venue.xml +16 -0
- data/test/mocks/rest.rb +212 -0
- data/test/spec_helper.rb +7 -0
- data/test/test_helper.rb +20 -0
- data/test/unit/album_spec.rb +52 -0
- data/test/unit/artist_spec.rb +130 -0
- data/test/unit/auth_spec.rb +36 -0
- data/test/unit/event_spec.rb +109 -0
- data/test/unit/geo_spec.rb +148 -0
- data/test/unit/library_spec.rb +133 -0
- data/test/unit/playing_test.rb +53 -0
- data/test/unit/playlist_spec.rb +25 -0
- data/test/unit/radio_spec.rb +22 -0
- data/test/unit/scrobble_spec.rb +55 -0
- data/test/unit/scrobble_test.rb +69 -0
- data/test/unit/simpleauth_test.rb +45 -0
- data/test/unit/tag_spec.rb +101 -0
- data/test/unit/track_spec.rb +95 -0
- data/test/unit/user_spec.rb +264 -0
- data/test/unit/venue_spec.rb +104 -0
- metadata +265 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe Scrobbler::Artist do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@artist = Scrobbler::Artist.new('Metallica')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'should know its name' do
|
|
10
|
+
@artist.name.should eql('Metallica')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should implement all methods from the Last.fm 2.0 API' do
|
|
14
|
+
@artist.should respond_to(:add_tags)
|
|
15
|
+
@artist.should respond_to(:events)
|
|
16
|
+
@artist.should respond_to(:images)
|
|
17
|
+
@artist.should respond_to(:load_info)
|
|
18
|
+
@artist.should respond_to(:shouts)
|
|
19
|
+
@artist.should respond_to(:similar)
|
|
20
|
+
@artist.should respond_to(:tags)
|
|
21
|
+
@artist.should respond_to(:top_albums)
|
|
22
|
+
@artist.should respond_to(:top_fans)
|
|
23
|
+
@artist.should respond_to(:top_tags)
|
|
24
|
+
@artist.should respond_to(:top_tracks)
|
|
25
|
+
@artist.should respond_to(:remove_tag)
|
|
26
|
+
@artist.should respond_to(:search)
|
|
27
|
+
@artist.should respond_to(:share)
|
|
28
|
+
@artist.should respond_to(:shout)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should be able to add tags'
|
|
32
|
+
|
|
33
|
+
it 'should be able to load a list of upcoming events'
|
|
34
|
+
|
|
35
|
+
it 'should be able to get images for this artist in a variety of sizes'
|
|
36
|
+
|
|
37
|
+
it 'should be able to load the artist info' do
|
|
38
|
+
@artist.load_info
|
|
39
|
+
@artist.mbid.should eql('bfcc6d75-a6a5-4bc6-8282-47aec8531818')
|
|
40
|
+
@artist.url.should eql('http://www.last.fm/music/Cher')
|
|
41
|
+
@artist.image(:small).should eql('http://userserve-ak.last.fm/serve/34/9137697.jpg')
|
|
42
|
+
@artist.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/9137697.jpg')
|
|
43
|
+
@artist.image(:large).should eql('http://userserve-ak.last.fm/serve/126/9137697.jpg')
|
|
44
|
+
@artist.streamable.should be_true
|
|
45
|
+
@artist.listeners.should eql(383775)
|
|
46
|
+
@artist.playcount.should eql(3141583)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'should be able to get shouts for this artist'
|
|
50
|
+
|
|
51
|
+
it 'should be able to get all the artists similar to this artist' do
|
|
52
|
+
@artist.similar.should be_kind_of(Array)
|
|
53
|
+
@artist.similar.should have(100).items
|
|
54
|
+
@artist.similar.first.should be_kind_of(Scrobbler::Artist)
|
|
55
|
+
@artist.similar.first.name.should eql('Megadeth')
|
|
56
|
+
@artist.similar.first.mbid.should eql('a9044915-8be3-4c7e-b11f-9e2d2ea0a91e')
|
|
57
|
+
@artist.similar.first.match.should eql(100)
|
|
58
|
+
@artist.similar.first.url.should eql('www.last.fm/music/Megadeth')
|
|
59
|
+
@artist.similar.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/8422011.jpg')
|
|
60
|
+
@artist.similar.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/8422011.jpg')
|
|
61
|
+
@artist.similar.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/8422011.jpg')
|
|
62
|
+
@artist.similar.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/8422011.jpg')
|
|
63
|
+
@artist.similar.first.streamable.should be_true
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'should be able to get the tags applied by a user'
|
|
67
|
+
|
|
68
|
+
it 'should be able to get the top albums' do
|
|
69
|
+
@artist.top_albums.should be_kind_of(Array)
|
|
70
|
+
@artist.top_albums.should have(4).items
|
|
71
|
+
@artist.top_albums.first.should be_kind_of(Scrobbler::Album)
|
|
72
|
+
@artist.top_albums.first.name.should eql('Master of Puppets')
|
|
73
|
+
@artist.top_albums.first.playcount.should eql(1165854)
|
|
74
|
+
@artist.top_albums.first.mbid.should eql('fed37cfc-2a6d-4569-9ac0-501a7c7598eb')
|
|
75
|
+
@artist.top_albums.first.url.should eql('http://www.last.fm/music/Metallica/Master+of+Puppets')
|
|
76
|
+
@artist.top_albums.first.artist.should be_kind_of(Scrobbler::Artist)
|
|
77
|
+
@artist.top_albums.first.artist.name.should eql('Metallica')
|
|
78
|
+
@artist.top_albums.first.artist.mbid.should eql('65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab')
|
|
79
|
+
@artist.top_albums.first.artist.url.should eql('http://www.last.fm/music/Metallica')
|
|
80
|
+
@artist.top_albums.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/8622967.jpg')
|
|
81
|
+
@artist.top_albums.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/8622967.jpg')
|
|
82
|
+
@artist.top_albums.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/8622967.jpg')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'should be able to get the top fans' do
|
|
86
|
+
@artist.top_fans.should be_kind_of(Array)
|
|
87
|
+
@artist.top_fans.should have(6).items
|
|
88
|
+
@artist.top_fans.first.should be_kind_of(Scrobbler::User)
|
|
89
|
+
@artist.top_fans.first.username.should eql('Slide15')
|
|
90
|
+
@artist.top_fans.first.url.should eql('http://www.last.fm/user/Slide15')
|
|
91
|
+
@artist.top_fans.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/4477633.jpg')
|
|
92
|
+
@artist.top_fans.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/4477633.jpg')
|
|
93
|
+
@artist.top_fans.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/4477633.jpg')
|
|
94
|
+
@artist.top_fans.first.weight.should eql(265440672)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'should be able to get the top tags' do
|
|
98
|
+
@artist.top_tags.should be_kind_of(Array)
|
|
99
|
+
@artist.top_tags.should have(3).items
|
|
100
|
+
@artist.top_tags.first.should be_kind_of(Scrobbler::Tag)
|
|
101
|
+
@artist.top_tags.first.name.should eql('metal')
|
|
102
|
+
@artist.top_tags.first.count.should eql(100)
|
|
103
|
+
@artist.top_tags.first.url.should eql('http://www.last.fm/tag/metal')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'should be able to get the top tracks' do
|
|
107
|
+
@artist.top_tracks.should be_kind_of(Array)
|
|
108
|
+
@artist.top_tracks.should have(4).items
|
|
109
|
+
@artist.top_tracks.first.should be_kind_of(Scrobbler::Track)
|
|
110
|
+
@artist.top_tracks.first.rank.should eql(1)
|
|
111
|
+
@artist.top_tracks.first.name.should eql('Nothing Else Matters')
|
|
112
|
+
@artist.top_tracks.first.playcount.should eql(537704)
|
|
113
|
+
@artist.top_tracks.first.mbid.should eql('')
|
|
114
|
+
@artist.top_tracks.first.url.should eql('http://www.last.fm/music/Metallica/_/Nothing+Else+Matters')
|
|
115
|
+
@artist.top_tracks.first.artist.should be_kind_of(Scrobbler::Artist)
|
|
116
|
+
@artist.top_tracks.first.artist.name.should eql('Metallica')
|
|
117
|
+
@artist.top_tracks.first.artist.url.should eql('http://www.last.fm/music/Metallica')
|
|
118
|
+
@artist.top_tracks.first.artist.mbid.should eql('65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab')
|
|
119
|
+
@artist.top_tracks.first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/8622943.jpg')
|
|
120
|
+
@artist.top_tracks.first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/8622943.jpg')
|
|
121
|
+
@artist.top_tracks.first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/8622943.jpg')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should be able to remove tags'
|
|
125
|
+
|
|
126
|
+
it 'should be able to search for an artist'
|
|
127
|
+
|
|
128
|
+
it 'should be able to leave a shout'
|
|
129
|
+
|
|
130
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe Scrobbler::Auth do
|
|
4
|
+
|
|
5
|
+
before(:all) do
|
|
6
|
+
@auth = Scrobbler::Auth.new('user')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'should implement all methods from the Last.fm 2.0 API' do
|
|
10
|
+
@auth.should respond_to(:mobile_session)
|
|
11
|
+
@auth.should respond_to(:session)
|
|
12
|
+
@auth.should respond_to(:token)
|
|
13
|
+
@auth.should respond_to(:websession)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should be able to start a mobile session'
|
|
17
|
+
|
|
18
|
+
it 'should be able to fetch a session key' do
|
|
19
|
+
session = @auth.session('test123token')
|
|
20
|
+
session.should be_kind_of(Scrobbler::Session)
|
|
21
|
+
session.name.should eql('MyLastFMUsername')
|
|
22
|
+
session.key.should eql('d580d57f32848f5dcf574d1ce18d78b2')
|
|
23
|
+
session.subscriber.should be_false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should be able to fetch a request token' do
|
|
27
|
+
@auth.token.should eql('0e6af5cd2fff6b314994af5b0c58ecc1')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should be able to start a web session'
|
|
31
|
+
|
|
32
|
+
it 'should be able to get a url for authenticate this service' do
|
|
33
|
+
@auth.url.should eql('http://www.last.fm/api/auth/?api_key=foo123&token=0e6af5cd2fff6b314994af5b0c58ecc1')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe Scrobbler::Event do
|
|
4
|
+
|
|
5
|
+
before(:all) do
|
|
6
|
+
@auth = Scrobbler::Auth.new('user')
|
|
7
|
+
@session = @auth.session('test123token')
|
|
8
|
+
@event = Scrobbler::Event.new(328799)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should know its id' do
|
|
12
|
+
@event.id.should eql(328799)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'should implement the Last.fm 2.0 API method' do
|
|
16
|
+
[:attend, :attendees, :load_info, :shouts, :share, :shout].each do |method_name|
|
|
17
|
+
it "'#{method_name}'" do
|
|
18
|
+
@event.should respond_to(method_name)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should set user\'s status for attendace' do
|
|
24
|
+
@event.attend(@session,1)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'events attendees' do
|
|
28
|
+
before do
|
|
29
|
+
@attendees = ["ikea", "Schrollum", "Alpha1", "japps", "Gomhen", "NTG"]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should have 6 attendees' do
|
|
33
|
+
@event.attendees.size.should == 6
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should know it's attendees names" do
|
|
37
|
+
@event.attendees.collect(&:name).should == @attendees
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe 'first attendee' do
|
|
41
|
+
before do
|
|
42
|
+
@attendee = @event.attendees.first
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should know it's realname" do
|
|
46
|
+
@attendee.realname.should == 'Jane'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should know it's small image" do
|
|
50
|
+
@attendee.image(:small).should == 'http://userserve-ak.last.fm/serve/34/17805805.jpg'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should know it's medium image" do
|
|
54
|
+
@attendee.image(:medium).should == 'http://userserve-ak.last.fm/serve/64/17805805.jpg'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should know it's large image" do
|
|
58
|
+
@attendee.image(:large).should eql('http://userserve-ak.last.fm/serve/126/17805805.jpg')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should know it's large url" do
|
|
62
|
+
@attendee.url.should == 'http://www.last.fm/user/ikea'
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'should be able to load its info' do
|
|
68
|
+
@event.load_info
|
|
69
|
+
@event.title.should eql('Philip Glass')
|
|
70
|
+
@event.artists.should be_kind_of(Array)
|
|
71
|
+
@event.artists.first.should be_kind_of(Scrobbler::Artist)
|
|
72
|
+
@event.artists.first.name.should eql('Philip Glass')
|
|
73
|
+
@event.headliner.should be_kind_of(Scrobbler::Artist)
|
|
74
|
+
@event.headliner.name.should eql('Philip Glass')
|
|
75
|
+
@event.venue.should be_kind_of(Scrobbler::Venue)
|
|
76
|
+
@event.venue.name.should eql('Barbican Centre')
|
|
77
|
+
@event.venue.city.should eql('London')
|
|
78
|
+
@event.venue.country.should eql('United Kingdom')
|
|
79
|
+
@event.venue.street.should eql('Silk Street')
|
|
80
|
+
@event.venue.postalcode.should eql('EC2Y 8DS')
|
|
81
|
+
@event.venue.geo_lat.should eql('51.519972')
|
|
82
|
+
@event.venue.geo_long.should eql('-0.09334')
|
|
83
|
+
@event.venue.url.should eql('http://www.last.fm/venue/8777860')
|
|
84
|
+
@event.start_date.should eql(Time.mktime(2008, 6, 12, 19, 30, 00))
|
|
85
|
+
@event.description.should eql('Nunc vulputate, ante vitae sollicitudin ullamcorper, velit eros ultricies libero.')
|
|
86
|
+
@event.image(:small).should eql('http://userserve-ak.last.fm/serve/34/320636.jpg')
|
|
87
|
+
@event.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/320636.jpg')
|
|
88
|
+
@event.image(:large).should eql('http://userserve-ak.last.fm/serve/126/320636.jpg')
|
|
89
|
+
@event.url.should eql('http://www.last.fm/event/328799')
|
|
90
|
+
@event.attendance.should eql(46)
|
|
91
|
+
@event.reviews.should eql(0)
|
|
92
|
+
@event.tag.should eql('lastfm:event=328799')
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'should be able to get its shouts' do
|
|
96
|
+
@event.shouts.should be_kind_of(Array)
|
|
97
|
+
@event.shouts.should have(6).items
|
|
98
|
+
@event.shouts.first.should be_kind_of(Scrobbler::Shout)
|
|
99
|
+
@event.shouts.first.body.should eql('test')
|
|
100
|
+
@event.shouts.first.author.should be_kind_of(Scrobbler::User)
|
|
101
|
+
@event.shouts.first.author.username.should eql('kaypey')
|
|
102
|
+
@event.shouts.first.date.should eql(Time.mktime(2009, 4, 28, 5, 35, 11))
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should be able to be shared'
|
|
106
|
+
|
|
107
|
+
it 'should be able to leave a shout'
|
|
108
|
+
|
|
109
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe Scrobbler::Geo do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@geo = Scrobbler::Geo.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe 'should implement the method' do
|
|
10
|
+
[:events,:top_tracks,:top_artists].each do |method_name|
|
|
11
|
+
it "'#{method_name}'" do
|
|
12
|
+
@geo.should respond_to(method_name)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe 'finding by location' do
|
|
18
|
+
before do
|
|
19
|
+
@event_titles = ['Will and The People','Son Of Dave','Surface Unsigned','Experimental Dental School']
|
|
20
|
+
@event_ids = [1025661,954053,1005964,909456]
|
|
21
|
+
@first_atrists_names = ['Will And The People','Carnations','Midwich Cuckoos','NO FLASH']
|
|
22
|
+
@first_headliner = 'Will And The People'
|
|
23
|
+
@top_artist_names = ['The Killers','Coldplay','Radiohead','Muse','Franz Ferdinand','U2']
|
|
24
|
+
@top_track_names = ['Use Somebody','Schwarz zu Blau','Sex on Fire','Alles Neu','Poker Face','Ayo Technology']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'events in manchester' do
|
|
28
|
+
before do
|
|
29
|
+
@events = @geo.events(:location => 'Manchester')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should find 4 events' do
|
|
33
|
+
@events.size.should eql(4)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should have the correct event id's" do
|
|
37
|
+
@events.collect(&:id).should eql(@event_ids)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should have the correct event titles' do
|
|
41
|
+
@events.collect(&:title).should eql(@event_titles)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe 'finding top artists in spain' do
|
|
46
|
+
before do
|
|
47
|
+
@top_artists = @geo.top_artists(:location => 'Spain')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should find 6 artists' do
|
|
51
|
+
@top_artists.size.should eql(6)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should have the correct artist names' do
|
|
55
|
+
@top_artists.collect(&:name).should eql(@top_artist_names)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe 'finding top tracks in germany' do
|
|
60
|
+
before do
|
|
61
|
+
@top_tracks = @geo.top_tracks(:location => 'Germany')
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'should find 6 top tracks' do
|
|
65
|
+
@top_tracks.size.should eql(6)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should have the correct top track names' do
|
|
69
|
+
@top_track_names.should eql(@top_tracks.collect(&:name))
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
describe 'finding by latitude and longitude' do
|
|
76
|
+
describe 'events in 40.71417 -74.00639' do
|
|
77
|
+
before do
|
|
78
|
+
@events = @geo.events(:lat => 40.71417, :long => -74.00639)
|
|
79
|
+
@event_ids = [1066470, 990602, 1062713, 1088394]
|
|
80
|
+
@event_titles = ["We Love Brasil", "Red Bank Jazz and Blues Festival", "Jazz For Young People", "The Paul Green School Of Rock"]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'should find 4 events' do
|
|
84
|
+
@events.size.should eql(4)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should have the correct event id's" do
|
|
88
|
+
@events.collect(&:id).should eql(@event_ids)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'should have the correct event titles' do
|
|
92
|
+
@events.collect(&:title).should eql(@event_titles)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe 'finding by distance' do
|
|
98
|
+
describe 'events within 15km' do
|
|
99
|
+
before do
|
|
100
|
+
@events = @geo.events(:distance => 15)
|
|
101
|
+
@event_ids = [926134, 1046018, 1070375, 805363]
|
|
102
|
+
@event_titles = ["Feast - Picnic by the Lake", "Bootleg Beatles", "The Lucid Dream", "Oasis"]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should find 4 events' do
|
|
106
|
+
@events.size.should eql(4)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "should have the correct event id's" do
|
|
110
|
+
@events.collect(&:id).should eql(@event_ids)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'should have the correct event titles' do
|
|
114
|
+
@events.collect(&:title).should eql(@event_titles)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
describe 'pagination' do
|
|
120
|
+
describe 'page two of events in manchester' do
|
|
121
|
+
before do
|
|
122
|
+
@page = @geo.events(:location => 'Manchester', :page => 2)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'should have 10 events' do
|
|
126
|
+
@page.size.should eql(10)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'should have the correct title for the first event' do
|
|
130
|
+
@page.first.title.should eql('New Bruises')
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe 'page three of events in manchester' do
|
|
135
|
+
before do
|
|
136
|
+
@page = @geo.events(:location => 'Manchester', :page => 3)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'should have 10 events' do
|
|
140
|
+
@page.size.should eql(10)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it 'should have the correct title for the first event' do
|
|
144
|
+
@page.first.title.should eql('Saving Aimee')
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe Scrobbler::Library do
|
|
4
|
+
|
|
5
|
+
before(:all) do
|
|
6
|
+
@library = Scrobbler::Library.new('xhochy')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'should know its username' do
|
|
10
|
+
@library.user.should be_kind_of(Scrobbler::User)
|
|
11
|
+
@library.user.name.should eql('xhochy')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should implement all methods from the Last.fm 2.0 API' do
|
|
15
|
+
@library.should respond_to(:add_album)
|
|
16
|
+
@library.should respond_to(:add_artist)
|
|
17
|
+
@library.should respond_to(:add_track)
|
|
18
|
+
@library.should respond_to(:albums)
|
|
19
|
+
@library.should respond_to(:artists)
|
|
20
|
+
@library.should respond_to(:tracks)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should be able to add an album'
|
|
24
|
+
|
|
25
|
+
it 'should be able to add an artist'
|
|
26
|
+
|
|
27
|
+
it 'should be able to add a track'
|
|
28
|
+
|
|
29
|
+
it 'should be able to get its albums' do
|
|
30
|
+
@library.should have(396).albums
|
|
31
|
+
first = @library.albums.first
|
|
32
|
+
first.should be_kind_of(Scrobbler::Album)
|
|
33
|
+
first.name.should eql('Silent Alarm')
|
|
34
|
+
first.playcount.should eql(1043)
|
|
35
|
+
first.tagcount.should eql(0)
|
|
36
|
+
first.mbid.should eql('7e18e965-cbc7-43d6-9042-daba4f984a34')
|
|
37
|
+
first.url.should eql('http://www.last.fm/music/Bloc+Party/Silent+Alarm')
|
|
38
|
+
first.artist.should be_kind_of(Scrobbler::Artist)
|
|
39
|
+
first.artist.name.should eql('Bloc Party')
|
|
40
|
+
first.artist.mbid.should eql('8c538f11-c141-4588-8ecb-931083524186')
|
|
41
|
+
first.artist.url.should eql('http://www.last.fm/music/Bloc+Party')
|
|
42
|
+
first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/9903887.jpg')
|
|
43
|
+
first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/9903887.jpg')
|
|
44
|
+
first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/9903887.jpg')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should be able to get its 30 most heard albums' do
|
|
48
|
+
@library.albums(:all => false, :limit => 30).should have(30).items
|
|
49
|
+
first = @library.albums(:all => false, :limit => 30).first
|
|
50
|
+
first.should be_kind_of(Scrobbler::Album)
|
|
51
|
+
first.name.should eql('Silent Alarm')
|
|
52
|
+
first.playcount.should eql(1043)
|
|
53
|
+
first.tagcount.should eql(0)
|
|
54
|
+
first.mbid.should eql('7e18e965-cbc7-43d6-9042-daba4f984a34')
|
|
55
|
+
first.url.should eql('http://www.last.fm/music/Bloc+Party/Silent+Alarm')
|
|
56
|
+
first.artist.should be_kind_of(Scrobbler::Artist)
|
|
57
|
+
first.artist.name.should eql('Bloc Party')
|
|
58
|
+
first.artist.mbid.should eql('8c538f11-c141-4588-8ecb-931083524186')
|
|
59
|
+
first.artist.url.should eql('http://www.last.fm/music/Bloc+Party')
|
|
60
|
+
first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/9903887.jpg')
|
|
61
|
+
first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/9903887.jpg')
|
|
62
|
+
first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/9903887.jpg')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should be able to get its artists' do
|
|
66
|
+
@library.should have(340).artists
|
|
67
|
+
first = @library.artists.first
|
|
68
|
+
first.should be_kind_of(Scrobbler::Artist)
|
|
69
|
+
first.name.should eql('Bloc Party')
|
|
70
|
+
first.playcount.should eql(2314)
|
|
71
|
+
first.tagcount.should eql(0)
|
|
72
|
+
first.mbid.should eql('8c538f11-c141-4588-8ecb-931083524186')
|
|
73
|
+
first.url.should eql('http://www.last.fm/music/Bloc+Party')
|
|
74
|
+
first.streamable.should be_true
|
|
75
|
+
first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/115908.jpg')
|
|
76
|
+
first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/115908.jpg')
|
|
77
|
+
first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/115908.jpg')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'should be able to get its 30 most heard artists' do
|
|
81
|
+
@library.artists(:all => false, :limit => 30).should have(30).items
|
|
82
|
+
first = @library.artists(:all => false, :limit => 30).first
|
|
83
|
+
first.should be_kind_of(Scrobbler::Artist)
|
|
84
|
+
first.name.should eql('Bloc Party')
|
|
85
|
+
first.playcount.should eql(2314)
|
|
86
|
+
first.tagcount.should eql(0)
|
|
87
|
+
first.mbid.should eql('8c538f11-c141-4588-8ecb-931083524186')
|
|
88
|
+
first.url.should eql('http://www.last.fm/music/Bloc+Party')
|
|
89
|
+
first.streamable.should be_true
|
|
90
|
+
first.image(:small).should eql('http://userserve-ak.last.fm/serve/34/115908.jpg')
|
|
91
|
+
first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64/115908.jpg')
|
|
92
|
+
first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/115908.jpg')
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'should be able to get its tracks' do
|
|
96
|
+
@library.should have(1686).tracks
|
|
97
|
+
first = @library.tracks.first
|
|
98
|
+
first.should be_kind_of(Scrobbler::Track)
|
|
99
|
+
first.name.should eql('A-Punk')
|
|
100
|
+
first.playcount.should eql(185)
|
|
101
|
+
first.tagcount.should eql(0)
|
|
102
|
+
first.mbid.should eql('')
|
|
103
|
+
first.url.should eql('http://www.last.fm/music/Vampire+Weekend/_/A-Punk')
|
|
104
|
+
first.streamable.should be_false
|
|
105
|
+
first.artist.should be_kind_of(Scrobbler::Artist)
|
|
106
|
+
first.artist.name.should eql('Vampire Weekend')
|
|
107
|
+
first.artist.mbid.should eql('af37c51c-0790-4a29-b995-456f98a6b8c9')
|
|
108
|
+
first.artist.url.should eql('http://www.last.fm/music/Vampire+Weekend')
|
|
109
|
+
first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/10258165.jpg')
|
|
110
|
+
first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/10258165.jpg')
|
|
111
|
+
first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/10258165.jpg')
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'should be able to get its 30 most heard tracks' do
|
|
115
|
+
@library.tracks(:all => false, :limit => 30).should have(30).items
|
|
116
|
+
first = @library.tracks(:all => false, :limit => 30).first
|
|
117
|
+
first.should be_kind_of(Scrobbler::Track)
|
|
118
|
+
first.name.should eql('A-Punk')
|
|
119
|
+
first.playcount.should eql(185)
|
|
120
|
+
first.tagcount.should eql(0)
|
|
121
|
+
first.mbid.should eql('')
|
|
122
|
+
first.url.should eql('http://www.last.fm/music/Vampire+Weekend/_/A-Punk')
|
|
123
|
+
first.streamable.should be_false
|
|
124
|
+
first.artist.should be_kind_of(Scrobbler::Artist)
|
|
125
|
+
first.artist.name.should eql('Vampire Weekend')
|
|
126
|
+
first.artist.mbid.should eql('af37c51c-0790-4a29-b995-456f98a6b8c9')
|
|
127
|
+
first.artist.url.should eql('http://www.last.fm/music/Vampire+Weekend')
|
|
128
|
+
first.image(:small).should eql('http://userserve-ak.last.fm/serve/34s/10258165.jpg')
|
|
129
|
+
first.image(:medium).should eql('http://userserve-ak.last.fm/serve/64s/10258165.jpg')
|
|
130
|
+
first.image(:large).should eql('http://userserve-ak.last.fm/serve/126/10258165.jpg')
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
end
|