lastfm 1.13.1 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,6 +49,10 @@ It supports methods which require {authentication}[http://www.last.fm/api/authen
49
49
 
50
50
  * {event.getInfo}[http://www.lastfm.jp/api/show/event.getInfo]
51
51
 
52
+ === Radio
53
+
54
+ * {radio.getPlaylist}[http://www.lastfm.jp/api/show/radio.getPlaylist]
55
+
52
56
  === Tag
53
57
 
54
58
  * {tag.getTopArtists}[http://www.lastfm.jp/api/show/tag.getTopArtists]
@@ -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.13.1"
15
+ gem.version = "1.14.0"
16
16
 
17
17
  gem.add_dependency "xml-simple"
18
18
  gem.add_dependency "httparty"
@@ -17,6 +17,7 @@ require 'lastfm/method_category/tasteometer'
17
17
  require 'lastfm/method_category/track'
18
18
  require 'lastfm/method_category/user'
19
19
  require 'lastfm/method_category/chart'
20
+ require 'lastfm/method_category/radio'
20
21
 
21
22
  class Lastfm
22
23
  API_ROOT = 'http://ws.audioscrobbler.com/2.0'
@@ -85,6 +86,10 @@ class Lastfm
85
86
  MethodCategory::Chart.new(self)
86
87
  end
87
88
 
89
+ def radio
90
+ MethodCategory::Radio.new(self)
91
+ end
92
+
88
93
  def request(method, params = {}, http_method = :get, with_signature = false, with_session = false)
89
94
  params[:method] = method
90
95
  params[:api_key] = @api_key
@@ -0,0 +1,17 @@
1
+ class Lastfm
2
+ module MethodCategory
3
+ class Radio < Base
4
+ write_method :tune, [:station]
5
+ method_with_authentication :get_playlist, [], [] do |response|
6
+ playlist = response.xml['playlist']
7
+ tracklist = playlist['trackList']['track']
8
+
9
+ unless tracklist.is_a?(Array)
10
+ playlist['trackList']['track'] = [tracklist]
11
+ end
12
+
13
+ playlist
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,163 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <playlist version="1" xmlns="http://xspf.org/ns/0/">
4
+ <title>Pop Tag Radio</title>
5
+ <creator>Last.fm</creator>
6
+ <date>2012-12-04T01:48:10</date>
7
+ <link rel="http://www.last.fm/expiry">3600</link>
8
+ <trackList>
9
+ <track>
10
+ <location>http://play.last.fm/user/5d91bdcf9392915898ec2b35105bd2ef.mp3</location>
11
+ <title>All The Things She Said</title>
12
+ <identifier>1026968</identifier>
13
+ <album>Nachtschicht Vol. 37</album>
14
+ <creator>t.A.T.u.</creator>
15
+ <duration>207000</duration>
16
+ <image>http://userserve-ak.last.fm/serve/174s/47373527.jpg</image>
17
+
18
+ <extension application="http://www.last.fm">
19
+ <trackauth>75699</trackauth>
20
+ <albumid>234792586</albumid>
21
+ <artistid>1005290</artistid>
22
+ <recording>118782567</recording>
23
+
24
+ <artistpage>http://www.last.fm/music/t.A.T.u.</artistpage>
25
+ <albumpage>http://www.last.fm/music/Various/Nachtschicht+Vol.+37</albumpage>
26
+ <trackpage>http://www.last.fm/music/t.A.T.u./_/All+The+Things+She+Said</trackpage>
27
+ <buyTrackURL></buyTrackURL>
28
+ <buyAlbumURL></buyAlbumURL>
29
+ <freeTrackURL></freeTrackURL>
30
+
31
+ <explicit>0</explicit>
32
+ <loved>0</loved>
33
+ <streamid>8c926ea59eb105b6</streamid>
34
+
35
+
36
+
37
+
38
+ </extension>
39
+ </track>
40
+ <track>
41
+ <location>http://play.last.fm/user/bca46e434c3389217ef1b8d20db1690c.mp3</location>
42
+ <title>Your Body</title>
43
+ <identifier>554827812</identifier>
44
+ <album>Your Body</album>
45
+ <creator>Christina Aguilera</creator>
46
+ <duration>239000</duration>
47
+ <image>http://userserve-ak.last.fm/serve/174s/81918635.png</image>
48
+
49
+ <extension application="http://www.last.fm">
50
+ <trackauth>f2d16</trackauth>
51
+ <albumid>310636382</albumid>
52
+ <artistid>1017893</artistid>
53
+ <recording>133417720</recording>
54
+
55
+ <artistpage>http://www.last.fm/music/Christina+Aguilera</artistpage>
56
+ <albumpage>http://www.last.fm/music/Christina+Aguilera/Your+Body</albumpage>
57
+ <trackpage>http://www.last.fm/music/Christina+Aguilera/_/Your+Body</trackpage>
58
+ <buyTrackURL></buyTrackURL>
59
+ <buyAlbumURL></buyAlbumURL>
60
+ <freeTrackURL></freeTrackURL>
61
+
62
+ <explicit>0</explicit>
63
+ <loved>0</loved>
64
+ <streamid>8eb25091a71e9cc8</streamid>
65
+
66
+
67
+
68
+
69
+ </extension>
70
+ </track>
71
+ <track>
72
+ <location>http://play.last.fm/user/d98fd1c32bea007f1a04f42ec3972a0f.mp3</location>
73
+ <title>Time (Clock Of The Heart)</title>
74
+ <identifier>1066724</identifier>
75
+ <album>The Best Of Culture Club</album>
76
+ <creator>Culture Club</creator>
77
+ <duration>224000</duration>
78
+ <image>http://userserve-ak.last.fm/serve/174s/52853847.jpg</image>
79
+
80
+ <extension application="http://www.last.fm">
81
+ <trackauth>2599f</trackauth>
82
+ <albumid>2407014</albumid>
83
+ <artistid>1010458</artistid>
84
+ <recording>111604370</recording>
85
+
86
+ <artistpage>http://www.last.fm/music/Culture+Club</artistpage>
87
+ <albumpage>http://www.last.fm/music/Culture+Club/The+Best+Of+Culture+Club</albumpage>
88
+ <trackpage>http://www.last.fm/music/Culture+Club/_/Time+(Clock+Of+The+Heart)</trackpage>
89
+ <buyTrackURL></buyTrackURL>
90
+ <buyAlbumURL></buyAlbumURL>
91
+ <freeTrackURL></freeTrackURL>
92
+
93
+ <explicit>0</explicit>
94
+ <loved>0</loved>
95
+ <streamid>d9b98278b7803a6</streamid>
96
+
97
+
98
+
99
+
100
+ </extension>
101
+ </track>
102
+ <track>
103
+ <location>http://play.last.fm/user/772173b4cbfcd7faf958f625f1c7b26a.mp3</location>
104
+ <title>I Gotta Feeling</title>
105
+ <identifier>308970420</identifier>
106
+ <album>The E.N.D.</album>
107
+ <creator>Black Eyed Peas</creator>
108
+ <duration>289000</duration>
109
+ <image>http://userserve-ak.last.fm/serve/174s/55595879.png</image>
110
+
111
+ <extension application="http://www.last.fm">
112
+ <trackauth>cbcb5</trackauth>
113
+ <albumid>25043881</albumid>
114
+ <artistid>1784</artistid>
115
+ <recording>118305234</recording>
116
+
117
+ <artistpage>http://www.last.fm/music/Black+Eyed+Peas</artistpage>
118
+ <albumpage>http://www.last.fm/music/Black+Eyed+Peas/The+E.N.D.</albumpage>
119
+ <trackpage>http://www.last.fm/music/Black+Eyed+Peas/_/I+Gotta+Feeling</trackpage>
120
+ <buyTrackURL></buyTrackURL>
121
+ <buyAlbumURL></buyAlbumURL>
122
+ <freeTrackURL></freeTrackURL>
123
+
124
+ <loved>0</loved>
125
+ <streamid>a64764734de8903f</streamid>
126
+
127
+
128
+
129
+
130
+ </extension>
131
+ </track>
132
+ <track>
133
+ <location>http://play.last.fm/user/60bde9cbc9043220efe0d4a87e4c8acb.mp3</location>
134
+ <title>Your Biggest Mistake</title>
135
+ <identifier>385126338</identifier>
136
+ <album>Bright Lights</album>
137
+ <creator>Ellie Goulding</creator>
138
+ <duration>206000</duration>
139
+ <image>http://userserve-ak.last.fm/serve/174s/55469561.png</image>
140
+
141
+ <extension application="http://www.last.fm">
142
+ <trackauth>78adf</trackauth>
143
+ <albumid>252123763</albumid>
144
+ <artistid>31868586</artistid>
145
+ <recording>132307224</recording>
146
+
147
+ <artistpage>http://www.last.fm/music/Ellie+Goulding</artistpage>
148
+ <albumpage>http://www.last.fm/music/Ellie+Goulding/Bright+Lights</albumpage>
149
+ <trackpage>http://www.last.fm/music/Ellie+Goulding/_/Your+Biggest+Mistake</trackpage>
150
+ <buyTrackURL></buyTrackURL>
151
+ <buyAlbumURL></buyAlbumURL>
152
+ <freeTrackURL></freeTrackURL>
153
+
154
+ <loved>0</loved>
155
+ <streamid>3d301ddfe0eb8b</streamid>
156
+
157
+
158
+
159
+
160
+ </extension>
161
+ </track>
162
+ </trackList>
163
+ </playlist></lfm>
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <lfm status="ok">
3
+ <playlist version="1" xmlns="http://xspf.org/ns/0/">
4
+ <title>Pop Tag Radio</title>
5
+ <creator>Last.fm</creator>
6
+ <date>2012-12-04T01:48:10</date>
7
+ <link rel="http://www.last.fm/expiry">3600</link>
8
+ <trackList>
9
+ <track>
10
+ <location>http://play.last.fm/user/5d91bdcf9392915898ec2b35105bd2ef.mp3</location>
11
+ <title>All The Things She Said</title>
12
+ <identifier>1026968</identifier>
13
+ <album>Nachtschicht Vol. 37</album>
14
+ <creator>t.A.T.u.</creator>
15
+ <duration>207000</duration>
16
+ <image>http://userserve-ak.last.fm/serve/174s/47373527.jpg</image>
17
+
18
+ <extension application="http://www.last.fm">
19
+ <trackauth>75699</trackauth>
20
+ <albumid>234792586</albumid>
21
+ <artistid>1005290</artistid>
22
+ <recording>118782567</recording>
23
+
24
+ <artistpage>http://www.last.fm/music/t.A.T.u.</artistpage>
25
+ <albumpage>http://www.last.fm/music/Various/Nachtschicht+Vol.+37</albumpage>
26
+ <trackpage>http://www.last.fm/music/t.A.T.u./_/All+The+Things+She+Said</trackpage>
27
+ <buyTrackURL></buyTrackURL>
28
+ <buyAlbumURL></buyAlbumURL>
29
+ <freeTrackURL></freeTrackURL>
30
+
31
+ <explicit>0</explicit>
32
+ <loved>0</loved>
33
+ <streamid>8c926ea59eb105b6</streamid>
34
+
35
+
36
+
37
+
38
+ </extension>
39
+ </track>
40
+ </trackList>
41
+ </playlist></lfm>
@@ -0,0 +1,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe '#radio' do
4
+ before { init_lastfm }
5
+
6
+ it 'should return an instance of Lastfm::Radio' do
7
+ @lastfm.radio.should be_an_instance_of(Lastfm::MethodCategory::Radio)
8
+ end
9
+
10
+ describe '#tune' do
11
+ it 'should tune' do
12
+ @lastfm.should_receive(:request).with('radio.tune', {
13
+ :station => 'lastfm://globaltags/pop',
14
+ }, :post, true, true).and_return(@ok_response)
15
+ @lastfm.radio.tune("lastfm://globaltags/pop")
16
+ end
17
+ end
18
+
19
+ describe '#get_playlist' do
20
+ it 'should return some playlist' do
21
+ @lastfm.should_receive(:request).with("radio.getPlaylist", {}, :get, true, true).and_return(make_response('radio_get_playlist'))
22
+ playlist = @lastfm.radio.get_playlist
23
+ tracklist = playlist["trackList"]["track"]
24
+ tracklist.should be_an_instance_of(Array)
25
+ tracklist[0]['title'].should == "All The Things She Said"
26
+ tracklist[1]['location'].should == "http://play.last.fm/user/bca46e434c3389217ef1b8d20db1690c.mp3"
27
+ tracklist[2]['creator'].should == "Culture Club"
28
+ tracklist[3]['album'].should == "The E.N.D."
29
+ end
30
+
31
+ it 'should always return playlists with arrays of tracks' do
32
+ @lastfm.should_receive(:request).with("radio.getPlaylist", {}, :get, true, true).and_return(make_response('radio_get_playlist_single_track'))
33
+ playlist = @lastfm.radio.get_playlist
34
+ playlist["trackList"]["track"].should be_an_instance_of(Array)
35
+ end
36
+ end
37
+ end
38
+
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.13.1
4
+ version: 1.14.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: 2012-11-29 00:00:00.000000000 Z
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-simple
@@ -115,6 +115,7 @@ files:
115
115
  - lib/lastfm/method_category/event.rb
116
116
  - lib/lastfm/method_category/geo.rb
117
117
  - lib/lastfm/method_category/library.rb
118
+ - lib/lastfm/method_category/radio.rb
118
119
  - lib/lastfm/method_category/tag.rb
119
120
  - lib/lastfm/method_category/tasteometer.rb
120
121
  - lib/lastfm/method_category/track.rb
@@ -138,6 +139,8 @@ files:
138
139
  - spec/fixtures/library_get_tracks.xml
139
140
  - spec/fixtures/ng.xml
140
141
  - spec/fixtures/ok.xml
142
+ - spec/fixtures/radio_get_playlist.xml
143
+ - spec/fixtures/radio_get_playlist_single_track.xml
141
144
  - spec/fixtures/tag_get_top_artists.xml
142
145
  - spec/fixtures/tasteometer_compare.xml
143
146
  - spec/fixtures/track_get_correction.xml
@@ -174,6 +177,7 @@ files:
174
177
  - spec/method_specs/event_spec.rb
175
178
  - spec/method_specs/geo_spec.rb
176
179
  - spec/method_specs/library_spec.rb
180
+ - spec/method_specs/radio_spec.rb
177
181
  - spec/method_specs/tag_spec.rb
178
182
  - spec/method_specs/tasteometer_spec.rb
179
183
  - spec/method_specs/track_spec.rb
@@ -195,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
199
  version: '0'
196
200
  segments:
197
201
  - 0
198
- hash: 3020588867676167718
202
+ hash: -194095241316451190
199
203
  required_rubygems_version: !ruby/object:Gem::Requirement
200
204
  none: false
201
205
  requirements:
@@ -204,10 +208,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
208
  version: '0'
205
209
  segments:
206
210
  - 0
207
- hash: 3020588867676167718
211
+ hash: -194095241316451190
208
212
  requirements: []
209
213
  rubyforge_project:
210
- rubygems_version: 1.8.23
214
+ rubygems_version: 1.8.24
211
215
  signing_key:
212
216
  specification_version: 3
213
217
  summary: A ruby interface for Last.fm web services version 2.0
@@ -229,6 +233,8 @@ test_files:
229
233
  - spec/fixtures/library_get_tracks.xml
230
234
  - spec/fixtures/ng.xml
231
235
  - spec/fixtures/ok.xml
236
+ - spec/fixtures/radio_get_playlist.xml
237
+ - spec/fixtures/radio_get_playlist_single_track.xml
232
238
  - spec/fixtures/tag_get_top_artists.xml
233
239
  - spec/fixtures/tasteometer_compare.xml
234
240
  - spec/fixtures/track_get_correction.xml
@@ -265,6 +271,7 @@ test_files:
265
271
  - spec/method_specs/event_spec.rb
266
272
  - spec/method_specs/geo_spec.rb
267
273
  - spec/method_specs/library_spec.rb
274
+ - spec/method_specs/radio_spec.rb
268
275
  - spec/method_specs/tag_spec.rb
269
276
  - spec/method_specs/tasteometer_spec.rb
270
277
  - spec/method_specs/track_spec.rb