officialfm 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,20 +1,24 @@
1
- Copyright (c) 2011 Amos Wenger
1
+ Copyright (c) 2011, Amos Wenger
2
+ All rights reserved.
2
3
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+ * Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ * Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+ * Neither the name of the <organization> nor the
12
+ names of its contributors may be used to endorse or promote products
13
+ derived from this software without specific prior written permission.
10
14
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -81,7 +81,9 @@ the gem allows you to access it like this:
81
81
 
82
82
  ## Copyright
83
83
 
84
- Copyright (c) 2011 Amos Wenger. See LICENSE for details.
84
+ Copyright (c) 2011 Amos Wenger.
85
+
86
+ This project is distributed under the New BSD License. See LICENSE for details.
85
87
 
86
88
  Based on [@pengwynn's Gowalla API wrapper](https://github.com/pengwynn/gowalla)
87
89
 
data/Rakefile CHANGED
@@ -7,6 +7,7 @@ Bundler::GemHelper.install_tasks
7
7
 
8
8
  Rake::TestTask.new(:test) do |test|
9
9
  test.ruby_opts = ["-rubygems"] if defined? Gem
10
+ #test.ruby_opts << "-w"
10
11
  test.libs << "lib" << "test"
11
12
  test.pattern = "test/**/*_test.rb"
12
13
  end
data/changelog.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.3 May 18, 2011
4
+ * Added support for voted_playlists and voted_tracks requests
5
+
3
6
  ## 0.0.2 April 21, 2011
4
7
  * s/Unofficial/Official, this gem is now endorsed by official.fm
5
8
  * Playlist IDs no longer escaped
6
9
  * Removed dependency on OAuth2, as it's not needed for the Simple API
7
10
  * Better README
8
11
 
9
- ## 0.0.1 March 22, 2011
12
+ ## 0.0.1 March 23, 2011
10
13
  * Initial version
11
14
  * Supports tracks, users, playlists
12
15
  * Improved playlist support: tracks, running_time
13
-
@@ -40,6 +40,20 @@ module OfficialFM
40
40
  response.body
41
41
  end
42
42
 
43
+ # Retrieve a list of the tracks this user has voted for
44
+ #
45
+ # @param [String] user_id: id or login
46
+ # @param [Integer] limit (50) limit per page
47
+ # @param [Bool] embed (false) should embed codes be included in the response
48
+ # @return [Hashie::Mash] Track list
49
+ def voted_tracks(user_id, options={})
50
+ response = connection.get do |req|
51
+ req.url "/user/#{user_id}/voted_tracks",
52
+ :api_embed_codes => options[:embed], :api_max_responses => options[:limit]
53
+ end
54
+ response.body
55
+ end
56
+
43
57
  # Retrieve a list of the playlists of this user
44
58
  #
45
59
  # @param [String] user_id: id or login
@@ -54,6 +68,20 @@ module OfficialFM
54
68
  response.body
55
69
  end
56
70
 
71
+ # Retrieve a list of the playlists this user has voted for
72
+ #
73
+ # @param [String] user_id: id or login
74
+ # @param [Integer] limit (50) limit per page
75
+ # @param [Bool] embed (false) should embed codes be included in the response
76
+ # @return [Hashie::Mash] Playlist list
77
+ def voted_playlists(user_id, options={})
78
+ response = connection.get do |req|
79
+ req.url "/user/#{user_id}/voted_playlists",
80
+ :api_embed_codes => options[:embed], :api_max_responses => options[:limit]
81
+ end
82
+ response.body
83
+ end
84
+
57
85
  # Retrieve a list of the contacts of this user
58
86
  #
59
87
  # @param [String] user_id: id or login
@@ -95,3 +123,4 @@ module OfficialFM
95
123
 
96
124
  end
97
125
  end
126
+
@@ -1,3 +1,3 @@
1
1
  module OfficialFM
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,50 @@
1
+ [
2
+ {
3
+ "artwork_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"220\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50786?fairplayer=artwork\"></iframe>",
4
+ "comments_count":0,
5
+ "created_at":"2011-01-02 17:24:34 UTC",
6
+ "description":"",
7
+ "id":50786,
8
+ "large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50786?fairplayer=large\"></iframe>",
9
+ "length":3757,
10
+ "mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50786?fairplayer=mini\"></iframe>",
11
+ "name":"Top 20 (Most played) cover songs in 2010 ",
12
+ "password":null,
13
+ "picture_absolute_url":"http://cdn.official.fm/playlist_pictures/50/50786_small.jpg",
14
+ "plays_count":43,
15
+ "private":false,
16
+ "shuffle":false,
17
+ "small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50786?fairplayer=small\"></iframe>",
18
+ "standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50786?fairplayer=standard\"></iframe>",
19
+ "tracks":[1155,11519,64985,81107,19550,35878,70976,2408,12349,67940,12093,4149,67938,12645,78956,8277,15914],
20
+ "tracks_count":17,
21
+ "tracks_list":"1155,11519,64985,81107,19550,35878,70976,2408,12349,67940,12093,4149,67938,12645,78956,8277,15914",
22
+ "user_id":152,
23
+ "votes_count":7
24
+ }
25
+ ,
26
+ {
27
+ "artwork_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"220\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50195?fairplayer=artwork\"></iframe>",
28
+ "comments_count":0,
29
+ "created_at":"2010-12-23 18:17:14 UTC",
30
+ "description":null,
31
+ "id":50195,
32
+ "large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50195?fairplayer=large\"></iframe>",
33
+ "length":1322,
34
+ "mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50195?fairplayer=mini\"></iframe>",
35
+ "name":"top 5 2010",
36
+ "password":null,
37
+ "picture_absolute_url":"http://cdn.official.fm/track_pictures/175/175408_small.jpg",
38
+ "plays_count":9,
39
+ "private":false,
40
+ "shuffle":false,
41
+ "small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50195?fairplayer=small\"></iframe>",
42
+ "standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/playlist/50195?fairplayer=standard\"></iframe>",
43
+ "tracks":[175408,143269,139463,184871,184620],
44
+ "tracks_count":5,
45
+ "tracks_list":"175408,143269,139463,184871,184620",
46
+ "user_id":39714,
47
+ "votes_count":3
48
+ }
49
+
50
+ ]
@@ -0,0 +1,96 @@
1
+ [
2
+ {
3
+ "artist_string":"Various Artist",
4
+ "artwork_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"220\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/60526?fairplayer=artwork\"></iframe>",
5
+ "buy_url":"",
6
+ "comments_count":3,
7
+ "concatinated_genres":"Electronic",
8
+ "concatinated_tags":null,
9
+ "country_id":"FR",
10
+ "created_at":"2009-11-01 01:07:10 UTC",
11
+ "derived_by":null,
12
+ "derived_type":"original",
13
+ "description":"",
14
+ "downloadable":true,
15
+ "downloads_count":276,
16
+ "genres":["Electronic"],
17
+ "id":60526,
18
+ "isrc":null,
19
+ "label":"No Label",
20
+ "label_none":false,
21
+ "large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/60526?fairplayer=large\"></iframe>",
22
+ "length":2694,
23
+ "license_type":1,
24
+ "lyrics":null,
25
+ "mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/60526?fairplayer=mini\"></iframe>",
26
+ "original_track_id":null,
27
+ "original_track_string":null,
28
+ "password":null,
29
+ "picture_absolute_url":"http://cdn.official.fm/track_pictures/60/60526_small.jpg",
30
+ "playlists_count":3,
31
+ "plays_count":716,
32
+ "pr_url":"",
33
+ "private":false,
34
+ "require_valid_email":false,
35
+ "small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/60526?fairplayer=small\"></iframe>",
36
+ "standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/60526?fairplayer=standard\"></iframe>",
37
+ "status":"Complete",
38
+ "tags":[],
39
+ "title":"QuelqueChosed'HasBeen",
40
+ "url_1":"",
41
+ "url_1_name":"",
42
+ "url_2":"",
43
+ "url_2_name":"",
44
+ "user_id":35966,
45
+ "votes_count":18,
46
+ "web_url":""
47
+ }
48
+ ,
49
+ {
50
+ "artist_string":"Various Artist",
51
+ "artwork_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"220\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/48163?fairplayer=artwork\"></iframe>",
52
+ "buy_url":"",
53
+ "comments_count":2,
54
+ "concatinated_genres":"Electronic,Mixtape,Pop",
55
+ "concatinated_tags":null,
56
+ "country_id":"FR",
57
+ "created_at":"2009-08-08 16:12:33 UTC",
58
+ "derived_by":null,
59
+ "derived_type":"original",
60
+ "description":"",
61
+ "downloadable":true,
62
+ "downloads_count":591,
63
+ "genres":["Electronic","Mixtape","Pop"],
64
+ "id":48163,
65
+ "isrc":null,
66
+ "label":null,
67
+ "label_none":true,
68
+ "large_embed_code":"<iframe name=\"fairplayer\" width=\"220\" height=\"350\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/48163?fairplayer=large\"></iframe>",
69
+ "length":3482,
70
+ "license_type":1,
71
+ "lyrics":null,
72
+ "mini_embed_code":"<iframe name=\"fairplayer\" width=\"34\" height=\"18\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/48163?fairplayer=mini\"></iframe>",
73
+ "original_track_id":null,
74
+ "original_track_string":null,
75
+ "password":null,
76
+ "picture_absolute_url":"http://cdn.official.fm/track_pictures/48/48163_small.jpg",
77
+ "playlists_count":10,
78
+ "plays_count":896,
79
+ "pr_url":"",
80
+ "private":false,
81
+ "require_valid_email":false,
82
+ "small_embed_code":"<iframe name=\"fairplayer\" width=\"100%\" height=\"40\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/48163?fairplayer=small\"></iframe>",
83
+ "standard_embed_code":"<iframe name=\"fairplayer\" width=\"160\" height=\"240\" scrolling=\"no\" frameborder=\"0\" src=\"http://official.fm/track/48163?fairplayer=standard\"></iframe>",
84
+ "status":"Complete",
85
+ "tags":[],
86
+ "title":"SummerALaMode Mix by SALM",
87
+ "url_1":"",
88
+ "url_1_name":"",
89
+ "url_2":"",
90
+ "url_2_name":"",
91
+ "user_id":35966,
92
+ "votes_count":18,
93
+ "web_url":""
94
+ }
95
+
96
+ ]
data/test/users_test.rb CHANGED
@@ -36,6 +36,13 @@ class UsersTest < Test::Unit::TestCase
36
36
  tracks[0].artist_string.should == 'Hercules and Love Affair'
37
37
  end
38
38
 
39
+ should "retrieve the first two tracks nddrylliog has voted for" do
40
+ stub_get('http://api.official.fm/user/nddrylliog/voted_tracks?key=GNXbH3zYb25F1I7KVEEN&format=json&api_embed_codes=&api_max_responses=2', 'voted_tracks.json')
41
+ tracks = @client.voted_tracks('nddrylliog', :limit => 2)
42
+ tracks.size.should == 2
43
+ tracks[0].title.should == "QuelqueChosed'HasBeen"
44
+ end
45
+
39
46
  should "retrieve the first two playlists of chab" do
40
47
  stub_get('http://api.official.fm/user/chab/playlists?key=GNXbH3zYb25F1I7KVEEN&format=json&api_embed_codes=&api_max_responses=2', 'user_playlists.json')
41
48
  playlists = @client.user_playlists('chab', :limit => 2)
@@ -44,6 +51,13 @@ class UsersTest < Test::Unit::TestCase
44
51
  playlists[1].user_id.should == 8735 # chab's user id
45
52
  end
46
53
 
54
+ should "retrieve the first two playlists bencolon has voted for" do
55
+ stub_get('http://api.official.fm/user/bencolon/voted_playlists?key=GNXbH3zYb25F1I7KVEEN&format=json&api_embed_codes=&api_max_responses=2', 'voted_playlists.json')
56
+ playlists = @client.voted_playlists('bencolon', :limit => 2)
57
+ playlists.size.should == 2
58
+ playlists[1].id.should == 50195
59
+ end
60
+
47
61
  should "retrieve the first two contacts of chab" do
48
62
  stub_get('http://api.official.fm/user/chab/contacts?key=GNXbH3zYb25F1I7KVEEN&format=json&api_max_responses=2', 'user_contacts.json')
49
63
  contacts = @client.user_contacts('chab', :limit => 2)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: officialfm
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Amos Wenger
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-21 00:00:00 +02:00
13
+ date: 2011-05-18 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -161,6 +161,8 @@ files:
161
161
  - test/fixtures/user_subscribers.json
162
162
  - test/fixtures/user_subscriptions.json
163
163
  - test/fixtures/user_tracks.json
164
+ - test/fixtures/voted_playlists.json
165
+ - test/fixtures/voted_tracks.json
164
166
  - test/helper.rb
165
167
  - test/playlists_test.rb
166
168
  - test/tracks_test.rb
@@ -208,6 +210,8 @@ test_files:
208
210
  - test/fixtures/user_subscribers.json
209
211
  - test/fixtures/user_subscriptions.json
210
212
  - test/fixtures/user_tracks.json
213
+ - test/fixtures/voted_playlists.json
214
+ - test/fixtures/voted_tracks.json
211
215
  - test/helper.rb
212
216
  - test/playlists_test.rb
213
217
  - test/tracks_test.rb