soundcloud2 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.swp
6
+ *.swo
7
+ coverage
8
+ doc
9
+ .yardoc
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm 1.9.2
2
+ rvm gemset use soundcloud
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # Soundcloud2 API Client
2
+
3
+ Simple Ruby wrapper for the Soundcloud API.
4
+
5
+ ## Overview
6
+
7
+ This library contains two types of consumption. First there is the Soundcloud::Client (Simple Client), which offers the four basic methods to search the Soundcloud API via GROUPS, PLAYLISTS, TRACKS, and USERS. Then there are the subclass modules that extend more of the advanced API calls on the main 4 resources that Soundcloud offers. Here is a quick example of the Soundcloud::Client module notation:
8
+
9
+ client.users(:q => 'skrillex').first.city
10
+ => "melbourne"
11
+ client.tracks(:q => 'A new world').first.permalink
12
+ => "a-new-world"
13
+
14
+ ## Quick Simple Client Usage
15
+
16
+ ### Instantiate the simple Client
17
+ The client should be instantiated with a single api_key that you can obtain from this url: http://soundcloud.com/you/apps/new
18
+ Note the client is a quick way to consume and search the soundcloud API. More advanced methods can
19
+ be found in the other subclassed modules.
20
+
21
+ client = Soundcloud::Client.new('YOUR_SOUNDCLOUD_API_KEY')
22
+
23
+ ### GROUPS
24
+ client.groups(:name => 'Field Recordings')
25
+ client.groups(:description => 'field recordings from across the world')
26
+ client.groups(:q => 'dubstep')
27
+
28
+ ### PLAYLISTS
29
+ client.playlists(:title => 'Summer of 69', :sharing => 'public', :downloadable => 'false')
30
+ client.playlists(:q => 'crunk house')
31
+
32
+ ### TRACKS
33
+ client.tracks(:q => 'A New World', :bpm => 120)
34
+ client.tracks(:id => 1647583)
35
+ client.tracks(:genre => 'dubstep', :downloadable => true)
36
+ client.tracks(:genre => 'dubstep', :order => 'hotness')
37
+
38
+ ### USERS
39
+ client.users(:id => 47194613)
40
+ client.users(:city => 'greece', :description => 'badass')
41
+ client.users(:username => 'djzaxx')
42
+
43
+ ## More Advanced Modules
44
+
45
+ ### Soundcloud::Users Module
46
+ u = Soundcloud::Users.new('YOUR_SOUNDCLOUD_API_KEY')
47
+ u.user('4201929')
48
+ u.user_tracks('4201929')
49
+ u.user_playlists('4201929')
50
+ u.user_followings('4201929')
51
+ u.user_followings('4201929', '1931470')
52
+ u.user_followers('4201929')
53
+ u.user_followers('4201929', '1931470')
54
+ u.user_comments('4201929')
55
+ u.user_favorites('4201929')
56
+ u.user_favorites('4201929', '1931470')
57
+ u.user_groups('4201929')
58
+
59
+ ### Soundcloud::Tracks Module
60
+ t = Soundcloud::Tracks.new('YOUR_SOUNDCLOUD_API_KEY')
61
+ t.tracks('20296934')
62
+ t.tracks_comments('20296934')
63
+ t.tracks_comments('20296934', '23145109')
64
+ t.tracks_favoriters('20296934')
65
+ t.tracks_favoriters('20296934', '2769794')
66
+ t.tracks_shared_to_users('20296934')
67
+ t.tracks_shared_to_emails('20296934')
68
+
69
+ ### Soundcloud::Playlists Module
70
+ p = Soundcloud::Playlists.new('YOUR_SOUNDCLOUD_API_KEY')
71
+ p.playlists('920731')
72
+ p.playlists_shared_to_users('4201929')
73
+ p.playlists_shared_to_emails('amanelis@gmail.com')
74
+
75
+ ### Soundcloud::Groups Module
76
+ g = Soundcloud::Groups.new('YOUR_SOUNDCLOUD_API_KEY')
77
+ g.groups('11440')
78
+ g.groups_moderators('11440')
79
+ g.groups_members('11440')
80
+ g.groups_contributors('11440')
81
+ g.groups_users('11440')
82
+ g.groups_tracks('11440')
83
+
84
+ ### Soundcloud::Comments Module
85
+ c = Soundcloud::Comments.new('YOUR_SOUNDCLOUD_API_KEY')
86
+ c.comments('23145109')
87
+
88
+
89
+ ## Dependencies
90
+ #### Install dependencies using bundler
91
+ $ bundle
92
+
93
+ #### Run rSpec
94
+ $ rspec -fp spec/client
95
+
96
+ ## Issues
97
+ None.
98
+
99
+ ## Changelog
100
+
101
+ ### 0.0.1 - Aug 6th, 2011
102
+
103
+ * Initial version
104
+
105
+
106
+ ## Under the hood
107
+ * [`Faraday`](https://github.com/technoweenie/faraday) REST client
108
+ * [`Hashie::Mash`](http://github.com/intridea/hashie) Magic
109
+
110
+ ## How to contribute
111
+
112
+ * Fork the project.
113
+ * Make your feature addition or bug fix.
114
+ * Add tests for it. This is important so I don't break it in a
115
+ future version unintentionally.
116
+ * Commit, do not mess with rakefile, version, or history.
117
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
118
+ * Send me a pull request. Bonus points for topic branches.
119
+
120
+ Copyright (c) 2011 [Alex Manelis](http://twitter.com/amanelis).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,5 @@
1
+ class Array
2
+ def extract_options!
3
+ last.is_a?(::Hash) ? pop : {}
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ module Soundcloud2
2
+ class Comments < Client
3
+ attr_reader :api_key, :conn
4
+
5
+ # Initialize on the Soundcloud::Client class
6
+ def initialize(*args)
7
+ super
8
+ end
9
+
10
+ # GET /comments/{id} a group
11
+ def comments(*args)
12
+ options = args.extract_options!.merge(:client_id => api_key)
13
+ response = conn.get("/comments/#{args[0]}.json") { |req| req.params = options }
14
+ args.nil? ? response.body.send(sym) : response.body
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,52 @@
1
+ module Soundcloud2
2
+ class Groups < Client
3
+ attr_reader :api_key, :conn
4
+
5
+ # Initialize on the Soundcloud::Client class
6
+ def initialize(*args)
7
+ super
8
+ end
9
+
10
+ # GET /groups/{id} a group
11
+ def groups(*args)
12
+ options = args.extract_options!.merge(:client_id => api_key)
13
+ response = conn.get("/groups/#{args[0]}.json") { |req| req.params = options }
14
+ args.nil? ? response.body.send(sym) : response.body
15
+ end
16
+
17
+ # GET /groups/{id}/moderators list of users who moderate the group
18
+ def groups_moderators(*args)
19
+ options = args.extract_options!.merge(:client_id => api_key)
20
+ response = conn.get("/groups/#{args[0]}/moderators.json") { |req| req.params = options }
21
+ args.nil? ? response.body.send(sym) : response.body
22
+ end
23
+
24
+ # GET /groups/{id}/members list of users who joined the group
25
+ def groups_members(*args)
26
+ options = args.extract_options!.merge(:client_id => api_key)
27
+ response = conn.get("/groups/#{args[0]}/members.json") { |req| req.params = options }
28
+ args.nil? ? response.body.send(sym) : response.body
29
+ end
30
+
31
+ # GET /groups/{id}/contributors list of users who contributed a track to the group
32
+ def groups_contributors(*args)
33
+ options = args.extract_options!.merge(:client_id => api_key)
34
+ response = conn.get("/groups/#{args[0]}/contributors.json") { |req| req.params = options }
35
+ args.nil? ? response.body.send(sym) : response.body
36
+ end
37
+
38
+ # GET /groups/{id}/users list of users who contributed to, joined or moderate the group
39
+ def groups_users(*args)
40
+ options = args.extract_options!.merge(:client_id => api_key)
41
+ response = conn.get("/groups/#{args[0]}/users.json") { |req| req.params = options }
42
+ args.nil? ? response.body.send(sym) : response.body
43
+ end
44
+
45
+ # GET /groups/{id}/tracks list of contributed and approved tracks
46
+ def groups_tracks(*args)
47
+ options = args.extract_options!.merge(:client_id => api_key)
48
+ response = conn.get("/groups/#{args[0]}/tracks.json") { |req| req.params = options }
49
+ args.nil? ? response.body.send(sym) : response.body
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,31 @@
1
+ module Soundcloud2
2
+ class Playlists < Client
3
+ attr_reader :api_key, :conn
4
+
5
+ # Initialize on the Soundcloud::Client class
6
+ def initialize(*args)
7
+ super
8
+ end
9
+
10
+ def playlists(*args)
11
+ options = args.extract_options!.merge(:client_id => api_key)
12
+ response = conn.get("/playlists/#{args[0]}.json") { |req| req.params = options }
13
+ args.nil? ? response.body.send(sym) : response.body
14
+ end
15
+
16
+ # GET /playlists/{id}/shared-to/users users who have access to the track
17
+ def playlists_shared_to_users(*args)
18
+ options = args.extract_options!.merge(:client_id => api_key)
19
+ response = conn.get("/playlists/#{args[0]}/shared-to/users.json") { |req| req.params = options }
20
+ args.nil? ? response.body.send(sym) : response.body
21
+ end
22
+
23
+ # GET /playlists/{id}/shared-to/emails email addresses who are invited to the playlist
24
+ def playlists_shared_to_emails(*args)
25
+ options = args.extract_options!.merge(:client_id => api_key)
26
+ response = conn.get("/playlists/#{args[0]}/shared-to/emails.json") { |req| req.params = options }
27
+ args.nil? ? response.body.send(sym) : response.body
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,55 @@
1
+ module Soundcloud2
2
+ class Tracks < Client
3
+ attr_reader :api_key, :conn
4
+
5
+ # Initialize on the Soundcloud::Client class
6
+ def initialize(*args)
7
+ super
8
+ end
9
+
10
+ # GET /tracks/{id} a user
11
+ def tracks(*args)
12
+ options = args.extract_options!.merge(:client_id => api_key)
13
+ response = conn.get("/tracks/#{args[0]}.json") { |req| req.params = options }
14
+ args.nil? ? response.body.send(sym) : response.body
15
+ end
16
+
17
+ # GET /tracks/{id}/comments comments for the track
18
+ # GET /tracks/{id}/comments/{comment-id} a comment for the track
19
+ def tracks_comments(*args)
20
+ options = args.extract_options!.merge(:client_id => api_key)
21
+ response = conn.get("/tracks/#{args[0]}/comments.json") { |req| req.params = options }
22
+ args[1].nil? ? (response = conn.get("/tracks/#{args[0]}/comments.json") { |req| req.params = options }) : (response = conn.get("/tracks/#{args[0]}/comments/#{args[1]}.json") { |req| req.params = options })
23
+ args.nil? ? response.body.send(sym) : response.body
24
+ end
25
+
26
+ # GET /tracks/{id}/favoriters users who favorited the track
27
+ # GET /tracks/{id}/favoriters/{user-id} a user who has favorited to the track
28
+ def tracks_favoriters(*args)
29
+ options = args.extract_options!.merge(:client_id => api_key)
30
+ args[1].nil? ? (response = conn.get("/tracks/#{args[0]}/favoriters.json") { |req| req.params = options }) : (response = conn.get("/tracks/#{args[0]}/favoriters/#{args[1]}.json") { |req| req.params = options })
31
+ args.nil? ? response.body.send(sym) : response.body
32
+ end
33
+
34
+ # GET /tracks/{id}/shared-to/users users who have access to the track
35
+ def tracks_shared_to_users(*args)
36
+ options = args.extract_options!.merge(:client_id => api_key)
37
+ response = conn.get("/tracks/#{args[0]}/shared-to/users.json") { |req| req.params = options }
38
+ args.nil? ? response.body.send(sym) : response.body
39
+ end
40
+
41
+ # GET /tracks/{id}/shared-to/emails email addresses who are invited to the track
42
+ def tracks_shared_to_emails(*args)
43
+ options = args.extract_options!.merge(:client_id => api_key)
44
+ response = conn.get("/tracks/#{args[0]}/shared-to/emails.json") { |req| req.params = options }
45
+ args.nil? ? response.body.send(sym) : response.body
46
+ end
47
+
48
+ # GET /tracks/{id}/secret-token secret token of the track
49
+ def tracks_secret_token(*args)
50
+ options = args.extract_options!.merge(:client_id => api_key)
51
+ response = conn.get("/tracks/#{args[0]}/secret-token.json") { |req| req.params = options }
52
+ args.nil? ? response.body.send(sym) : response.body
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,82 @@
1
+ module Soundcloud2
2
+ class Users < Client
3
+ attr_reader :api_key, :conn
4
+
5
+ # Initialize on the Soundcloud::Client class
6
+ def initialize(*args)
7
+ super
8
+ end
9
+
10
+ # GET /users/{id} a user
11
+ def users(*args)
12
+ options = args.extract_options!.merge(:client_id => api_key)
13
+ response = conn.get("/users/#{args[0]}.json") { |req| req.params = options }
14
+ args.nil? ? response.body.send(sym) : response.body
15
+ end
16
+
17
+ # GET /users/{id}/tracks list of tracks of the user
18
+ def users_tracks(*args)
19
+ options = args.extract_options!.merge(:client_id => api_key)
20
+ response = conn.get("/users/#{args[0]}/tracks.json") { |req| req.params = options }
21
+ args.nil? ? response.body.send(sym) : response.body
22
+ end
23
+
24
+ # GET /users/{id}/playlists list of playlists (sets) of the user
25
+ def users_playlists(*args)
26
+ options = args.extract_options!.merge(:client_id => api_key)
27
+ response = conn.get("/users/#{args[0]}/playlists.json") { |req| req.params = options }
28
+ args.nil? ? response.body.send(sym) : response.body
29
+ end
30
+
31
+ # GET /users/{id}/followings a users followings
32
+ # GET /users/{id}/followings/{id} a user who is followed by the user
33
+ def users_followings(*args)
34
+ options = args.extract_options!.merge(:client_id => api_key)
35
+ args[1].nil? ? (response = conn.get("/users/#{args[0]}/followings.json") { |req| req.params = options }) : (response = conn.get("/users/#{args[0]}/followings/#{args[1]}.json") { |req| req.params = options })
36
+ args.nil? ? response.body.send(sym) : response.body
37
+ end
38
+
39
+ # GET /users/{id}/followers a users followers
40
+ # GET /users/{id}/followers/{id} user who is following the user
41
+ def users_followers(*args)
42
+ options = args.extract_options!.merge(:client_id => api_key)
43
+ args[1].nil? ? (response = conn.get("/users/#{args[0]}/followers.json") { |req| req.params = options }) : (response = conn.get("/users/#{args[0]}/followers/#{args[1]}.json") { |req| req.params = options })
44
+ args.nil? ? response.body.send(sym) : response.body
45
+ end
46
+
47
+ # GET /users/{id}/comments list of comments from this user
48
+ def users_comments(*args)
49
+ options = args.extract_options!.merge(:client_id => api_key)
50
+ response = conn.get("/users/#{args[0]}/comments.json") { |req| req.params = options }
51
+ args.nil? ? response.body.send(sym) : response.body
52
+ end
53
+
54
+ # GET /users/{id}/favorites users favorites
55
+ # GET /users/{id}/favorites/{id} track favorited by the user
56
+ def users_favorites(*args)
57
+ options = args.extract_options!.merge(:client_id => api_key)
58
+ args[1].nil? ? (response = conn.get("/users/#{args[0]}/favorites.json") { |req| req.params = options }) : (response = conn.get("/users/#{args[0]}/favorites/#{args[1]}.json") { |req| req.params = options })
59
+ args.nil? ? response.body.send(sym) : response.body
60
+ end
61
+
62
+ # GET /users/{id}/groups list of joined groups
63
+ def users_groups(*args)
64
+ options = args.extract_options!.merge(:client_id => api_key)
65
+ response = conn.get("/users/#{args[0]}/groups.json") { |req| req.params = options }
66
+ args.nil? ? response.body.send(sym) : response.body
67
+ end
68
+
69
+ # def method_missing(sym, *args, &block)
70
+ # options = args.extract_options!.merge(:client_id => api_key)
71
+ # if sym.to_s == "users"
72
+ # response = conn.get("/users/#{args[0]}.json") { |req| req.params = options }
73
+ # elsif args[1].nil?
74
+ # response = conn.get("/users/#{args[0]}.json") { |req| req.params = options }
75
+ # else
76
+ # response = conn.get("/users/#{args[0]}/#{sym.to_s}/#{args[1]}.json") { |req| req.params = options }
77
+ # end
78
+ # args.nil? ? response.body.send(sym) : response.body
79
+ # end
80
+
81
+ end
82
+ end
@@ -0,0 +1,3 @@
1
+ module Soundcloud2
2
+ VERSION = "0.3.1"
3
+ end
@@ -0,0 +1,146 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+ require 'core_ext/array'
4
+ require 'yajl'
5
+
6
+ module Soundcloud2
7
+ class Client
8
+ attr_reader :api_key, :conn
9
+
10
+ def initialize(*args)
11
+ options = args.extract_options!
12
+ @api_key = args[0]
13
+ @conn = Faraday.new(:url => "https://api.soundcloud.com/") do |builder|
14
+ builder.use Faraday::Response::Mashify
15
+ builder.use Faraday::Response::ParseJson
16
+ builder.adapter Faraday.default_adapter
17
+ end
18
+ end
19
+
20
+ # PROPERTIES OF GROUPS API
21
+ # id integer ID 123
22
+ # uri API resource URL http://api.soundcloud.com/comments/32562
23
+ # created_at timestamp of creation "2009/08/13 18:30:10 +0000"
24
+ # permalink permalink of the resource "summer-of-69"
25
+ # permalink_url URL to the SoundCloud.com page "http://soundcloud.com/bryan/summer-of-69"
26
+ # artwork_url URL to a JPEG image "http://i1.sndcdn.com/a....-large.jpg?142a848"
27
+ # name name of the group "Field Recordings"
28
+ # description description of the group "field recordings from across the world"
29
+ # short_description short description of the group "field recordings!"
30
+ # creator mini user representation of the owner {id: 343, username: "Doctor Wilson"...}
31
+ def groups(*args); super; end
32
+
33
+ # PROPERTIES OF PLAYLISTS API
34
+ # id integer ID 123
35
+ # created_at timestamp of creation "2009/08/13 18:30:10 +0000"
36
+ # user-id user-id of the owner 343
37
+ # user mini user representation of the owner {id: 343, username: "Doctor Wilson"...}
38
+ # title track title "Summer of 69"
39
+ # permalink permalink of the resource "summer-of-69"
40
+ # permalink_url URL to the SoundCloud.com page "http://soundcloud.com/bryan/summer-of-69"
41
+ # uri API resource URL "http://api.soundcloud.com/tracks/123"
42
+ # sharing public/private sharing "public"
43
+ # purchase_url external purchase link "http://amazon.com/buy/a43aj0b03"
44
+ # artwork_url URL to a JPEG image "http://i1.sndcdn.com/a....-large.jpg?142a848"
45
+ # description HTML description "my first track"
46
+ # downloadable downloadable (boolean) false
47
+ # streamable streamable via API (boolean) true
48
+ # label label mini user object {id:123, username: "BeatLabel"...}
49
+ # duration duration in milliseconds 1203400
50
+ # genre genre "HipHop"
51
+ # shared_to_count number of sharings (if private) 45
52
+ # tag_list list of tags "tag1 \"hip hop\" geo:lat=32.444 geo:lon=55.33"
53
+ # label_id id of the label user 54677
54
+ # label_name label name "BeatLabel"
55
+ # license creative common license "no-rights-reserved"
56
+ # release release number 3234
57
+ # release_day day of the release 21
58
+ # release_month month of the release 5
59
+ # release_year year of the release 2001
60
+ # ean EAN identifier for the playlist "123-4354345-43"
61
+ # playlist_type playlist type "recording"
62
+ def playlists(*args); super; end
63
+
64
+ # PROPERTIES OF TRACKS API
65
+ # id integer ID 123
66
+ # created_at timestamp of creation "2009/08/13 18:30:10 +0000"
67
+ # user-id user-id of the owner 343
68
+ # user mini user representation of the owner {id: 343, username: "Doctor Wilson"...}
69
+ # title track title "Summer of 69"
70
+ # permalink permalink of the resource "summer-of-69"
71
+ # permalink_url URL to the SoundCloud.com page "http://soundcloud.com/bryan/summer-of-69"
72
+ # uri API resource URL "http://api.soundcloud.com/tracks/123"
73
+ # sharing public/private sharing "public"
74
+ # purchase_url external purchase link "http://amazon.com/buy/a43aj0b03"
75
+ # artwork_url URL to a JPEG image "http://i1.sndcdn.com/a....-large.jpg?142a848"
76
+ # description HTML description "my first track"
77
+ # downloadable downloadable (boolean) false
78
+ # streamable streamable via API (boolean) true
79
+ # label label mini user object {id:123, username: "BeatLabel"...}
80
+ # duration duration in milliseconds 1203400
81
+ # genre genre "HipHop"
82
+ # shared_to_count number of sharings (if private) 45
83
+ # tag_list list of tags "tag1 \"hip hop\" geo:lat=32.444 geo:lon=55.33"
84
+ # label_id id of the label user 54677
85
+ # label_name label name "BeatLabel"
86
+ # license creative common license "no-rights-reserved"
87
+ # release release number 3234
88
+ # release_day day of the release 21
89
+ # release_month month of the release 5
90
+ # release_year year of the release 2001
91
+ # state encoding state "finished"
92
+ # track_type track type "recording"
93
+ # waveform_url URL to PNG waveform image "http://w1.sndcdn.com/fxguEjG4ax6B_m.png"
94
+ # download_url URL to original file "http://api.soundcloud.com/tracks/3/download"
95
+ # stream_url link to 128kbs mp3 stream "http://api.soundcloud.com/tracks/3/stream"
96
+ # bpm beats per minute 120
97
+ # commentable track commentable (boolean) true
98
+ # isrc track ISRC "I123-545454"
99
+ # key_signature track key "Cmaj"
100
+ # comment_count track comment count 12
101
+ # download_count track download count 45
102
+ # playback_count track play count 435
103
+ # favoritings_count track favoriting count 6
104
+ # original_format file format of the original file "aiff"
105
+ # created_with the app that the track created {"id"=>3434, "..."=>nil}
106
+ # asset_data binary data of the audio file (only for uploading)
107
+ # artwork_data binary data of the artwork image (only for uploading)
108
+ # user_favorite track favorite of current user (boolean, authenticated requests only) 1
109
+ def tracks(*args); super; end
110
+
111
+ # PROPERTIES OF USERS API
112
+ # id integer ID 123
113
+ # permalink permalink of the resource "summer-of-69"
114
+ # username username "Doctor Wilson"
115
+ # uri API resource URL http://api.soundcloud.com/comments/32562
116
+ # permalink_url URL to the SoundCloud.com page "http://soundcloud.com/bryan/summer-of-69"
117
+ # avatar_url URL to a JPEG image "http://i1.sndcdn.com/a....-large.jpg?142a848"
118
+ # country country "Germany"
119
+ # full_name first and last name "Tom Wilson"
120
+ # city city "Berlin"
121
+ # description description "Another brick in the wall"
122
+ # discogs-name Discogs name "myrandomband"
123
+ # myspace-name MySpace name "myrandomband"
124
+ # website a URL to the website "http://facebook.com/myrandomband"
125
+ # website-title a custom title for the website "myrandomband on Facebook"
126
+ # online online status (boolean) true
127
+ # track_count number of public tracks 4
128
+ # playlist_count number of public playlists 5
129
+ # followers_count number of followers 54
130
+ # followings_count number of followed users 75
131
+ # public_favorites_count number of favorited public tracks 7
132
+ def users(*args); super; end
133
+
134
+ def method_missing(sym, *args, &block)
135
+ options = args.extract_options!.merge(:client_id => api_key)
136
+ response = conn.get("/#{sym.to_s}.json") { |req| req.params = options }
137
+ args.nil? ? response.body.send(sym) : response.body
138
+ end
139
+ end
140
+
141
+ autoload :Comments, "soundcloud2/comments"
142
+ autoload :Groups, "soundcloud2/groups"
143
+ autoload :Playlists, "soundcloud2/playlists"
144
+ autoload :Tracks, "soundcloud2/tracks"
145
+ autoload :Users, "soundcloud2/users"
146
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "soundcloud2/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "soundcloud2"
7
+ s.version = Soundcloud2::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Alex Manelis"]
10
+ s.email = ["amanelis@console.fm"]
11
+ s.homepage = "http://github.com/amanelis/soundcloud2"
12
+ s.summary = %q{A wrapper for the Soundcloud v2 API}
13
+ s.description = %q{A wrapper for the Soundcloud v2 API}
14
+
15
+ s.rubyforge_project = "soundcloud2"
16
+ s.add_development_dependency('rake', '~> 0.8')
17
+ s.add_development_dependency('rspec', '~> 2.5')
18
+ s.add_development_dependency('simplecov', '~> 0.4')
19
+ s.add_development_dependency('vcr', '~> 1.7.0')
20
+ s.add_development_dependency('fakeweb')
21
+ s.add_development_dependency('yard', '~> 0.6')
22
+ s.add_development_dependency('maruku', '~> 0.6')
23
+ s.add_runtime_dependency("faraday", '~> 0.7.4')
24
+ s.add_runtime_dependency("faraday_middleware", '~> 0.7.0')
25
+ s.add_runtime_dependency('hashie', '~> 1.1.0')
26
+ s.add_runtime_dependency('yajl-ruby', '~> 0.8.1')
27
+ s.add_runtime_dependency('multi_json', '~> 1.0.3')
28
+
29
+ s.files = `git ls-files`.split("\n")
30
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
+ s.require_paths = ["lib"]
33
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Soundcloud2::Client do
4
+ context "Client" do
5
+ before(:all) do
6
+ @client = Soundcloud2::Client.new(API_KEY)
7
+ end
8
+
9
+ it ".initialize" do
10
+ puts "TESTING: .api_key"
11
+ puts "TESTING: .inspect"
12
+ puts @client.api_key
13
+ puts @client.inspect
14
+ end
15
+
16
+ it ".groups" do
17
+ puts "TESTING: .groups"
18
+ data = @client.groups(:q => 'dubstep')
19
+ puts data.inspect
20
+ end
21
+
22
+ it ".playlists" do
23
+ puts "TESTING: .playlists"
24
+ data = @client.playlists(:q => 'dubstep')
25
+ puts data.inspect
26
+ end
27
+
28
+ it ".tracks" do
29
+ puts "TESTING: .tracks"
30
+ data = @client.tracks(:q => 'A new world')
31
+ puts data.inspect
32
+ end
33
+
34
+ it ".users" do
35
+ puts "TESTING: .users"
36
+ data = @client.users(:q => 'skrillex')
37
+ puts data.inspect
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Soundcloud2::Comments do
4
+ context "Comments" do
5
+ before(:all) do
6
+ @comments = Soundcloud2::Comments.new(API_KEY)
7
+ end
8
+
9
+ it ".initialize" do
10
+ puts "TESTING: .initialize"
11
+ puts @comments.api_key
12
+ puts @comments.inspect
13
+ end
14
+
15
+ it ".groups" do
16
+ puts "TESTING: .groups"
17
+ puts @comments.comments('23145109')
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Soundcloud2::Groups do
4
+ context "Groups" do
5
+ before(:all) do
6
+ @groups = Soundcloud2::Groups.new(API_KEY)
7
+ end
8
+
9
+ it ".initialize" do
10
+ puts "TESTING: .initialize"
11
+ puts @groups.api_key
12
+ puts @groups.inspect
13
+ end
14
+
15
+ it ".groups" do
16
+ puts "TESTING: .groups"
17
+ puts @groups.groups('11440')
18
+ end
19
+
20
+ it ".groups_moderators" do
21
+ puts "TESTING: .groups_moderators"
22
+ puts @groups.groups_moderators('11440')
23
+ end
24
+
25
+ it ".groups_members" do
26
+ puts "TESTING: .groups_members"
27
+ puts @groups.groups_members('11440')
28
+ end
29
+
30
+ it ".groups_contributors" do
31
+ puts "TESTING: .groups_contributors"
32
+ puts @groups.groups_contributors('11440')
33
+ end
34
+
35
+ it ".groups_users" do
36
+ puts "TESTING: .groups_users"
37
+ puts @groups.groups_users('11440')
38
+ end
39
+
40
+ it ".groups_tracks" do
41
+ puts "TESTING: .groups_tracks"
42
+ puts @groups.groups_tracks('11440')
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Soundcloud2::Playlists do
4
+ context "Playlists" do
5
+ before(:all) do
6
+ @playlists = Soundcloud2::Playlists.new(API_KEY)
7
+ end
8
+
9
+ it ".initialize" do
10
+ puts "TESTING: .initialize"
11
+ puts @playlists.api_key
12
+ puts @playlists.inspect
13
+ end
14
+
15
+ it ".playlists" do
16
+ puts "TESTING: .playlists"
17
+ puts @playlists.playlists('920731')
18
+ end
19
+
20
+ it ".playlists_shared_to_users" do
21
+ puts "TESTING: .playlists_shared_to_users"
22
+ puts @playlists.playlists_shared_to_users('4201929')
23
+ end
24
+
25
+ it ".playlists_shared_to_emails" do
26
+ puts "TESTING: .playlists_shared_to_emails"
27
+ puts @playlists.playlists_shared_to_emails('amanelis')
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Soundcloud2::Client do
4
+ context "Client" do
5
+ before(:all) do
6
+ @client = Soundcloud2::Client.new(API_KEY)
7
+ @tracks = Soundcloud2::Tracks.new(API_KEY)
8
+ end
9
+
10
+ it "Soundcloud2::Client.new(API_KEY).tracks" do
11
+ puts "---------------------------------------------------------"
12
+ puts "Soundcloud::Client.new(API_KEY).tracks(:q => 'Song title')"
13
+ results = Array.new
14
+ results << @client.tracks(:q => 'Skrillex - Do Da Oliphant')
15
+ results << @client.tracks(:q => 'Kryder K2')
16
+ results << @client.tracks(:q => 'Ry Legit - Woody (CLIP)')
17
+ results << @client.tracks(:q => 'Oblivion Feat. Ashley Merges - Bass Freq (Oblivion VIP) [FREE DOWNLOAD]')
18
+ results << @client.tracks(:q => 'Kayla ft. Lil Jon - Step On It (Proper Villains remix)')
19
+ results << @client.tracks(:q => 'Supreme - The Fortress (P0GMAN Remix) (CLIP) [FORTHCOMING BADMAN DIGITAL]')
20
+ results << @client.tracks(:q => 'Dubsidia & Balkansky - Annoying Dog (Original Mix) DEMO Play Me Records')
21
+
22
+ results.each do |r|
23
+ s = r.first
24
+
25
+ puts "Song Title: #{s.title}"
26
+ puts "Song id: #{s.id}"
27
+ puts "Genre: #{s.genre}"
28
+ puts "Slug: #{s.permalink}"
29
+ puts "Comments: #{s.comment_count}"
30
+ puts "Downloads: #{s.download_count}"
31
+ puts "Playbacks: #{s.playback_count}"
32
+ puts "Favorites: #{s.favoritings_count}"
33
+ puts "https://api.soundcloud.com/tracks/#{s.id}/stream?client_id=281bf78db858fb70bf8ccef48976dde4"
34
+ puts "*********************************************************************************************"
35
+ puts s.inspect
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,50 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Soundcloud2::Tracks do
4
+ context "Tracks" do
5
+ before(:all) do
6
+ @tracks = Soundcloud2::Tracks.new(API_KEY)
7
+ end
8
+
9
+ it ".initialize" do
10
+ puts "TESTING: .initialize"
11
+ puts @tracks.api_key
12
+ puts @tracks.inspect
13
+ end
14
+
15
+ it ".tracks" do
16
+ puts "TESTING: .tracks"
17
+ puts @tracks.tracks('20296934')
18
+ end
19
+
20
+ it ".tracks_comments" do
21
+ puts "TESTING: .tracks_comments"
22
+ puts @tracks.tracks_comments('20296934')
23
+ end
24
+
25
+ it ".tracks_comments/:id" do
26
+ puts "TESTING: .tracks_comments/:id"
27
+ puts @tracks.tracks_comments('20296934', '23145109')
28
+ end
29
+
30
+ it ".tracks_favoriters" do
31
+ puts "TESTING: .tracks_favoriters"
32
+ puts @tracks.tracks_favoriters('20296934')
33
+ end
34
+
35
+ it ".tracks_favoriters/:id" do
36
+ puts "TESTING: .tracks_favoriters/:id"
37
+ puts @tracks.tracks_favoriters('20296934', '2769794')
38
+ end
39
+
40
+ it ".tracks_shared_to_users" do
41
+ puts "TESTING: .tracks_shared_to_users"
42
+ puts @tracks.tracks_shared_to_users('20296934')
43
+ end
44
+
45
+ it ".tracks_shared_to_emails" do
46
+ puts "TESTING: .tracks_shared_to_emails"
47
+ puts @tracks.tracks_shared_to_emails('20296934')
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,71 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Soundcloud2::Users do
4
+ context "Users" do
5
+ before(:all) do
6
+ @users = Soundcloud2::Users.new(API_KEY)
7
+ end
8
+
9
+ it ".initialize" do
10
+ puts "TESTING: .initialize"
11
+ puts @users.api_key
12
+ puts @users.inspect
13
+ end
14
+
15
+ it ".users" do
16
+ puts "TESTING: .users"
17
+ puts @users.users('4201929')
18
+ end
19
+
20
+ it ".users_tracks" do
21
+ puts "TESTING: .users_tracks"
22
+ puts @users.users_tracks('4201929')
23
+ end
24
+
25
+ it ".users_playlists" do
26
+ puts "TESTING: .users_playlists"
27
+ puts @users.users_playlists('4201929')
28
+ end
29
+
30
+ it ".users_followings" do
31
+ puts "TESTING: .users_followings"
32
+ puts @users.users_followings('4201929')
33
+ end
34
+
35
+ it ".users_followings/:id" do
36
+ puts "TESTING: .users_followings/:id"
37
+ puts @users.users_followings('4201929', '1931470')
38
+ end
39
+
40
+ it ".users_followers" do
41
+ puts "TESTING: .users_followers"
42
+ puts @users.users_followers('4201929')
43
+ end
44
+
45
+ it ".users_followers/:id" do
46
+ puts "TESTING: .users_followers/:id"
47
+ puts @users.users_followers('4201929', '1931470')
48
+ end
49
+
50
+ it ".users_comments" do
51
+ puts "TESTING: .users_comments"
52
+ puts @users.users_comments('4201929')
53
+ end
54
+
55
+ it ".users_favorites" do
56
+ puts "TESTING: .users_favorites"
57
+ puts @users.users_favorites('4201929')
58
+ end
59
+
60
+ it ".users_favorites/:id" do
61
+ puts "TESTING: .users_favorites/:id"
62
+ puts @users.users_favorites('4201929', '1931470')
63
+ end
64
+
65
+ it ".users_groups" do
66
+ puts "TESTING: .users_groups"
67
+ puts @users.users_groups('4201929')
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,13 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_group 'Soundcloud2', 'lib/soundcloud2'
5
+ add_group 'Specs', 'spec'
6
+ end
7
+
8
+ require File.expand_path('../../lib/soundcloud2', __FILE__)
9
+ require 'rubygems'
10
+ require 'rspec'
11
+ require 'vcr'
12
+
13
+ API_KEY = "734a173874da8c420aeb59fd03623454"
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soundcloud2
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.3.1
6
+ platform: ruby
7
+ authors:
8
+ - Alex Manelis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-08-15 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "0.8"
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: "2.5"
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: simplecov
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: "0.4"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: vcr
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.7.0
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: fakeweb
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: yard
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: "0.6"
79
+ type: :development
80
+ version_requirements: *id006
81
+ - !ruby/object:Gem::Dependency
82
+ name: maruku
83
+ prerelease: false
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: "0.6"
90
+ type: :development
91
+ version_requirements: *id007
92
+ - !ruby/object:Gem::Dependency
93
+ name: faraday
94
+ prerelease: false
95
+ requirement: &id008 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ version: 0.7.4
101
+ type: :runtime
102
+ version_requirements: *id008
103
+ - !ruby/object:Gem::Dependency
104
+ name: faraday_middleware
105
+ prerelease: false
106
+ requirement: &id009 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: 0.7.0
112
+ type: :runtime
113
+ version_requirements: *id009
114
+ - !ruby/object:Gem::Dependency
115
+ name: hashie
116
+ prerelease: false
117
+ requirement: &id010 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ~>
121
+ - !ruby/object:Gem::Version
122
+ version: 1.1.0
123
+ type: :runtime
124
+ version_requirements: *id010
125
+ - !ruby/object:Gem::Dependency
126
+ name: yajl-ruby
127
+ prerelease: false
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.8.1
134
+ type: :runtime
135
+ version_requirements: *id011
136
+ - !ruby/object:Gem::Dependency
137
+ name: multi_json
138
+ prerelease: false
139
+ requirement: &id012 !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ~>
143
+ - !ruby/object:Gem::Version
144
+ version: 1.0.3
145
+ type: :runtime
146
+ version_requirements: *id012
147
+ description: A wrapper for the Soundcloud v2 API
148
+ email:
149
+ - amanelis@console.fm
150
+ executables: []
151
+
152
+ extensions: []
153
+
154
+ extra_rdoc_files: []
155
+
156
+ files:
157
+ - .gitignore
158
+ - .rvmrc
159
+ - Gemfile
160
+ - README.md
161
+ - Rakefile
162
+ - lib/core_ext/array.rb
163
+ - lib/soundcloud2.rb
164
+ - lib/soundcloud2/comments.rb
165
+ - lib/soundcloud2/groups.rb
166
+ - lib/soundcloud2/playlists.rb
167
+ - lib/soundcloud2/tracks.rb
168
+ - lib/soundcloud2/users.rb
169
+ - lib/soundcloud2/version.rb
170
+ - soundcloud2.gemspec
171
+ - spec/client/client_spec.rb
172
+ - spec/client/comments_spec.rb
173
+ - spec/client/groups_spec.rb
174
+ - spec/client/playlists_spec.rb
175
+ - spec/client/search_tracks.rb
176
+ - spec/client/tracks_spec.rb
177
+ - spec/client/users_spec.rb
178
+ - spec/spec_helper.rb
179
+ homepage: http://github.com/amanelis/soundcloud2
180
+ licenses: []
181
+
182
+ post_install_message:
183
+ rdoc_options: []
184
+
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ none: false
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: "0"
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: "0"
199
+ requirements: []
200
+
201
+ rubyforge_project: soundcloud2
202
+ rubygems_version: 1.8.7
203
+ signing_key:
204
+ specification_version: 3
205
+ summary: A wrapper for the Soundcloud v2 API
206
+ test_files:
207
+ - spec/client/client_spec.rb
208
+ - spec/client/comments_spec.rb
209
+ - spec/client/groups_spec.rb
210
+ - spec/client/playlists_spec.rb
211
+ - spec/client/search_tracks.rb
212
+ - spec/client/tracks_spec.rb
213
+ - spec/client/users_spec.rb
214
+ - spec/spec_helper.rb