soundcloud 0.3.2 → 0.3.5
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.
- checksums.yaml +7 -0
- data/LICENSE.md +20 -0
- data/README.md +23 -4
- data/lib/soundcloud/client.rb +19 -7
- data/lib/soundcloud/version.rb +1 -1
- metadata +24 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: df5b0cab01fdc8985e0059c4fbaebbb29672f58c17c33ce1cce2765861eeee3c
|
4
|
+
data.tar.gz: 730fc7f919b60e2aa582e755560284ebc07957d51054115da4093adfa71ced0c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 93d8a10bd11b13c43b18e6c5449a3e640f0f43e93eb40473869f3326d84e4f6c4c347929acf9e93ddb0e4f1fa6cf8df75f68d25818636f6738efbe2a2dfafd54
|
7
|
+
data.tar.gz: 71e706b85e323052f13bd39c1f32368c4cbaaccb41ceaf5e2eed65438502dc025e8adf30191af06ae9ea35efad492faad3a85443ef2cb0d57b4ad0a0b29c6e66
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009-2015 SoundCloud Ltd., Johannes Wagener, Erik Michaels-Ober
|
2
|
+
|
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:
|
10
|
+
|
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.
|
data/README.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# ⚠️⚠️DEPRECATED - NO LONGER MAINTAINED⚠️⚠️
|
2
|
+
This repository is no longer maintained by the SoundCloud team due to capacity constraints. We're instead focusing our efforts on improving the API & the developer platform. Please note, at the time of updating this, the repo is already not in sync with the latest API changes.
|
3
|
+
|
4
|
+
We recommend the community to fork this repo in order to maintain the SDK. We'd be more than happy to make a reference on our developer that the developers can use different SDKs build by the community. In case you need to reach out to us, please head over to https://github.com/soundcloud/api/issues
|
5
|
+
|
6
|
+
---
|
7
|
+
|
1
8
|
# SoundCloud API Wrapper
|
2
9
|
|
3
10
|
[](https://travis-ci.org/soundcloud/soundcloud-ruby)
|
@@ -12,12 +19,20 @@ gem install soundcloud
|
|
12
19
|
```
|
13
20
|
|
14
21
|
## Examples
|
15
|
-
|
22
|
+
|
23
|
+
The following examples are for the [latest gem version](https://rubygems.org/gems/soundcloud).
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
SoundCloud::VERSION
|
27
|
+
# => "0.3.4"
|
28
|
+
```
|
29
|
+
|
30
|
+
#### Print links of the 10 most recent tracks
|
16
31
|
```ruby
|
17
32
|
# register a client with YOUR_CLIENT_ID as client_id_
|
18
33
|
client = SoundCloud.new(:client_id => YOUR_CLIENT_ID)
|
19
|
-
# get
|
20
|
-
tracks = client.get('/tracks', :limit => 10
|
34
|
+
# get newest tracks
|
35
|
+
tracks = client.get('/tracks', :limit => 10)
|
21
36
|
# print each link
|
22
37
|
tracks.each do |track|
|
23
38
|
puts track.permalink_url
|
@@ -64,7 +79,7 @@ client = SoundCloud.new({
|
|
64
79
|
:refresh_token => SOME_REFRESH_TOKEN
|
65
80
|
})
|
66
81
|
|
67
|
-
# upload a new track with
|
82
|
+
# upload a new track with audio.mp3 as audio and image.jpg as artwork
|
68
83
|
track = client.post('/tracks', :track => {
|
69
84
|
:title => 'a new track',
|
70
85
|
:asset_data => File.new('audio.mp3')
|
@@ -168,3 +183,7 @@ Will return true or false depending on if `expires_at` is in the past.
|
|
168
183
|
In case a request was not successful a SoundCloud::ResponseError will be
|
169
184
|
raised. The original HTTParty response is available through
|
170
185
|
`SoundCloud::ResponseError#response`.
|
186
|
+
|
187
|
+
## Documentation
|
188
|
+
|
189
|
+
For more code examples, please visit the [SoundCloud API Documentation](http://developers.soundcloud.com/docs).
|
data/lib/soundcloud/client.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'soundcloud/version'
|
2
|
+
|
1
3
|
module SoundCloud
|
2
4
|
class Client
|
3
5
|
include HTTMultiParty
|
4
|
-
USER_AGENT = "SoundCloud Ruby Wrapper #{VERSION}"
|
6
|
+
USER_AGENT = "SoundCloud Ruby Wrapper #{SoundCloud::VERSION}"
|
5
7
|
CLIENT_ID_PARAM_NAME = :client_id
|
6
8
|
API_SUBHOST = 'api'
|
7
9
|
AUTHORIZE_PATH = '/connect'
|
@@ -16,7 +18,7 @@ module SoundCloud
|
|
16
18
|
|
17
19
|
def initialize(options={})
|
18
20
|
store_options(options)
|
19
|
-
if access_token.nil? && (options_for_refresh_flow_present? || options_for_credentials_flow_present? || options_for_code_flow_present?)
|
21
|
+
if access_token.nil? && (options_for_refresh_flow_present? || options_for_credentials_flow_present? || options_for_code_flow_present? || client_secret)
|
20
22
|
exchange_token
|
21
23
|
end
|
22
24
|
raise ArgumentError, "At least a client_id or an access_token must be present" if client_id.nil? && access_token.nil?
|
@@ -106,13 +108,14 @@ module SoundCloud
|
|
106
108
|
def exchange_token(options={})
|
107
109
|
store_options(options)
|
108
110
|
raise ArgumentError, 'client_id and client_secret is required to retrieve an access_token' if client_id.nil? || client_secret.nil?
|
109
|
-
|
111
|
+
|
110
112
|
params = if options_for_refresh_flow_present?
|
111
113
|
{
|
112
114
|
:grant_type => 'refresh_token',
|
113
115
|
:refresh_token => refresh_token,
|
114
116
|
}
|
115
117
|
elsif options_for_credentials_flow_present?
|
118
|
+
puts "Warning: Password grant is deprecated, see https://developers.soundcloud.com/blog/security-updates-api"
|
116
119
|
{
|
117
120
|
:grant_type => 'password',
|
118
121
|
:username => @options[:username],
|
@@ -124,11 +127,16 @@ module SoundCloud
|
|
124
127
|
:redirect_uri => @options[:redirect_uri],
|
125
128
|
:code => @options[:code],
|
126
129
|
}
|
130
|
+
elsif client_secret
|
131
|
+
{ :grant_type => 'client_credentials' }
|
127
132
|
end
|
128
|
-
|
133
|
+
|
134
|
+
params.merge!(:client_id => client_id, :client_secret => client_secret)
|
135
|
+
|
129
136
|
response = handle_response(false) {
|
130
137
|
self.class.post("https://#{api_host}#{TOKEN_PATH}", :query => params)
|
131
138
|
}
|
139
|
+
|
132
140
|
@options.merge!(:access_token => response.access_token, :refresh_token => response.refresh_token)
|
133
141
|
@options[:expires_at] = Time.now + response.expires_in if response.expires_in
|
134
142
|
@options[:on_exchange_token].call(*[(self if @options[:on_exchange_token].arity == 1)].compact)
|
@@ -151,9 +159,9 @@ module SoundCloud
|
|
151
159
|
else
|
152
160
|
raise ResponseError.new(response)
|
153
161
|
end
|
154
|
-
elsif
|
162
|
+
elsif response_is_a?(response, Hash)
|
155
163
|
HashResponseWrapper.new(response)
|
156
|
-
elsif
|
164
|
+
elsif response_is_a?(response, Array)
|
157
165
|
ArrayResponseWrapper.new(response)
|
158
166
|
elsif response && response.success?
|
159
167
|
response
|
@@ -185,8 +193,9 @@ module SoundCloud
|
|
185
193
|
options[body_or_query] ||= {}
|
186
194
|
options[body_or_query][:format] = "json"
|
187
195
|
if access_token
|
188
|
-
options[
|
196
|
+
options[:headers] = { 'Authorization' => "OAuth #{access_token}" }
|
189
197
|
else
|
198
|
+
puts "Warning: Authorization via ClientId is deprecated, see https://developers.soundcloud.com/blog/security-updates-api"
|
190
199
|
options[body_or_query][CLIENT_ID_PARAM_NAME] = client_id
|
191
200
|
end
|
192
201
|
[
|
@@ -195,5 +204,8 @@ module SoundCloud
|
|
195
204
|
]
|
196
205
|
end
|
197
206
|
|
207
|
+
def response_is_a?(response, type)
|
208
|
+
response.is_a?(type) || (response.respond_to?(:parsed_response) && response.parsed_response.is_a?(type))
|
209
|
+
end
|
198
210
|
end
|
199
211
|
end
|
data/lib/soundcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,102 +1,94 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Johannes Wagener
|
9
|
-
|
8
|
+
- Erik Michaels-Ober
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httmultiparty
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
17
|
requirements:
|
19
|
-
- - ~>
|
18
|
+
- - "~>"
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: 0.3.0
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
|
-
- - ~>
|
25
|
+
- - "~>"
|
28
26
|
- !ruby/object:Gem::Version
|
29
27
|
version: 0.3.0
|
30
28
|
- !ruby/object:Gem::Dependency
|
31
29
|
name: hashie
|
32
30
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
31
|
requirements:
|
35
|
-
- -
|
32
|
+
- - ">="
|
36
33
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
34
|
+
version: '0'
|
38
35
|
type: :runtime
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
|
-
- -
|
39
|
+
- - ">="
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
41
|
+
version: '0'
|
46
42
|
- !ruby/object:Gem::Dependency
|
47
43
|
name: bundler
|
48
44
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
45
|
requirements:
|
51
|
-
- - ~>
|
46
|
+
- - "~>"
|
52
47
|
- !ruby/object:Gem::Version
|
53
48
|
version: '1.0'
|
54
49
|
type: :development
|
55
50
|
prerelease: false
|
56
51
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
52
|
requirements:
|
59
|
-
- - ~>
|
53
|
+
- - "~>"
|
60
54
|
- !ruby/object:Gem::Version
|
61
55
|
version: '1.0'
|
62
56
|
description: The official SoundCloud API wrapper. It provides simple methods to handle
|
63
57
|
authorization and to execute HTTP calls.
|
64
58
|
email:
|
65
|
-
-
|
59
|
+
- api@soundcloud.com
|
66
60
|
executables: []
|
67
61
|
extensions: []
|
68
62
|
extra_rdoc_files: []
|
69
63
|
files:
|
64
|
+
- LICENSE.md
|
65
|
+
- README.md
|
66
|
+
- lib/soundcloud.rb
|
70
67
|
- lib/soundcloud/array_response_wrapper.rb
|
71
68
|
- lib/soundcloud/client.rb
|
72
69
|
- lib/soundcloud/hash_response_wrapper.rb
|
73
70
|
- lib/soundcloud/response_error.rb
|
74
71
|
- lib/soundcloud/version.rb
|
75
|
-
|
76
|
-
- README.md
|
77
|
-
homepage: http://dev.soundcloud.com
|
72
|
+
homepage: https://dev.soundcloud.com
|
78
73
|
licenses: []
|
79
|
-
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
80
76
|
rdoc_options: []
|
81
77
|
require_paths:
|
82
78
|
- lib
|
83
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
80
|
requirements:
|
86
|
-
- -
|
81
|
+
- - ">="
|
87
82
|
- !ruby/object:Gem::Version
|
88
83
|
version: '0'
|
89
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
85
|
requirements:
|
92
|
-
- -
|
86
|
+
- - ">="
|
93
87
|
- !ruby/object:Gem::Version
|
94
88
|
version: 1.3.5
|
95
89
|
requirements: []
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
specification_version: 3
|
90
|
+
rubygems_version: 3.1.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
100
93
|
summary: The official SoundCloud API wrapper.
|
101
94
|
test_files: []
|
102
|
-
has_rdoc:
|