lastfm 1.3.0 → 1.4.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.
- data/README.rdoc +24 -11
- data/VERSION +1 -1
- data/lib/lastfm.rb +25 -15
- data/lib/lastfm/method_category/artist.rb +9 -0
- data/lib/lastfm/method_category/event.rb +9 -0
- data/lib/lastfm/method_category/tag.rb +9 -0
- data/lib/lastfm/method_category/user.rb +34 -17
- data/spec/fixtures/album_get_info.xml +168 -157
- data/spec/fixtures/artist_get_events.xml +13 -13
- data/spec/fixtures/artist_get_info.xml +93 -93
- data/spec/fixtures/artist_get_similar.xml +12 -0
- data/spec/fixtures/artist_get_tags.xml +13 -0
- data/spec/fixtures/event_get_info.xml +39 -0
- data/spec/fixtures/geo_get_events.xml +4 -4
- data/spec/fixtures/library_get_artists.xml +1 -0
- data/spec/fixtures/library_get_tracks.xml +15 -14
- data/spec/fixtures/ng.xml +2 -1
- data/spec/fixtures/ok.xml +87 -102
- data/spec/fixtures/tag_get_top_artists.xml +60 -0
- data/spec/fixtures/track_get_correction.xml +2 -1
- data/spec/fixtures/track_get_info.xml +47 -53
- data/spec/fixtures/track_get_info_force_array.xml +28 -31
- data/spec/fixtures/track_get_similar.xml +75 -5078
- data/spec/fixtures/track_get_tags.xml +10 -10
- data/spec/fixtures/track_get_top_fans.xml +23 -26
- data/spec/fixtures/track_get_top_tags.xml +13 -13
- data/spec/fixtures/track_search.xml +31 -33
- data/spec/fixtures/user_get_friends.xml +2 -1
- data/spec/fixtures/user_get_info.xml +2 -1
- data/spec/fixtures/user_get_loved_tracks.xml +23 -22
- data/spec/fixtures/user_get_neighbours.xml +54 -502
- data/spec/fixtures/user_get_personal_tags.xml +29 -0
- data/spec/fixtures/user_get_personal_tags_albums.xml +21 -0
- data/spec/fixtures/user_get_personal_tags_artists.xml +62 -0
- data/spec/fixtures/user_get_personal_tags_tracks.xml +87 -0
- data/spec/fixtures/user_get_recent_tracks.xml +2 -1
- data/spec/fixtures/user_get_top_albums.xml +22 -22
- data/spec/fixtures/user_get_top_artists.xml +22 -22
- data/spec/fixtures/user_get_top_tags.xml +30 -0
- data/spec/fixtures/user_get_top_tracks.xml +24 -23
- data/spec/lastfm_spec.rb +33 -516
- data/spec/method_specs/album_spec.rb +30 -0
- data/spec/method_specs/artist_spec.rb +79 -0
- data/spec/method_specs/event_spec.rb +17 -0
- data/spec/method_specs/geo_spec.rb +33 -0
- data/spec/method_specs/library_spec.rb +37 -0
- data/spec/method_specs/tag_spec.rb +25 -0
- data/spec/method_specs/track_spec.rb +224 -0
- data/spec/method_specs/user_spec.rb +214 -0
- data/spec/response_spec.rb +4 -4
- data/spec/spec_helper.rb +15 -0
- data/spec/util_spec.rb +4 -4
- metadata +34 -15
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<lfm status="ok">
|
|
3
|
+
<taggings user="RJ" tag="rock" page="1" perPage="50" totalPages="1" total="14">
|
|
4
|
+
<artists>
|
|
5
|
+
<artist>
|
|
6
|
+
<name>Afghan Whigs</name>
|
|
7
|
+
<mbid/>
|
|
8
|
+
<url>http://www.last.fm/music/Afghan+Whigs</url>
|
|
9
|
+
<streamable>1</streamable>
|
|
10
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/65473.jpg</image>
|
|
11
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/65473.jpg</image>
|
|
12
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/65473.jpg</image>
|
|
13
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/65473.jpg</image>
|
|
14
|
+
<image size="mega">http://userserve-ak.last.fm/serve/_/65473/Afghan+Whigs.jpg</image>
|
|
15
|
+
</artist>
|
|
16
|
+
<artist>
|
|
17
|
+
<name>Jeff The Brotherhood</name>
|
|
18
|
+
<mbid>51b13b20-dc03-4d51-8c6d-f3b0c52476a6</mbid>
|
|
19
|
+
<url>http://www.last.fm/music/Jeff+The+Brotherhood</url>
|
|
20
|
+
<streamable>0</streamable>
|
|
21
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/42786999.jpg</image>
|
|
22
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/42786999.jpg</image>
|
|
23
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/42786999.jpg</image>
|
|
24
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/42786999.jpg</image>
|
|
25
|
+
<image size="mega">http://userserve-ak.last.fm/serve/500/42786999/Jeff+The+Brotherhood+JTBKAHANtext.jpg</image>
|
|
26
|
+
</artist>
|
|
27
|
+
</artists>
|
|
28
|
+
</taggings>
|
|
29
|
+
</lfm>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<lfm status="ok">
|
|
3
|
+
<taggings user="RJ" tag="hip-hop" page="1" perPage="50" totalPages="1" total="1">
|
|
4
|
+
<albums>
|
|
5
|
+
<album>
|
|
6
|
+
<name>DJ Bizkid Presents: The Best of Atmosphere</name>
|
|
7
|
+
<mbid>d7bc8315-a032-435b-a551-ec39a3998443</mbid>
|
|
8
|
+
<url>http://www.last.fm/music/Atmosphere/DJ+Bizkid+Presents%3A+The+Best+of+Atmosphere</url>
|
|
9
|
+
<artist>
|
|
10
|
+
<name>Atmosphere</name>
|
|
11
|
+
<mbid>ef954679-5ee7-4016-acef-7ac71f2fa3d8</mbid>
|
|
12
|
+
<url>http://www.last.fm/music/Atmosphere</url>
|
|
13
|
+
</artist>
|
|
14
|
+
<image size="small">http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_medium.png</image>
|
|
15
|
+
<image size="medium">http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_medium.png</image>
|
|
16
|
+
<image size="large">http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_medium.png</image>
|
|
17
|
+
<image size="extralarge">http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_medium.png</image>
|
|
18
|
+
</album>
|
|
19
|
+
</albums>
|
|
20
|
+
</taggings>
|
|
21
|
+
</lfm>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<lfm status="ok">
|
|
3
|
+
<taggings user="RJ" tag="rock" page="1" perPage="50" totalPages="1" total="5">
|
|
4
|
+
<artists>
|
|
5
|
+
<artist>
|
|
6
|
+
<name>Afghan Whigs</name>
|
|
7
|
+
<mbid/>
|
|
8
|
+
<url>http://www.last.fm/music/Afghan+Whigs</url>
|
|
9
|
+
<streamable>1</streamable>
|
|
10
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/65473.jpg</image>
|
|
11
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/65473.jpg</image>
|
|
12
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/65473.jpg</image>
|
|
13
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/65473.jpg</image>
|
|
14
|
+
<image size="mega">http://userserve-ak.last.fm/serve/_/65473/Afghan+Whigs.jpg</image>
|
|
15
|
+
</artist>
|
|
16
|
+
<artist>
|
|
17
|
+
<name>Jeff The Brotherhood</name>
|
|
18
|
+
<mbid>51b13b20-dc03-4d51-8c6d-f3b0c52476a6</mbid>
|
|
19
|
+
<url>http://www.last.fm/music/Jeff+The+Brotherhood</url>
|
|
20
|
+
<streamable>0</streamable>
|
|
21
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/42786999.jpg</image>
|
|
22
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/42786999.jpg</image>
|
|
23
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/42786999.jpg</image>
|
|
24
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/42786999.jpg</image>
|
|
25
|
+
<image size="mega">http://userserve-ak.last.fm/serve/500/42786999/Jeff+The+Brotherhood+JTBKAHANtext.jpg</image>
|
|
26
|
+
</artist>
|
|
27
|
+
<artist>
|
|
28
|
+
<name>Morphine</name>
|
|
29
|
+
<mbid>42689657-cbec-4f66-a9ed-80f939ea23ed</mbid>
|
|
30
|
+
<url>http://www.last.fm/music/Morphine</url>
|
|
31
|
+
<streamable>1</streamable>
|
|
32
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/37674353.jpg</image>
|
|
33
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/37674353.jpg</image>
|
|
34
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/37674353.jpg</image>
|
|
35
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/37674353.jpg</image>
|
|
36
|
+
<image size="mega">http://userserve-ak.last.fm/serve/500/37674353/Morphine.jpg</image>
|
|
37
|
+
</artist>
|
|
38
|
+
<artist>
|
|
39
|
+
<name>John Hammond</name>
|
|
40
|
+
<mbid>d83e599c-2d5a-44ec-b727-587e1455b1b5</mbid>
|
|
41
|
+
<url>http://www.last.fm/music/John+Hammond</url>
|
|
42
|
+
<streamable>1</streamable>
|
|
43
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/22931645.jpg</image>
|
|
44
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/22931645.jpg</image>
|
|
45
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/22931645.jpg</image>
|
|
46
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/22931645.jpg</image>
|
|
47
|
+
<image size="mega">http://userserve-ak.last.fm/serve/500/22931645/John+Hammond+jhjr.jpg</image>
|
|
48
|
+
</artist>
|
|
49
|
+
<artist>
|
|
50
|
+
<name>G3</name>
|
|
51
|
+
<mbid>ec676b1e-9586-479d-926b-25face38e87f</mbid>
|
|
52
|
+
<url>http://www.last.fm/music/G3</url>
|
|
53
|
+
<streamable>1</streamable>
|
|
54
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/45853299.png</image>
|
|
55
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64/45853299.png</image>
|
|
56
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/45853299.png</image>
|
|
57
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/252/45853299.png</image>
|
|
58
|
+
<image size="mega">http://userserve-ak.last.fm/serve/500/45853299/G3.png</image>
|
|
59
|
+
</artist>
|
|
60
|
+
</artists>
|
|
61
|
+
</taggings>
|
|
62
|
+
</lfm>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<lfm status="ok">
|
|
3
|
+
<taggings user="RJ" tag="jazz" page="1" perPage="50" totalPages="1" total="5">
|
|
4
|
+
<tracks>
|
|
5
|
+
<track>
|
|
6
|
+
<name>Come Together</name>
|
|
7
|
+
<duration>316</duration>
|
|
8
|
+
<mbid/>
|
|
9
|
+
<url>http://www.last.fm/music/Brian+Bromberg/_/Come+Together</url>
|
|
10
|
+
<streamable fulltrack="0">1</streamable>
|
|
11
|
+
<artist>
|
|
12
|
+
<name>Brian Bromberg</name>
|
|
13
|
+
<mbid>69ed9582-7b72-4b7b-8e30-816c06e5f89b</mbid>
|
|
14
|
+
<url>http://www.last.fm/music/Brian+Bromberg</url>
|
|
15
|
+
</artist>
|
|
16
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/33026873.jpg</image>
|
|
17
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64s/33026873.jpg</image>
|
|
18
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/33026873.jpg</image>
|
|
19
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/33026873.jpg</image>
|
|
20
|
+
</track>
|
|
21
|
+
<track>
|
|
22
|
+
<name>Dione</name>
|
|
23
|
+
<duration>450</duration>
|
|
24
|
+
<mbid/>
|
|
25
|
+
<url>http://www.last.fm/music/Calum+Marshall/_/Dione</url>
|
|
26
|
+
<streamable fulltrack="1">1</streamable>
|
|
27
|
+
<artist>
|
|
28
|
+
<name>Calum Marshall</name>
|
|
29
|
+
<mbid/>
|
|
30
|
+
<url>http://www.last.fm/music/Calum+Marshall</url>
|
|
31
|
+
</artist>
|
|
32
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/34604249.jpg</image>
|
|
33
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64s/34604249.jpg</image>
|
|
34
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/34604249.jpg</image>
|
|
35
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/34604249.jpg</image>
|
|
36
|
+
</track>
|
|
37
|
+
<track>
|
|
38
|
+
<name>Living Hope</name>
|
|
39
|
+
<duration>306</duration>
|
|
40
|
+
<mbid/>
|
|
41
|
+
<url>http://www.last.fm/music/Dennis+Chambers/_/Living+Hope</url>
|
|
42
|
+
<streamable fulltrack="0">1</streamable>
|
|
43
|
+
<artist>
|
|
44
|
+
<name>Dennis Chambers</name>
|
|
45
|
+
<mbid>919553a3-2c2f-4b2e-b0ea-efe8e2573e9c</mbid>
|
|
46
|
+
<url>http://www.last.fm/music/Dennis+Chambers</url>
|
|
47
|
+
</artist>
|
|
48
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/33038159.jpg</image>
|
|
49
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64s/33038159.jpg</image>
|
|
50
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/33038159.jpg</image>
|
|
51
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/33038159.jpg</image>
|
|
52
|
+
</track>
|
|
53
|
+
<track>
|
|
54
|
+
<name>Morning Dance</name>
|
|
55
|
+
<duration>256</duration>
|
|
56
|
+
<mbid/>
|
|
57
|
+
<url>http://www.last.fm/music/Spyro+Gyra/_/Morning+Dance</url>
|
|
58
|
+
<streamable fulltrack="0">1</streamable>
|
|
59
|
+
<artist>
|
|
60
|
+
<name>Spyro Gyra</name>
|
|
61
|
+
<mbid>9a7c8025-1af8-42cd-8df8-857220610bc5</mbid>
|
|
62
|
+
<url>http://www.last.fm/music/Spyro+Gyra</url>
|
|
63
|
+
</artist>
|
|
64
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/32950969.jpg</image>
|
|
65
|
+
<image size="medium">http://userserve-ak.last.fm/serve/64s/32950969.jpg</image>
|
|
66
|
+
<image size="large">http://userserve-ak.last.fm/serve/126/32950969.jpg</image>
|
|
67
|
+
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/32950969.jpg</image>
|
|
68
|
+
</track>
|
|
69
|
+
<track>
|
|
70
|
+
<name>Walk on By</name>
|
|
71
|
+
<duration>290</duration>
|
|
72
|
+
<mbid/>
|
|
73
|
+
<url>http://www.last.fm/music/Peter+White/_/Walk+on+By</url>
|
|
74
|
+
<streamable fulltrack="0">1</streamable>
|
|
75
|
+
<artist>
|
|
76
|
+
<name>Peter White</name>
|
|
77
|
+
<mbid>2833d222-f057-43a5-a90b-e44f0df63acb</mbid>
|
|
78
|
+
<url>http://www.last.fm/music/Peter+White</url>
|
|
79
|
+
</artist>
|
|
80
|
+
<image size="small">http://images.amazon.com/images/P/B0000516VZ.01._SCMZZZZZZZ_.jpg</image>
|
|
81
|
+
<image size="medium">http://images.amazon.com/images/P/B0000516VZ.01._SCMZZZZZZZ_.jpg</image>
|
|
82
|
+
<image size="large">http://images.amazon.com/images/P/B0000516VZ.01._SCMZZZZZZZ_.jpg</image>
|
|
83
|
+
<image size="extralarge">http://images.amazon.com/images/P/B0000516VZ.01._SCMZZZZZZZ_.jpg</image>
|
|
84
|
+
</track>
|
|
85
|
+
</tracks>
|
|
86
|
+
</taggings>
|
|
87
|
+
</lfm>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
1
2
|
<lfm status="ok">
|
|
2
3
|
<recenttracks user="RJ" page="1" perPage="10" totalPages="3019">
|
|
3
4
|
<track nowplaying="true">
|
|
@@ -20,4 +21,4 @@
|
|
|
20
21
|
<image size="extralarge">http://userserve-ak.last.fm/serve/300x300/8822309.jpg</image>
|
|
21
22
|
</track>
|
|
22
23
|
</recenttracks>
|
|
23
|
-
</lfm>
|
|
24
|
+
</lfm>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<lfm status="ok">
|
|
3
|
-
<topalbums user="test" type="overall">
|
|
3
|
+
<topalbums user="test" type="overall">
|
|
4
4
|
<album rank="1">
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
<name>The Wall</name>
|
|
6
|
+
<playcount>536</playcount>
|
|
7
|
+
<mbid>639f0d06-53bd-32a5-8f65-1db785743ab0</mbid>
|
|
8
|
+
<url>http://www.last.fm/music/Pink+Floyd/The+Wall</url>
|
|
9
|
+
<artist>
|
|
10
|
+
<name>Pink Floyd</name>
|
|
11
|
+
<mbid>83d91898-7763-47d7-b03b-b92132375c47</mbid>
|
|
12
|
+
<url>http://www.last.fm/music/Pink+Floyd</url>
|
|
13
|
+
</artist>
|
|
14
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/70211546.png</image>
|
|
15
15
|
</album>
|
|
16
16
|
<album rank="2">
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
<name>The Perfect Element, Part I</name>
|
|
18
|
+
<playcount>524</playcount>
|
|
19
|
+
<mbid>3039a1a9-a8d2-4560-81c7-b0af31f692b3</mbid>
|
|
20
|
+
<url>http://www.last.fm/music/Pain+Of+Salvation/The+Perfect+Element%2C+Part+I</url>
|
|
21
|
+
<artist>
|
|
22
|
+
<name>Pain of Salvation</name>
|
|
23
|
+
<mbid>f7c65346-9631-4220-9188-5e90baae58d5</mbid>
|
|
24
|
+
<url>http://www.last.fm/music/Pain+of+Salvation</url>
|
|
25
|
+
</artist>
|
|
26
|
+
<image size="small">http://userserve-ak.last.fm/serve/34s/66884232.png</image>
|
|
27
27
|
</album>
|
|
28
|
-
</topalbums>
|
|
28
|
+
</topalbums>
|
|
29
29
|
</lfm>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<lfm status="ok">
|
|
3
|
-
<topartists user="test" type="overall">
|
|
3
|
+
<topartists user="test" type="overall">
|
|
4
4
|
<artist rank="1">
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
<name>Pain of Salvation</name>
|
|
6
|
+
<playcount>1354</playcount>
|
|
7
|
+
<mbid>28503ab7-8bf2-4666-a7bd-2644bfc7cb1d</mbid>
|
|
8
|
+
<url>f7c65346-9631-4220-9188-5e90baae58d5</url>
|
|
9
|
+
<streamable>1</streamable>
|
|
10
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/53572699.png</image>
|
|
11
11
|
</artist>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
<artist rank="2">
|
|
13
|
+
<name>Opeth</name>
|
|
14
|
+
<playcount>1186</playcount>
|
|
15
|
+
<mbid>c14b4180-dc87-481e-b17a-64e4150f90f6</mbid>
|
|
16
|
+
<url>http://www.last.fm/music/Opeth</url>
|
|
17
|
+
<streamable>1</streamable>
|
|
18
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/66663756.png</image>
|
|
19
19
|
</artist>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
<artist rank="3">
|
|
21
|
+
<name>Nevermore</name>
|
|
22
|
+
<playcount>959</playcount>
|
|
23
|
+
<mbid>7d093650-89be-4108-842b-ba7f5367504b</mbid>
|
|
24
|
+
<url>http://www.last.fm/music/Nevermore</url>
|
|
25
|
+
<streamable>1</streamable>
|
|
26
|
+
<image size="small">http://userserve-ak.last.fm/serve/34/239749.jpg</image>
|
|
27
27
|
</artist>
|
|
28
|
-
</topartists>
|
|
28
|
+
</topartists>
|
|
29
29
|
</lfm>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<lfm status="ok">
|
|
3
|
+
<toptags user="RJ">
|
|
4
|
+
<tag>
|
|
5
|
+
<name>rock</name>
|
|
6
|
+
<count>19</count>
|
|
7
|
+
<url>www.last.fm/tag/rock</url>
|
|
8
|
+
</tag>
|
|
9
|
+
<tag>
|
|
10
|
+
<name>jazz</name>
|
|
11
|
+
<count>15</count>
|
|
12
|
+
<url>www.last.fm/tag/jazz</url>
|
|
13
|
+
</tag>
|
|
14
|
+
<tag>
|
|
15
|
+
<name>metal</name>
|
|
16
|
+
<count>10</count>
|
|
17
|
+
<url>www.last.fm/tag/metal</url>
|
|
18
|
+
</tag>
|
|
19
|
+
<tag>
|
|
20
|
+
<name>soul</name>
|
|
21
|
+
<count>8</count>
|
|
22
|
+
<url>www.last.fm/tag/soul</url>
|
|
23
|
+
</tag>
|
|
24
|
+
<tag>
|
|
25
|
+
<name>female vocalists</name>
|
|
26
|
+
<count>8</count>
|
|
27
|
+
<url>www.last.fm/tag/female%20vocalists</url>
|
|
28
|
+
</tag>
|
|
29
|
+
</toptags>
|
|
30
|
+
</lfm>
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<lfm status="ok">
|
|
3
|
-
<toptracks user="skr" type="7day" page="1" perPage="50" totalPages="6" total="271">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<artist>
|
|
3
|
+
<toptracks user="skr" type="7day" page="1" perPage="50" totalPages="6" total="271">
|
|
4
|
+
<track rank="1">
|
|
5
|
+
<name>No Light, No Light (TV On The Radio Remix)</name>
|
|
6
|
+
<duration/>
|
|
7
|
+
<playcount>5</playcount>
|
|
8
|
+
<mbid/>
|
|
9
|
+
<url>http://www.last.fm/music/Florence%2B%252B%2Bthe%2BMachine/_/No+Light%2C+No+Light+%28TV+On+The+Radio+Remix%29</url>
|
|
10
|
+
<streamable fulltrack="0">0</streamable>
|
|
11
|
+
<artist>
|
|
13
12
|
<name>Florence + the Machine</name>
|
|
14
13
|
<mbid>5fee3020-513b-48c2-b1f7-4681b01db0c6</mbid>
|
|
15
14
|
<url>http://www.last.fm/music/Florence%2B%252B%2Bthe%2BMachine</url>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
</artist>
|
|
16
|
+
</track>
|
|
17
|
+
<track rank="2">
|
|
18
|
+
<name>Backwords (Porcelain Raft cover)</name>
|
|
19
|
+
<duration>230</duration>
|
|
20
|
+
<playcount>5</playcount>
|
|
21
|
+
<mbid/>
|
|
22
|
+
<url>http://www.last.fm/music/Oupa%2B%2526%2BTony%2BCrow/_/Backwords+%28Porcelain+Raft+cover%29</url>
|
|
23
|
+
<streamable fulltrack="0">0</streamable>
|
|
24
|
+
<artist>
|
|
25
25
|
<name>Oupa & Tony Crow</name>
|
|
26
|
-
<mbid
|
|
26
|
+
<mbid/>
|
|
27
27
|
<url>http://www.last.fm/music/Oupa%2B%2526%2BTony%2BCrow</url>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
</artist>
|
|
29
|
+
</track>
|
|
30
|
+
</toptracks>
|
|
31
|
+
</lfm>
|
data/spec/lastfm_spec.rb
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
|
3
3
|
describe "Lastfm" do
|
|
4
|
-
before
|
|
5
|
-
@lastfm = Lastfm.new('xxx', 'yyy')
|
|
6
|
-
@response_xml = <<XML
|
|
7
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
8
|
-
<lfm status="ok">
|
|
9
|
-
<foo>bar</foo></lfm>
|
|
10
|
-
XML
|
|
11
|
-
@ok_response = make_response(<<XML)
|
|
12
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
13
|
-
<lfm status="ok">
|
|
14
|
-
</lfm>
|
|
15
|
-
XML
|
|
16
|
-
end
|
|
4
|
+
before { init_lastfm }
|
|
17
5
|
|
|
18
6
|
it 'should have base_uri' do
|
|
19
|
-
Lastfm.base_uri.should
|
|
7
|
+
Lastfm.base_uri.should == 'http://ws.audioscrobbler.com/2.0'
|
|
20
8
|
end
|
|
21
9
|
|
|
22
10
|
describe '.new' do
|
|
@@ -29,10 +17,10 @@ XML
|
|
|
29
17
|
it 'should post' do
|
|
30
18
|
mock_response = mock(HTTParty::Response)
|
|
31
19
|
@lastfm.class.should_receive(:post).with('/', :body => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
:foo => 'bar',
|
|
21
|
+
:method => 'xxx.yyy',
|
|
22
|
+
:api_key => 'xxx',
|
|
23
|
+
}).and_return(mock_response)
|
|
36
24
|
mock_response.should_receive(:body).and_return(@response_xml)
|
|
37
25
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, false, false)
|
|
38
26
|
end
|
|
@@ -40,11 +28,11 @@ XML
|
|
|
40
28
|
it 'should post with signature' do
|
|
41
29
|
mock_response = mock(HTTParty::Response)
|
|
42
30
|
@lastfm.class.should_receive(:post).with('/', :body => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
:foo => 'bar',
|
|
32
|
+
:method => 'xxx.yyy',
|
|
33
|
+
:api_key => 'xxx',
|
|
34
|
+
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyyyy'),
|
|
35
|
+
}).and_return(mock_response)
|
|
48
36
|
mock_response.should_receive(:body).and_return(@response_xml)
|
|
49
37
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, false)
|
|
50
38
|
end
|
|
@@ -53,12 +41,12 @@ XML
|
|
|
53
41
|
mock_response = mock(HTTParty::Response)
|
|
54
42
|
@lastfm.session = 'abcdef'
|
|
55
43
|
@lastfm.class.should_receive(:post).with('/', :body => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
44
|
+
:foo => 'bar',
|
|
45
|
+
:method => 'xxx.yyy',
|
|
46
|
+
:api_key => 'xxx',
|
|
47
|
+
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyskabcdefyyy'),
|
|
48
|
+
:sk => 'abcdef',
|
|
49
|
+
}).and_return(mock_response)
|
|
62
50
|
mock_response.should_receive(:body).and_return(@response_xml)
|
|
63
51
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :post, true, true)
|
|
64
52
|
end
|
|
@@ -77,11 +65,11 @@ XML
|
|
|
77
65
|
it 'should get with signature (request for authentication)' do
|
|
78
66
|
mock_response = mock(HTTParty::Response)
|
|
79
67
|
@lastfm.class.should_receive(:get).with('/', :query => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
:foo => 'bar',
|
|
69
|
+
:method => 'xxx.yyy',
|
|
70
|
+
:api_key => 'xxx',
|
|
71
|
+
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyyyy'),
|
|
72
|
+
}).and_return(mock_response)
|
|
85
73
|
mock_response.should_receive(:body).and_return(@response_xml)
|
|
86
74
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, false)
|
|
87
75
|
end
|
|
@@ -90,12 +78,12 @@ XML
|
|
|
90
78
|
mock_response = mock(HTTParty::Response)
|
|
91
79
|
@lastfm.session = 'abcdef'
|
|
92
80
|
@lastfm.class.should_receive(:get).with('/', :query => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
:foo => 'bar',
|
|
82
|
+
:method => 'xxx.yyy',
|
|
83
|
+
:api_key => 'xxx',
|
|
84
|
+
:api_sig => Digest::MD5.hexdigest('api_keyxxxfoobarmethodxxx.yyyskabcdefyyy'),
|
|
85
|
+
:sk => 'abcdef',
|
|
86
|
+
}).and_return(mock_response)
|
|
99
87
|
mock_response.should_receive(:body).and_return(@response_xml)
|
|
100
88
|
@lastfm.request('xxx.yyy', { :foo => 'bar' }, :get, true, true)
|
|
101
89
|
end
|
|
@@ -127,7 +115,7 @@ XML
|
|
|
127
115
|
<token>xxxyyyzzz</token></lfm>
|
|
128
116
|
XML
|
|
129
117
|
|
|
130
|
-
@lastfm.auth.get_token.should
|
|
118
|
+
@lastfm.auth.get_token.should == 'xxxyyyzzz'
|
|
131
119
|
end
|
|
132
120
|
|
|
133
121
|
it 'should get session' do
|
|
@@ -144,8 +132,8 @@ XML
|
|
|
144
132
|
</lfm>
|
|
145
133
|
XML
|
|
146
134
|
session = @lastfm.auth.get_session('xxxyyyzzz')
|
|
147
|
-
session['name'].should
|
|
148
|
-
session['key'].should
|
|
135
|
+
session['name'].should == 'MyLastFMUsername'
|
|
136
|
+
session['key'].should == 'zzzyyyxxx'
|
|
149
137
|
end
|
|
150
138
|
|
|
151
139
|
it 'should get mobile session' do
|
|
@@ -162,479 +150,8 @@ XML
|
|
|
162
150
|
</lfm>
|
|
163
151
|
XML
|
|
164
152
|
session = @lastfm.auth.get_mobile_session('xxxyyyzzz', 'xxxxAuthTokenxxxx')
|
|
165
|
-
session['name'].should
|
|
166
|
-
session['key'].should
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
describe '#track' do
|
|
171
|
-
it 'should return an instance of Lastfm::Track' do
|
|
172
|
-
@lastfm.track.should be_an_instance_of(Lastfm::MethodCategory::Track)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it 'should add tags' do
|
|
176
|
-
@lastfm.should_receive(:request).with('track.addTags', {
|
|
177
|
-
:artist => 'foo artist',
|
|
178
|
-
:track => 'foo track',
|
|
179
|
-
:tags => 'aaa,bbb,ccc'
|
|
180
|
-
}, :post, true, true).and_return(@ok_response)
|
|
181
|
-
|
|
182
|
-
@lastfm.track.add_tags('foo artist', 'foo track', 'aaa,bbb,ccc').should be_true
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
it 'should ban' do
|
|
186
|
-
@lastfm.should_receive(:request).with('track.ban', {
|
|
187
|
-
:artist => 'foo artist',
|
|
188
|
-
:track => 'foo track',
|
|
189
|
-
}, :post, true, true).and_return(@ok_response)
|
|
190
|
-
|
|
191
|
-
@lastfm.track.ban('foo artist', 'foo track').should be_true
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
it 'should get info' do
|
|
195
|
-
@lastfm.should_receive(:request).with('track.getInfo', {
|
|
196
|
-
:artist => 'Cher',
|
|
197
|
-
:track => 'Believe',
|
|
198
|
-
:username => 'youpy',
|
|
199
|
-
}).and_return(make_response('track_get_info'))
|
|
200
|
-
|
|
201
|
-
track = @lastfm.track.get_info('Cher', 'Believe', 'youpy')
|
|
202
|
-
track['name'].should eql('Believe')
|
|
203
|
-
track['album']['image'].size.should eql(4)
|
|
204
|
-
track['album']['image'].first['size'].should eql('small')
|
|
205
|
-
track['album']['image'].first['content'].should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
|
206
|
-
track['toptags']['tag'].size.should eql(5)
|
|
207
|
-
track['toptags']['tag'].first['name'].should eql('pop')
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
it 'should get correction' do
|
|
211
|
-
@lastfm.should_receive(:request).with('track.getCorrection', {
|
|
212
|
-
:artist => 'White Stripes',
|
|
213
|
-
:track => 'One More Cup of Coffee',
|
|
214
|
-
:username => 'wainekerr',
|
|
215
|
-
}).and_return(make_response('track_get_correction'))
|
|
216
|
-
|
|
217
|
-
correction = @lastfm.track.get_correction('White Stripes', 'One More Cup of Coffee', 'wainekerr')
|
|
218
|
-
correction['track']['name'].should eql('One More Cup of Coffee')
|
|
219
|
-
correction['track']['artist']['name'].should eql('The White Stripes')
|
|
220
|
-
correction['track']['url'].should eql('www.last.fm/music/The+White+Stripes/_/One+More+Cup+of+Coffee')
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
it 'should get xml with force array option' do
|
|
224
|
-
@lastfm.should_receive(:request).with('track.getInfo', {
|
|
225
|
-
:artist => 'Cher',
|
|
226
|
-
:track => 'Believe',
|
|
227
|
-
:username => 'youpy',
|
|
228
|
-
}).and_return(make_response('track_get_info_force_array'))
|
|
229
|
-
|
|
230
|
-
track = @lastfm.track.get_info('Cher', 'Believe', 'youpy')
|
|
231
|
-
track['album']['image'].size.should eql(1)
|
|
232
|
-
track['album']['image'].first['size'].should eql('small')
|
|
233
|
-
track['album']['image'].first['content'].should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
|
234
|
-
track['toptags']['tag'].size.should eql(1)
|
|
235
|
-
track['toptags']['tag'].first['name'].should eql('pop')
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
it 'should get similar' do
|
|
239
|
-
@lastfm.should_receive(:request).with('track.getSimilar', {
|
|
240
|
-
:artist => 'Cher',
|
|
241
|
-
:track => 'Believe',
|
|
242
|
-
}).and_return(make_response('track_get_similar'))
|
|
243
|
-
|
|
244
|
-
tracks = @lastfm.track.get_similar('Cher', 'Believe')
|
|
245
|
-
tracks.size.should eql(250)
|
|
246
|
-
tracks.first['name'].should eql('Strong Enough')
|
|
247
|
-
tracks.first['image'][1]['content'].should eql('http://userserve-ak.last.fm/serve/64s/8674593.jpg')
|
|
248
|
-
tracks[1]['image'][0]['content'].should eql('http://userserve-ak.last.fm/serve/34s/8674593.jpg')
|
|
249
|
-
end
|
|
250
|
-
|
|
251
|
-
it 'should get tags' do
|
|
252
|
-
@lastfm.should_receive(:request).with('track.getTags', {
|
|
253
|
-
:artist => 'foo artist',
|
|
254
|
-
:track => 'foo track',
|
|
255
|
-
}, :get, true, true).and_return(make_response('track_get_tags'))
|
|
256
|
-
|
|
257
|
-
tags = @lastfm.track.get_tags('foo artist', 'foo track')
|
|
258
|
-
tags.size.should eql(2)
|
|
259
|
-
tags[0]['name'].should eql('swedish')
|
|
260
|
-
tags[0]['url'].should eql('http://www.last.fm/tag/swedish')
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
it 'should get top fans' do
|
|
264
|
-
@lastfm.should_receive(:request).with('track.getTopFans', {
|
|
265
|
-
:artist => 'foo artist',
|
|
266
|
-
:track => 'foo track',
|
|
267
|
-
}).and_return(make_response('track_get_top_fans'))
|
|
268
|
-
|
|
269
|
-
users = @lastfm.track.get_top_fans('foo artist', 'foo track')
|
|
270
|
-
users.size.should eql(2)
|
|
271
|
-
users[0]['name'].should eql('Through0glass')
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
it 'should get top tags' do
|
|
275
|
-
@lastfm.should_receive(:request).with('track.getTopTags', {
|
|
276
|
-
:artist => 'foo artist',
|
|
277
|
-
:track => 'foo track',
|
|
278
|
-
}).and_return(make_response('track_get_top_tags'))
|
|
279
|
-
|
|
280
|
-
tags = @lastfm.track.get_top_tags('foo artist', 'foo track')
|
|
281
|
-
tags.size.should eql(2)
|
|
282
|
-
tags[0]['name'].should eql('alternative')
|
|
283
|
-
tags[0]['count'].should eql('100')
|
|
284
|
-
tags[0]['url'].should eql('www.last.fm/tag/alternative')
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
it 'should love' do
|
|
288
|
-
@lastfm.should_receive(:request).with('track.love', {
|
|
289
|
-
:artist => 'foo artist',
|
|
290
|
-
:track => 'foo track',
|
|
291
|
-
}, :post, true, true).and_return(@ok_response)
|
|
292
|
-
|
|
293
|
-
@lastfm.track.love('foo artist', 'foo track').should be_true
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
it 'should remove tag' do
|
|
297
|
-
@lastfm.should_receive(:request).with('track.removeTag', {
|
|
298
|
-
:artist => 'foo artist',
|
|
299
|
-
:track => 'foo track',
|
|
300
|
-
:tag => 'aaa'
|
|
301
|
-
}, :post, true, true).and_return(@ok_response)
|
|
302
|
-
|
|
303
|
-
@lastfm.track.remove_tag('foo artist', 'foo track', 'aaa').should be_true
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
it 'should search' do
|
|
307
|
-
@lastfm.should_receive(:request).with('track.search', {
|
|
308
|
-
:artist => nil,
|
|
309
|
-
:track => 'Believe',
|
|
310
|
-
:limit => 10,
|
|
311
|
-
:page => 3,
|
|
312
|
-
}).and_return(make_response('track_search'))
|
|
313
|
-
|
|
314
|
-
tracks = @lastfm.track.search('Believe', nil, 10, 3)
|
|
315
|
-
tracks['results']['for'].should eql('Believe')
|
|
316
|
-
tracks['results']['totalResults'].should eql('40540')
|
|
317
|
-
tracks['results']['trackmatches']['track'].size.should eql(2)
|
|
318
|
-
tracks['results']['trackmatches']['track'][0]['name'].should eql('Make Me Believe')
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
it 'should share' do
|
|
322
|
-
@lastfm.should_receive(:request).with('track.share', {
|
|
323
|
-
:artist => 'foo artist',
|
|
324
|
-
:track => 'foo track',
|
|
325
|
-
:message => 'this is a message',
|
|
326
|
-
:recipient => 'foo@example.com',
|
|
327
|
-
}, :post, true, true).and_return(@ok_response)
|
|
328
|
-
|
|
329
|
-
@lastfm.track.share('foo artist', 'foo track', 'foo@example.com', 'this is a message').should be_true
|
|
330
|
-
end
|
|
331
|
-
|
|
332
|
-
it 'should scrobble' do
|
|
333
|
-
time = Time.now
|
|
334
|
-
@lastfm.should_receive(:request).with('track.scrobble', {
|
|
335
|
-
:artist => 'foo artist',
|
|
336
|
-
:track => 'foo track',
|
|
337
|
-
:album => 'foo album',
|
|
338
|
-
:mbid => '0383dadf-2a4e-4d10-a46a-e9e041da8eb3',
|
|
339
|
-
:timestamp => time,
|
|
340
|
-
:trackNumber => 1,
|
|
341
|
-
:duration => nil,
|
|
342
|
-
:albumArtist => nil,
|
|
343
|
-
}, :post, true, true).and_return(@ok_response)
|
|
344
|
-
|
|
345
|
-
@lastfm.track.scrobble('foo artist', 'foo track', time, 'foo album', 1, '0383dadf-2a4e-4d10-a46a-e9e041da8eb3', nil, nil)
|
|
346
|
-
end
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
it 'should update now playing' do
|
|
350
|
-
@lastfm.should_receive(:request).with('track.updateNowPlaying', {
|
|
351
|
-
:artist => 'foo artist',
|
|
352
|
-
:track => 'foo track',
|
|
353
|
-
:album => 'foo album',
|
|
354
|
-
:mbid => '0383dadf-2a4e-4d10-a46a-e9e041da8eb3',
|
|
355
|
-
:trackNumber => 1,
|
|
356
|
-
:duration => nil,
|
|
357
|
-
:albumArtist => nil,
|
|
358
|
-
}, :post, true, true).and_return(@ok_response)
|
|
359
|
-
|
|
360
|
-
@lastfm.track.update_now_playing('foo artist', 'foo track', 'foo album', 1, '0383dadf-2a4e-4d10-a46a-e9e041da8eb3', nil, nil)
|
|
361
|
-
end
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
describe '#artist' do
|
|
365
|
-
it 'should return an instance of Lastfm::Artist' do
|
|
366
|
-
@lastfm.artist.should be_an_instance_of(Lastfm::MethodCategory::Artist)
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
it 'should get info' do
|
|
370
|
-
@lastfm.should_receive(:request).with('artist.getInfo', {
|
|
371
|
-
:artist => 'Cher'
|
|
372
|
-
}).and_return(make_response('artist_get_info'))
|
|
373
|
-
|
|
374
|
-
artist = @lastfm.artist.get_info('Cher')
|
|
375
|
-
artist['name'].should eql('Cher')
|
|
376
|
-
artist['mbid'].should eql('bfcc6d75-a6a5-4bc6-8282-47aec8531818')
|
|
377
|
-
artist['url'].should eql('http://www.last.fm/music/Cher')
|
|
378
|
-
artist['image'].size.should eql(5)
|
|
379
|
-
end
|
|
380
|
-
|
|
381
|
-
it 'should get events' do
|
|
382
|
-
@lastfm.should_receive(:request).with('artist.getEvents', {
|
|
383
|
-
:artist => 'Cher'
|
|
384
|
-
}).and_return(make_response('artist_get_events'))
|
|
385
|
-
|
|
386
|
-
events = @lastfm.artist.get_events('Cher')
|
|
387
|
-
events.size.should eql(1)
|
|
388
|
-
events[0]['title'].should eql('Cher')
|
|
389
|
-
events[0]['artists'].size.should == 2
|
|
390
|
-
events[0]['artists']['headliner'].should eql('Cher')
|
|
391
|
-
events[0]['venue']['name'].should eql('The Colosseum At Caesars Palace')
|
|
392
|
-
events[0]['venue']['location']['city'].should eql('Las Vegas(, NV)')
|
|
393
|
-
events[0]['venue']['location']['point']['lat'].should eql("36.116143")
|
|
394
|
-
events[0]['image'].size.should eql(4)
|
|
395
|
-
events[0]['image'][0]['size'].should eql('small')
|
|
396
|
-
events[0]['image'][0]['content'].should eql('http://userserve-ak.last.fm/serve/34/34814037.jpg')
|
|
397
|
-
events[0]['startDate'].should eql("Sat, 23 Oct 2010 19:30:00")
|
|
398
|
-
events[0]['tickets']['ticket']['supplier'].should eql("TicketMaster")
|
|
399
|
-
events[0]['tickets']['ticket']['content'].should eql("http://www.last.fm/affiliate/byid/29/1584537/12/ws.artist.events.b25b959554ed76058ac220b7b2e0a026")
|
|
400
|
-
events[0]['tags']['tag'].should == ["pop", "dance", "female vocalists", "80s", "cher"]
|
|
401
|
-
end
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
describe '#album' do
|
|
405
|
-
it 'should return an instance of Lastfm::Album' do
|
|
406
|
-
@lastfm.album.should be_an_instance_of(Lastfm::MethodCategory::Album)
|
|
407
|
-
end
|
|
408
|
-
|
|
409
|
-
it 'should get info' do
|
|
410
|
-
@lastfm.should_receive(:request).with('album.getInfo', {
|
|
411
|
-
:artist => 'Cher', :album => 'Believe'
|
|
412
|
-
}).and_return(make_response('album_get_info'))
|
|
413
|
-
|
|
414
|
-
album = @lastfm.album.get_info('Cher', 'Believe')
|
|
415
|
-
album['name'].should eql('Believe')
|
|
416
|
-
album['artist'].should eql('Cher')
|
|
417
|
-
album['id'].should eql('2026126')
|
|
418
|
-
album['mbid'].should eql('61bf0388-b8a9-48f4-81d1-7eb02706dfb0')
|
|
419
|
-
album['url'].should eql('http://www.last.fm/music/Cher/Believe')
|
|
420
|
-
album['image'].size.should eql(5)
|
|
421
|
-
album['releasedate'].should eql('6 Apr 1999, 00:00')
|
|
422
|
-
album['tracks']['track'].size.should eql(10)
|
|
423
|
-
album['tracks']['track'][0]['name'].should eql('Believe')
|
|
424
|
-
album['tracks']['track'][0]['duration'].should eql('239')
|
|
425
|
-
album['tracks']['track'][0]['url'].should eql('http://www.last.fm/music/Cher/_/Believe')
|
|
426
|
-
end
|
|
427
|
-
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
describe '#geo' do
|
|
431
|
-
it 'should return an instance of Lastfm::Geo' do
|
|
432
|
-
@lastfm.geo.should be_an_instance_of(Lastfm::MethodCategory::Geo)
|
|
433
|
-
end
|
|
434
|
-
|
|
435
|
-
it 'should get events' do
|
|
436
|
-
@lastfm.should_receive(:request).with('geo.getEvents', {
|
|
437
|
-
:location => 'Boulder',
|
|
438
|
-
:distance => nil,
|
|
439
|
-
:limit => nil,
|
|
440
|
-
:page => nil
|
|
441
|
-
}).and_return(make_response('geo_get_events'))
|
|
442
|
-
|
|
443
|
-
events = @lastfm.geo.get_events('Boulder')
|
|
444
|
-
events.size.should eql(1)
|
|
445
|
-
events[0]['title'].should eql('Transistor Festival')
|
|
446
|
-
events[0]['artists'].size.should == 2
|
|
447
|
-
events[0]['artists']['headliner'].should eql('Not Breathing')
|
|
448
|
-
events[0]['venue']['name'].should eql('The Walnut Room')
|
|
449
|
-
events[0]['venue']['location']['city'].should eql('Denver, CO')
|
|
450
|
-
events[0]['venue']['location']['point']['lat'].should eql("39.764316")
|
|
451
|
-
events[0]['image'].size.should eql(4)
|
|
452
|
-
events[0]['image'][0]['size'].should eql('small')
|
|
453
|
-
events[0]['image'][0]['content'].should eql('http://userserve-ak.last.fm/serve/34/166214.jpg')
|
|
454
|
-
events[0]['startDate'].should eql("Fri, 10 Jun 2011 01:58:01")
|
|
455
|
-
end
|
|
456
|
-
end
|
|
457
|
-
|
|
458
|
-
describe '#user' do
|
|
459
|
-
it 'should return an instance of Lastfm::User' do
|
|
460
|
-
@lastfm.user.should be_an_instance_of(Lastfm::MethodCategory::User)
|
|
461
|
-
end
|
|
462
|
-
|
|
463
|
-
describe '#get_info' do
|
|
464
|
-
it 'should get user info' do
|
|
465
|
-
@lastfm.should_receive(:request).with('user.getInfo', {:user => 'test'}).and_return(make_response('user_get_info'))
|
|
466
|
-
info = @lastfm.user.get_info('test')
|
|
467
|
-
info['id'].should eql('1000002')
|
|
468
|
-
end
|
|
469
|
-
end
|
|
470
|
-
|
|
471
|
-
describe '#get_top_artists' do
|
|
472
|
-
it 'should get user\'s top artists' do
|
|
473
|
-
@lastfm.should_receive(:request).with('user.getTopArtists', {
|
|
474
|
-
:user => 'test',
|
|
475
|
-
:period => 'overall',
|
|
476
|
-
:limit => nil,
|
|
477
|
-
:page => nil
|
|
478
|
-
}).and_return(make_response('user_get_top_artists'))
|
|
479
|
-
|
|
480
|
-
artists = @lastfm.user.get_top_artists('test', 'overall', nil, nil)
|
|
481
|
-
|
|
482
|
-
artists.size.should == 3
|
|
483
|
-
artists[0]['name'].should == "Pain of Salvation"
|
|
484
|
-
artists[0]['playcount'].should == '1354'
|
|
485
|
-
|
|
486
|
-
artists[1]['name'].should == "Opeth"
|
|
487
|
-
artists[1]['playcount'].should == '1186'
|
|
488
|
-
|
|
489
|
-
artists[2]['name'].should == "Nevermore"
|
|
490
|
-
artists[2]['playcount'].should == '959'
|
|
491
|
-
end
|
|
492
|
-
end
|
|
493
|
-
|
|
494
|
-
describe '#get_top_albums' do
|
|
495
|
-
it 'should get user\'s top albums' do
|
|
496
|
-
@lastfm.should_receive(:request).with('user.getTopAlbums', {
|
|
497
|
-
:user => 'test',
|
|
498
|
-
:period => 'overall',
|
|
499
|
-
:limit => nil,
|
|
500
|
-
:page => nil
|
|
501
|
-
}).and_return(make_response('user_get_top_albums'))
|
|
502
|
-
|
|
503
|
-
albums = @lastfm.user.get_top_albums('test', 'overall', nil, nil)
|
|
504
|
-
|
|
505
|
-
albums.size.should == 2
|
|
506
|
-
|
|
507
|
-
albums[0]['rank'].should == '1'
|
|
508
|
-
albums[0]['name'].should == 'The Wall'
|
|
509
|
-
albums[0]['artist']['name'].should == 'Pink Floyd'
|
|
510
|
-
|
|
511
|
-
albums[1]['rank'].should == '2'
|
|
512
|
-
albums[1]['name'].should == 'The Perfect Element, Part I'
|
|
513
|
-
albums[1]['artist']['name'].should == 'Pain of Salvation'
|
|
514
|
-
end
|
|
515
|
-
end
|
|
516
|
-
|
|
517
|
-
describe '#get_top_tracks' do
|
|
518
|
-
it 'should get user\'s top tracks' do
|
|
519
|
-
@lastfm.should_receive(:request).with('user.getTopTracks', {
|
|
520
|
-
:user => 'test',
|
|
521
|
-
:period => '7day',
|
|
522
|
-
:limit => nil,
|
|
523
|
-
:page => nil
|
|
524
|
-
}).and_return(make_response('user_get_top_tracks'))
|
|
525
|
-
|
|
526
|
-
tracks = @lastfm.user.get_top_tracks('test', '7day', nil, nil)
|
|
527
|
-
|
|
528
|
-
tracks.size.should == 2
|
|
529
|
-
|
|
530
|
-
tracks[0]['rank'].should == '1'
|
|
531
|
-
tracks[0]['name'].should == 'No Light, No Light (TV On The Radio Remix)'
|
|
532
|
-
tracks[0]['artist']['name'].should == 'Florence + the Machine'
|
|
533
|
-
|
|
534
|
-
tracks[1]['rank'].should == '2'
|
|
535
|
-
tracks[1]['name'].should == 'Backwords (Porcelain Raft cover)'
|
|
536
|
-
tracks[1]['artist']['name'].should == 'Oupa & Tony Crow'
|
|
537
|
-
end
|
|
538
|
-
end
|
|
539
|
-
|
|
540
|
-
describe '#get_loved_tracks' do
|
|
541
|
-
it 'should get user\'s loved tracks' do
|
|
542
|
-
@lastfm.should_receive(:request).with('user.getLovedTracks', {
|
|
543
|
-
:user => 'test',
|
|
544
|
-
:period => nil,
|
|
545
|
-
:limit => nil,
|
|
546
|
-
:page => nil
|
|
547
|
-
}).and_return(make_response('user_get_loved_tracks'))
|
|
548
|
-
|
|
549
|
-
tracks = @lastfm.user.get_loved_tracks('test', nil, nil, nil)
|
|
550
|
-
|
|
551
|
-
tracks.size.should == 2
|
|
552
|
-
|
|
553
|
-
tracks[0]['rank'].should == nil
|
|
554
|
-
tracks[0]['name'].should == 'I Spy'
|
|
555
|
-
tracks[0]['artist']['name'].should == 'Mikhael Paskalev'
|
|
556
|
-
|
|
557
|
-
tracks[1]['rank'].should == nil
|
|
558
|
-
tracks[1]['name'].should == 'Working Titles'
|
|
559
|
-
tracks[1]['artist']['name'].should == 'Damien Jurado'
|
|
560
|
-
end
|
|
561
|
-
end
|
|
562
|
-
|
|
563
|
-
describe '#get_friends' do
|
|
564
|
-
it 'should get user\'s friends' do
|
|
565
|
-
@lastfm.should_receive(:request).with('user.getFriends', {
|
|
566
|
-
:user => 'test',
|
|
567
|
-
:recenttracks => nil,
|
|
568
|
-
:page => nil,
|
|
569
|
-
:limit => nil
|
|
570
|
-
}).and_return(make_response('user_get_friends'))
|
|
571
|
-
friends = @lastfm.user.get_friends('test')
|
|
572
|
-
friends.size.should == 1
|
|
573
|
-
friends[0]['name'].should eql('polaroide')
|
|
574
|
-
end
|
|
575
|
-
end
|
|
576
|
-
|
|
577
|
-
describe '#get_neighbours' do
|
|
578
|
-
it 'should get user\'s neighbours' do
|
|
579
|
-
@lastfm.should_receive(:request).with('user.getNeighbours', {
|
|
580
|
-
:user => 'rj',
|
|
581
|
-
:recenttracks => nil,
|
|
582
|
-
:page => nil,
|
|
583
|
-
:limit => nil
|
|
584
|
-
}).and_return(make_response('user_get_neighbours'))
|
|
585
|
-
neighbours = @lastfm.user.get_neighbours('rj')
|
|
586
|
-
neighbours.size.should == 50
|
|
587
|
-
neighbours[0]['name'].should eql('willywongi')
|
|
588
|
-
end
|
|
589
|
-
end
|
|
590
|
-
|
|
591
|
-
describe '#get_recent_tracks' do
|
|
592
|
-
it 'should get user\'s recent tracks' do
|
|
593
|
-
@lastfm.should_receive(:request).with('user.getRecentTracks', {
|
|
594
|
-
:user => 'test',
|
|
595
|
-
:page => nil,
|
|
596
|
-
:limit => nil,
|
|
597
|
-
:to => nil,
|
|
598
|
-
:from => nil
|
|
599
|
-
}).and_return(make_response('user_get_recent_tracks'))
|
|
600
|
-
tracks = @lastfm.user.get_recent_tracks('test')
|
|
601
|
-
tracks[1]['artist']['content'].should eql('Kylie Minogue')
|
|
602
|
-
tracks.size.should == 2
|
|
603
|
-
end
|
|
604
|
-
end
|
|
605
|
-
end
|
|
606
|
-
|
|
607
|
-
describe '#library' do
|
|
608
|
-
it 'should return an instance of Lastfm::Library' do
|
|
609
|
-
@lastfm.library.should be_an_instance_of(Lastfm::MethodCategory::Library)
|
|
610
|
-
end
|
|
611
|
-
|
|
612
|
-
describe '#get_tracks' do
|
|
613
|
-
it 'should get the tracks\' info' do
|
|
614
|
-
@lastfm.should_receive(:request).with('library.getTracks', {
|
|
615
|
-
:user => 'test',
|
|
616
|
-
:artist => 'foo',
|
|
617
|
-
:album => 'bar',
|
|
618
|
-
:limit => nil,
|
|
619
|
-
:page => nil
|
|
620
|
-
}).and_return(make_response('library_get_tracks'))
|
|
621
|
-
tracks = @lastfm.library.get_tracks('test', 'foo', 'bar')
|
|
622
|
-
tracks[0]['name'].should eql('Learning to Live')
|
|
623
|
-
tracks.size.should == 1
|
|
624
|
-
end
|
|
625
|
-
end
|
|
626
|
-
|
|
627
|
-
describe '#get_artists' do
|
|
628
|
-
it 'should get the artists\' info' do
|
|
629
|
-
@lastfm.should_receive(:request).with('library.getArtists', {
|
|
630
|
-
:user => 'test',
|
|
631
|
-
:limit => nil,
|
|
632
|
-
:page => nil
|
|
633
|
-
}).and_return(make_response('library_get_artists'))
|
|
634
|
-
artists = @lastfm.library.get_artists('test')
|
|
635
|
-
artists[1]['name'].should eql('Dark Castle')
|
|
636
|
-
artists.size.should == 2
|
|
637
|
-
end
|
|
153
|
+
session['name'].should == 'MyLastFMUsername'
|
|
154
|
+
session['key'].should == 'zzzyyyxxx'
|
|
638
155
|
end
|
|
639
156
|
end
|
|
640
157
|
end
|