lastfm 1.22.0 → 1.23.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,6 +1,4 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
2
  - 1.9.3
5
3
  - 2.0.0
6
4
  - 2.1.0
data/README.rdoc CHANGED
@@ -4,21 +4,29 @@ A Ruby interface for Last.fm Web Services v2.0
4
4
 
5
5
  == Synopsis
6
6
 
7
- require 'lastfm'
7
+ ```ruby
8
+ require 'lastfm'
8
9
 
9
- lastfm = Lastfm.new(api_key, api_secret)
10
- token = lastfm.auth.get_token
10
+ lastfm = Lastfm.new(api_key, api_secret)
11
+ token = lastfm.auth.get_token
11
12
 
12
- # open 'http://www.last.fm/api/auth/?api_key=xxxxxxxxxxx&token=xxxxxxxx' and grant the application
13
+ # open 'http://www.last.fm/api/auth/?api_key=xxxxxxxxxxx&token=xxxxxxxx' and grant the application
13
14
 
14
- lastfm.session = lastfm.auth.get_session(:token => token)['key']
15
+ lastfm.session = lastfm.auth.get_session(token: token)['key']
15
16
 
16
- lastfm.track.love(:artist => 'Hujiko Pro', :track => 'acid acid 7riddim')
17
- lastfm.track.scrobble(:artist => 'Hujiko Pro', :track => 'acid acid 7riddim')
18
- lastfm.track.update_now_playing(:artist => 'Hujiko Pro', :track => 'acid acid 7riddim')
17
+ lastfm.track.love(artist: 'Hujiko Pro', track: 'acid acid 7riddim')
18
+ lastfm.track.scrobble(artist: 'Hujiko Pro', track: 'acid acid 7riddim')
19
+ lastfm.track.update_now_playing(artist: 'Hujiko Pro', track: 'acid acid 7riddim')
19
20
 
20
- # deprecated style
21
- lastfm.track.love('Hujiko Pro', 'acid acid 7riddim')
21
+ # deprecated style
22
+ lastfm.track.love('Hujiko Pro', 'acid acid 7riddim')
23
+ ```
24
+
25
+ == Supported Rubies
26
+
27
+ * 1.9.3
28
+ * 2.0.0
29
+ * 2.1.0
22
30
 
23
31
  == Supported API Methods
24
32
 
@@ -30,7 +38,7 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
30
38
 
31
39
  === Artist
32
40
 
33
- * {artist.getEvents}[http://www.lastfm.jp/api/show?service=117]
41
+ * {artist.getEvents}[http://www.last.fm/api/show?service=117]
34
42
  * {artist.getInfo}[http://www.last.fm/api/show?service=267]
35
43
  * {artist.getSimilar}[http://www.last.fm/api/show?service=267]
36
44
  * {artist.getTags}[http://www.last.fm/api/show?service=267]
@@ -38,63 +46,65 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
38
46
  * {artist.getTopFans}[http://www.last.fm/api/show/artist.getTopFans]
39
47
  * {artist.getTopTags}[http://www.last.fm/api/show/artist.getTopTags]
40
48
  * {artist.getTopTracks}[http://www.last.fm/api/show/artist.getTopTracks]
41
- * {artist.search}[http://www.lastfm.jp/api/show/artist.search]
49
+ * {artist.search}[http://www.last.fm/api/show/artist.search]
42
50
 
43
51
  === Auth
44
52
 
45
- * {auth.getMobileSession}[http://www.lastfm.jp/api/show?service=266]
46
- * {auth.getToken}[http://www.lastfm.jp/api/show?service=265]
47
- * {auth.getSession}[http://www.lastfm.jp/api/show?service=125]
53
+ * {auth.getMobileSession}[http://www.last.fm/api/show?service=266]
54
+ * {auth.getToken}[http://www.last.fm/api/show?service=265]
55
+ * {auth.getSession}[http://www.last.fm/api/show?service=125]
48
56
 
49
57
  === Event
50
58
 
51
- * {event.getInfo}[http://www.lastfm.jp/api/show/event.getInfo]
59
+ * {event.getInfo}[http://www.last.fm/api/show/event.getInfo]
52
60
 
53
61
  === Radio
54
62
 
55
- * {radio.getPlaylist}[http://www.lastfm.jp/api/show/radio.getPlaylist]
63
+ * {radio.getPlaylist}[http://www.last.fm/api/show/radio.getPlaylist]
56
64
 
57
65
  === Tag
58
66
 
59
- * {tag.getTopArtists}[http://www.lastfm.jp/api/show/tag.getTopArtists]
60
- * {tag.getTopTracks}[http://www.lastfm.jp/api/show/tag.getTopTracks]
67
+ * {tag.getTopAlbums}[http://www.last.fm/api/show/tag.getTopAlbums]
68
+ * {tag.getTopArtists}[http://www.last.fm/api/show/tag.getTopArtists]
69
+ * {tag.getTopTracks}[http://www.last.fm/api/show/tag.getTopTracks]
70
+ * {tag.search}[http://www.last.fm/api/show/tag.search]
61
71
 
62
72
  === Tasteometer
63
73
 
64
- * {tasteometer.compare}[http://www.lastfm.jp/api/show/tasteometer.compare]
74
+ * {tasteometer.compare}[http://www.last.fm/api/show/tasteometer.compare]
65
75
 
66
76
  === Track
67
77
 
68
- * {track.addTags}[http://www.lastfm.jp/api/show?service=304]
69
- * {track.ban}[http://www.lastfm.jp/api/show?service=261]
70
- * {track.getCorrection}[http://www.lastfm.jp/api/show?service=447]
71
- * {track.getInfo}[http://www.lastfm.jp/api/show?service=356]
72
- * {track.getSimilar}[http://www.lastfm.jp/api/show?service=319]
73
- * {track.getTags}[http://www.lastfm.jp/api/show?service=320]
74
- * {track.getTopFans}[http://www.lastfm.jp/api/show?service=312]
75
- * {track.getTopTags}[http://www.lastfm.jp/api/show?service=289]
76
- * {track.love}[http://www.lastfm.jp/api/show?service=260]
77
- * {track.removeTag}[http://www.lastfm.jp/api/show?service=316]
78
- * {track.scrobble}[http://www.lastfm.jp/api/show?service=443]
79
- * {track.search}[http://www.lastfm.jp/api/show?service=286]
80
- * {track.share}[http://www.lastfm.jp/api/show?service=305]
81
- * {track.updateNowPlaying}[http://www.lastfm.jp/api/show?service=454]
78
+ * {track.addTags}[http://www.last.fm/api/show?service=304]
79
+ * {track.ban}[http://www.last.fm/api/show?service=261]
80
+ * {track.getCorrection}[http://www.last.fm/api/show?service=447]
81
+ * {track.getInfo}[http://www.last.fm/api/show?service=356]
82
+ * {track.getSimilar}[http://www.last.fm/api/show?service=319]
83
+ * {track.getTags}[http://www.last.fm/api/show?service=320]
84
+ * {track.getTopFans}[http://www.last.fm/api/show?service=312]
85
+ * {track.getTopTags}[http://www.last.fm/api/show?service=289]
86
+ * {track.love}[http://www.last.fm/api/show?service=260]
87
+ * {track.removeTag}[http://www.last.fm/api/show?service=316]
88
+ * {track.scrobble}[http://www.last.fm/api/show?service=443]
89
+ * {track.search}[http://www.last.fm/api/show?service=286]
90
+ * {track.share}[http://www.last.fm/api/show?service=305]
91
+ * {track.updateNowPlaying}[http://www.last.fm/api/show?service=454]
82
92
  * {track.unlove}[http://www.last.fm/api/show/track.unlove]
83
93
 
84
94
  === User
85
95
 
86
- * {user.getFriends}[http://www.lastfm.jp/api/show?service=263]
87
- * {user.getInfo}[http://www.lastfm.jp/api/show?service=344]
88
- * {user.getLovedTracks}[http://www.lastfm.jp/api/show/user.getLovedTracks]
89
- * {user.getNeighbours}[http://www.lastfm.jp/api/show?service=264]
90
- * {user.getPersonalTags}[http://www.lastfm.jp/api/show/user.getPersonalTags]
91
- * {user.getRecentTracks}[http://www.lastfm.jp/api/show?service=278]
96
+ * {user.getFriends}[http://www.last.fm/api/show?service=263]
97
+ * {user.getInfo}[http://www.last.fm/api/show?service=344]
98
+ * {user.getLovedTracks}[http://www.last.fm/api/show/user.getLovedTracks]
99
+ * {user.getNeighbours}[http://www.last.fm/api/show?service=264]
100
+ * {user.getPersonalTags}[http://www.last.fm/api/show/user.getPersonalTags]
101
+ * {user.getRecentTracks}[http://www.last.fm/api/show?service=278]
92
102
  * {user.getRecommendedEvents}[http://www.last.fm/api/show/user.getRecommendedEvents]
93
103
  * {user.getRecommendedArtists}[http://www.last.fm/api/show/user.getRecommendedArtists]
94
- * {user.getTopArtists}[http://www.lastfm.jp/api/show/user.getTopArtists]
95
- * {user.getTopAlbums}[http://www.lastfm.jp/api/show/user.getTopAlbums]
96
- * {user.getTopTags}[http://www.lastfm.jp/api/show/user.getTopTags]
97
- * {user.getTopTracks}[http://www.lastfm.jp/api/show/user.getTopTracks]
104
+ * {user.getTopArtists}[http://www.last.fm/api/show/user.getTopArtists]
105
+ * {user.getTopAlbums}[http://www.last.fm/api/show/user.getTopAlbums]
106
+ * {user.getTopTags}[http://www.last.fm/api/show/user.getTopTags]
107
+ * {user.getTopTracks}[http://www.last.fm/api/show/user.getTopTracks]
98
108
  * {user.getWeeklyAlbumList}[http://www.last.fm/api/show/user.getWeeklyAlbumChart]
99
109
  * {user.getWeeklyArtistList}[http://www.last.fm/api/show/user.getWeeklyArtistChart]
100
110
  * {user.getWeeklyChartList}[http://www.last.fm/api/show/group.getWeeklyChartList]
@@ -102,21 +112,21 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
102
112
 
103
113
  === Geo
104
114
 
105
- * {geo.getEvents}[http://www.lastfm.jp/api/show?service=270]
115
+ * {geo.getEvents}[http://www.last.fm/api/show?service=270]
106
116
 
107
117
  === Library
108
118
 
109
- * {library.getArtists}[http://www.lastfm.jp/api/show?service=322]
119
+ * {library.getArtists}[http://www.last.fm/api/show?service=322]
110
120
  * {library.getTracks}[http://www.last.fm/api/show/library.getTracks]
111
121
 
112
122
  === Chart
113
123
 
114
- * {chart.getHypedArtists}[http://www.lastfm.jp/api/show/chart.getHypedArtists]
115
- * {chart.getHypedTracks}[http://www.lastfm.jp/api/show/chart.getHypedTracks]
116
- * {chart.getLovedTracks}[http://www.lastfm.jp/api/show/chart.getLovedTracks]
117
- * {chart.getTopArtists}[http://www.lastfm.jp/api/show/chart.getTopArtists]
118
- * {chart.getTopTags}[http://www.lastfm.jp/api/show/chart.getTopTags]
119
- * {chart.getTopTracks}[http://www.lastfm.jp/api/show/chart.getTopTracks]
124
+ * {chart.getHypedArtists}[http://www.last.fm/api/show/chart.getHypedArtists]
125
+ * {chart.getHypedTracks}[http://www.last.fm/api/show/chart.getHypedTracks]
126
+ * {chart.getLovedTracks}[http://www.last.fm/api/show/chart.getLovedTracks]
127
+ * {chart.getTopArtists}[http://www.last.fm/api/show/chart.getTopArtists]
128
+ * {chart.getTopTags}[http://www.last.fm/api/show/chart.getTopTags]
129
+ * {chart.getTopTracks}[http://www.last.fm/api/show/chart.getTopTracks]
120
130
 
121
131
  == Installation
122
132
 
data/lastfm.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
13
  gem.name = %q{lastfm}
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "1.22.0"
15
+ gem.version = "1.23.0"
16
16
  gem.license = 'MIT'
17
17
 
18
18
  gem.add_dependency "xml-simple"
@@ -22,6 +22,28 @@ class Lastfm
22
22
  ) do |response|
23
23
  response.xml['toptracks']['track']
24
24
  end
25
+
26
+ regular_method(
27
+ :get_top_albums,
28
+ :required => [:tag],
29
+ :optional => [
30
+ [:limit, nil],
31
+ [:page, nil]
32
+ ]
33
+ ) do |response|
34
+ response.xml['topalbums']['album']
35
+ end
36
+
37
+ regular_method(
38
+ :search,
39
+ :required => [:tag],
40
+ :optional => [
41
+ [:limit, nil],
42
+ [:page, nil]
43
+ ]
44
+ ) do |response|
45
+ response.xml['results']['tagmatches']['tag']
46
+ end
25
47
  end
26
48
  end
27
49
  end
@@ -0,0 +1,70 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <topalbums tag="Disco" page="1" perPage="5" totalPages="200" total="1000">
4
+
5
+ <album rank="1">
6
+ <name>Number Ones</name>
7
+ <mbid>1a5fbd22-9a0a-4252-9bb0-60f3f1e14750</mbid>
8
+ <url>http://www.last.fm/music/Bee+Gees/Number+Ones</url>
9
+ <artist>
10
+ <name>Bee Gees</name>
11
+ <mbid>bf0f7e29-dfe1-416c-b5c6-f9ebc19ea810</mbid>
12
+ <url>http://www.last.fm/music/Bee+Gees</url>
13
+ </artist>
14
+ <image size="small">http://userserve-ak.last.fm/serve/34s/88142617.png</image>
15
+ <image size="medium">http://userserve-ak.last.fm/serve/64s/88142617.png</image>
16
+ <image size="large">http://userserve-ak.last.fm/serve/126/88142617.png</image>
17
+ <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/88142617.png</image>
18
+ </album> <album rank="2">
19
+ <name>Gold: Greatest Hits</name>
20
+ <mbid>f2d583b3-c542-4b9e-bcef-12b9696bea51</mbid>
21
+ <url>http://www.last.fm/music/ABBA/Gold:+Greatest+Hits</url>
22
+ <artist>
23
+ <name>ABBA</name>
24
+ <mbid>d87e52c5-bb8d-4da8-b941-9f4928627dc8</mbid>
25
+ <url>http://www.last.fm/music/ABBA</url>
26
+ </artist>
27
+ <image size="small">http://userserve-ak.last.fm/serve/34s/91651569.png</image>
28
+ <image size="medium">http://userserve-ak.last.fm/serve/64s/91651569.png</image>
29
+ <image size="large">http://userserve-ak.last.fm/serve/126/91651569.png</image>
30
+ <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/91651569.png</image>
31
+ </album> <album rank="3">
32
+ <name>Remix 2005</name>
33
+ <mbid>08b95338-faa4-489e-87b3-7ea3a69aa7b6</mbid>
34
+ <url>http://www.last.fm/music/Boney+M./Remix+2005</url>
35
+ <artist>
36
+ <name>Boney M.</name>
37
+ <mbid>1a79fc33-3cfb-4736-9042-b6b9e8ce4fe9</mbid>
38
+ <url>http://www.last.fm/music/Boney+M.</url>
39
+ </artist>
40
+ <image size="small">http://userserve-ak.last.fm/serve/34s/9102817.jpg</image>
41
+ <image size="medium">http://userserve-ak.last.fm/serve/64s/9102817.jpg</image>
42
+ <image size="large">http://userserve-ak.last.fm/serve/126/9102817.jpg</image>
43
+ <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/9102817.jpg</image>
44
+ </album> <album rank="4">
45
+ <name>Greatest Hits</name>
46
+ <mbid>b05fbfb7-833e-4f40-acbf-103539bec01b</mbid>
47
+ <url>http://www.last.fm/music/Earth,+Wind+&amp;+Fire/Greatest+Hits</url>
48
+ <artist>
49
+ <name>Earth, Wind &amp; Fire</name>
50
+ <mbid>535afeda-2538-435d-9dd1-5e10be586774</mbid>
51
+ <url>http://www.last.fm/music/Earth,+Wind+&amp;+Fire</url>
52
+ </artist>
53
+ <image size="small">http://userserve-ak.last.fm/serve/34s/9699191.jpg</image>
54
+ <image size="medium">http://userserve-ak.last.fm/serve/64s/9699191.jpg</image>
55
+ <image size="large">http://userserve-ak.last.fm/serve/126/9699191.jpg</image>
56
+ <image size="extralarge">http://userserve-ak.last.fm/serve/300x300/9699191.jpg</image>
57
+ </album> <album rank="5">
58
+ <name>Greatest Hits</name>
59
+ <mbid>11f1262d-9be0-46d4-8e74-a273f803a327</mbid>
60
+ <url>http://www.last.fm/music/KC+and+The+Sunshine+Band/Greatest+Hits</url>
61
+ <artist>
62
+ <name>KC and The Sunshine Band</name>
63
+ <mbid>25ad6e44-40a9-4b67-82cd-d20bb3b27afa</mbid>
64
+ <url>http://www.last.fm/music/KC+and+The+Sunshine+Band</url>
65
+ </artist>
66
+ <image size="small">http://images.amazon.com/images/P/B00002NDAL.01.MZZZZZZZ.jpg</image>
67
+ <image size="medium">http://images.amazon.com/images/P/B00002NDAL.01.MZZZZZZZ.jpg</image>
68
+ <image size="large">http://images.amazon.com/images/P/B00002NDAL.01.MZZZZZZZ.jpg</image>
69
+ <image size="extralarge">http://images.amazon.com/images/P/B00002NDAL.01.MZZZZZZZ.jpg</image>
70
+ </album></topalbums></lfm>
@@ -0,0 +1,35 @@
1
+
2
+ <?xml version="1.0" encoding="utf-8"?>
3
+ <lfm status="ok">
4
+ <results for="disco" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
5
+ <opensearch:Query role="request" searchTerms="disco" startPage="1" />
6
+ <opensearch:totalResults>1172</opensearch:totalResults>
7
+ <opensearch:startIndex>0</opensearch:startIndex>
8
+ <opensearch:itemsPerPage>5</opensearch:itemsPerPage><tagmatches>
9
+ <tag>
10
+ <name>disco</name>
11
+ <count>157207</count>
12
+ <url>www.last.fm/tag/disco</url>
13
+ </tag>
14
+ <tag>
15
+ <name>italo disco</name>
16
+ <count>18395</count>
17
+ <url>www.last.fm/tag/italo%20disco</url>
18
+ </tag>
19
+ <tag>
20
+ <name>disco house</name>
21
+ <count>6306</count>
22
+ <url>www.last.fm/tag/disco%20house</url>
23
+ </tag>
24
+ <tag>
25
+ <name>nu disco</name>
26
+ <count>7080</count>
27
+ <url>www.last.fm/tag/nu%20disco</url>
28
+ </tag>
29
+ <tag>
30
+ <name>panic at the disco</name>
31
+ <count>2825</count>
32
+ <url>www.last.fm/tag/panic%20at%20the%20disco</url>
33
+ </tag>
34
+ </tagmatches>
35
+ </results></lfm>
@@ -40,4 +40,38 @@ describe '#tag' do
40
40
  end
41
41
  end
42
42
 
43
+ describe '#get_top_albums' do
44
+ it 'should get top albums of a given tag' do
45
+ @lastfm.should_receive(:request).with('tag.getTopAlbums', {
46
+ :tag => 'Disco',
47
+ :limit => 5,
48
+ :page => nil
49
+ }).and_return(make_response('tag_get_top_albums'))
50
+
51
+ albums = @lastfm.tag.get_top_albums(:tag => 'Disco', :limit => 5)
52
+ albums.size.should == 5
53
+ albums[0]['name'].should == 'Number Ones'
54
+ albums[0]['url'].should == 'http://www.last.fm/music/Bee+Gees/Number+Ones'
55
+ albums[0]['artist']['name'].should == 'Bee Gees'
56
+ albums[1]['name'].should == 'Gold: Greatest Hits'
57
+ end
58
+ end
59
+
60
+ describe '#search' do
61
+ it 'should get all tags related to a given one' do
62
+ @lastfm.should_receive(:request).with('tag.search', {
63
+ :tag => 'Disco',
64
+ :limit => 5,
65
+ :page => nil
66
+ }).and_return(make_response('tag_search'))
67
+
68
+ tags = @lastfm.tag.search(:tag => 'Disco', :limit => 5)
69
+ tags.size.should == 5
70
+ tags[0]['name'].should == 'disco'
71
+ tags[0]['count'].should == '157207'
72
+ tags[0]['url'].should == 'www.last.fm/tag/disco'
73
+ tags[1]['name'].should == 'italo disco'
74
+ end
75
+ end
76
+
43
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lastfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.0
4
+ version: 1.23.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-23 00:00:00.000000000 Z
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
@@ -149,8 +149,10 @@ files:
149
149
  - spec/fixtures/ok.xml
150
150
  - spec/fixtures/radio_get_playlist.xml
151
151
  - spec/fixtures/radio_get_playlist_single_track.xml
152
+ - spec/fixtures/tag_get_top_albums.xml
152
153
  - spec/fixtures/tag_get_top_artists.xml
153
154
  - spec/fixtures/tag_get_top_tracks.xml
155
+ - spec/fixtures/tag_search.xml
154
156
  - spec/fixtures/tasteometer_compare.xml
155
157
  - spec/fixtures/track_get_correction.xml
156
158
  - spec/fixtures/track_get_info.xml
@@ -213,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
215
  version: '0'
214
216
  segments:
215
217
  - 0
216
- hash: -4186265295065313550
218
+ hash: 1082027776483675998
217
219
  required_rubygems_version: !ruby/object:Gem::Requirement
218
220
  none: false
219
221
  requirements:
@@ -222,10 +224,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
224
  version: '0'
223
225
  segments:
224
226
  - 0
225
- hash: -4186265295065313550
227
+ hash: 1082027776483675998
226
228
  requirements: []
227
229
  rubyforge_project:
228
- rubygems_version: 1.8.24
230
+ rubygems_version: 1.8.25
229
231
  signing_key:
230
232
  specification_version: 3
231
233
  summary: A ruby interface for Last.fm web services version 2.0
@@ -255,8 +257,10 @@ test_files:
255
257
  - spec/fixtures/ok.xml
256
258
  - spec/fixtures/radio_get_playlist.xml
257
259
  - spec/fixtures/radio_get_playlist_single_track.xml
260
+ - spec/fixtures/tag_get_top_albums.xml
258
261
  - spec/fixtures/tag_get_top_artists.xml
259
262
  - spec/fixtures/tag_get_top_tracks.xml
263
+ - spec/fixtures/tag_search.xml
260
264
  - spec/fixtures/tasteometer_compare.xml
261
265
  - spec/fixtures/track_get_correction.xml
262
266
  - spec/fixtures/track_get_info.xml