rspotify 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspotify/connection.rb +0 -1
- data/lib/rspotify/playlist.rb +18 -0
- data/lib/rspotify/user.rb +12 -2
- data/lib/rspotify/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b837a539cae25d32cc6bdfad118ec0ae25de9f4
|
4
|
+
data.tar.gz: 21153745531d4695bba73613c70535eb9fac7f0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25ffeff226c2c59241faffc769685d00122d62ffb1ea51d21a2faa0d5dd641bcdeca88ffba6d4218447204cfe72df9174739ac2011c2413987bf0ec00e950129
|
7
|
+
data.tar.gz: '0975e8de9ebdc83fb4778a2229c6a72b33c60639eb9cf64c9df1eb8352291ac0d26f91cfe9304bd5bb5c1d9f2aed2333ebc9c05eece629474424683d5e1b3eb2'
|
data/lib/rspotify/connection.rb
CHANGED
data/lib/rspotify/playlist.rb
CHANGED
@@ -340,6 +340,24 @@ module RSpotify
|
|
340
340
|
self
|
341
341
|
end
|
342
342
|
|
343
|
+
# Replace the image used to represent a specific playlist. Requires ugc-image-upload scope. Changing a public playlist
|
344
|
+
# requires the *playlist-modify-public* scope; changing a private playlist requires the *playlist-modify-private* scope.
|
345
|
+
#
|
346
|
+
# @param image [String] Base64 encoded JPEG image data, maximum payload size is 256 KB
|
347
|
+
# @param content_type [String] The content type of the request body, e.g. "image/jpeg"
|
348
|
+
# @return [NilClass] When the image has been provided, Spofity forwards it on to their transcoder service in order to generate the three sizes provided in the playlist’s images object. This operation takes some time, that's why nothing is returned for this method.
|
349
|
+
#
|
350
|
+
# @example
|
351
|
+
# playlist.replace_image!('SkZJRgABA...', 'image/jpeg')
|
352
|
+
def replace_image!(image, content_type)
|
353
|
+
url = "#{@path}/images"
|
354
|
+
headers = {
|
355
|
+
'Content-Type' => content_type
|
356
|
+
}
|
357
|
+
User.oauth_put(@owner.id, url, image, { headers: headers })
|
358
|
+
nil
|
359
|
+
end
|
360
|
+
|
343
361
|
# Replace all the tracks in a playlist, overwriting its existing tracks. Changing a public playlist requires
|
344
362
|
# the *playlist-modify-public* scope; changing a private playlist requires the *playlist-modify-private* scope.
|
345
363
|
#
|
data/lib/rspotify/user.rb
CHANGED
@@ -43,6 +43,13 @@ module RSpotify
|
|
43
43
|
end
|
44
44
|
private_class_method :refresh_token
|
45
45
|
|
46
|
+
def self.extract_custom_headers(params)
|
47
|
+
headers_param = params.find{|x| x.is_a?(Hash) && x[:headers]}
|
48
|
+
params.delete(headers_param) if headers_param
|
49
|
+
headers_param ? headers_param[:headers] : {}
|
50
|
+
end
|
51
|
+
private_class_method :extract_custom_headers
|
52
|
+
|
46
53
|
def self.oauth_header(user_id)
|
47
54
|
{
|
48
55
|
'Authorization' => "Bearer #{@@users_credentials[user_id]['token']}",
|
@@ -52,18 +59,21 @@ module RSpotify
|
|
52
59
|
private_class_method :oauth_header
|
53
60
|
|
54
61
|
def self.oauth_send(user_id, verb, path, *params)
|
62
|
+
custom_headers = extract_custom_headers(params)
|
63
|
+
headers = oauth_header(user_id).merge(custom_headers)
|
64
|
+
params << headers
|
55
65
|
RSpotify.send(:send_request, verb, path, *params)
|
66
|
+
|
56
67
|
rescue RestClient::Exception => e
|
57
68
|
raise e if e.response !~ /access token expired/
|
58
69
|
refresh_token(user_id)
|
59
|
-
params[-1] =
|
70
|
+
params[-1] = headers
|
60
71
|
RSpotify.send(:send_request, verb, path, *params)
|
61
72
|
end
|
62
73
|
private_class_method :oauth_header
|
63
74
|
|
64
75
|
RSpotify::VERBS.each do |verb|
|
65
76
|
define_singleton_method "oauth_#{verb}" do |user_id, path, *params|
|
66
|
-
params << oauth_header(user_id)
|
67
77
|
oauth_send(user_id, verb, path, *params)
|
68
78
|
end
|
69
79
|
end
|
data/lib/rspotify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Sad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|