rspotify 1.19.1 → 1.20.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/playlist.rb +6 -2
- data/lib/rspotify/user.rb +4 -0
- 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: 6a0c24d5567ae501a2521c15ef19a34175dde046
|
4
|
+
data.tar.gz: 25b8e50e446cce78cfb8f98f232353220454ee0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd7117cec0764a99ec287d42e913bec0634bccd480b53efa4c9418b7e5782785dc81c59b875dafd53f2637ff8e7ec86ecca4a5b743002abf51ab1eb577ab198e
|
7
|
+
data.tar.gz: 504222a7bb2eb95b18e0e6abf5b1961c789b07411245ed23d1914b7c2de45415224baabeeb015f9dadd0e278c4a2b29c22f3b803dfc89200e5805559bc01914c
|
data/lib/rspotify/playlist.rb
CHANGED
@@ -42,15 +42,17 @@ module RSpotify
|
|
42
42
|
#
|
43
43
|
# @param user_id [String]
|
44
44
|
# @param id [String]
|
45
|
+
# @param market [String] Optional. An {https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2 country code}. Provide this parameter if you want to apply Track Relinking
|
45
46
|
# @return [Playlist]
|
46
47
|
#
|
47
48
|
# @example
|
48
49
|
# playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
|
49
50
|
# playlist.class #=> RSpotify::Playlist
|
50
51
|
# playlist.name #=> "Movie Soundtrack Masterpieces"
|
51
|
-
def self.find(user_id, id)
|
52
|
+
def self.find(user_id, id, market: nil)
|
52
53
|
url = "users/#{user_id}/"
|
53
54
|
url << (id == 'starred' ? id : "playlists/#{id}")
|
55
|
+
url << "?market=#{market}" if market
|
54
56
|
|
55
57
|
response = RSpotify.resolve_auth_request(user_id, url)
|
56
58
|
return response if RSpotify.raw_response
|
@@ -226,18 +228,20 @@ module RSpotify
|
|
226
228
|
#
|
227
229
|
# @param limit [Integer] Maximum number of tracks to return. Maximum: 100. Default: 100.
|
228
230
|
# @param offset [Integer] The index of the first track to return. Use with limit to get the next set of objects. Default: 0.
|
231
|
+
# @param market [String] Optional. An {https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2 country code}. Provide this parameter if you want to apply Track Relinking
|
229
232
|
# @return [Array<Track>]
|
230
233
|
#
|
231
234
|
# @example
|
232
235
|
# playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
|
233
236
|
# playlist.tracks.first.name #=> "Main Theme from Star Wars - Instrumental"
|
234
|
-
def tracks(limit: 100, offset: 0)
|
237
|
+
def tracks(limit: 100, offset: 0, market: nil)
|
235
238
|
last_track = offset + limit - 1
|
236
239
|
if @tracks_cache && last_track < 100 && !RSpotify.raw_response
|
237
240
|
return @tracks_cache[offset..last_track]
|
238
241
|
end
|
239
242
|
|
240
243
|
url = "#{@path}/tracks?limit=#{limit}&offset=#{offset}"
|
244
|
+
url << "&market=#{market}" if market
|
241
245
|
response = RSpotify.resolve_auth_request(@owner.id, url)
|
242
246
|
|
243
247
|
json = RSpotify.raw_response ? JSON.parse(response) : response
|
data/lib/rspotify/user.rb
CHANGED
@@ -38,6 +38,8 @@ module RSpotify
|
|
38
38
|
response = RestClient.post(TOKEN_URI, request_body, RSpotify.send(:auth_header))
|
39
39
|
response = JSON.parse(response)
|
40
40
|
@@users_credentials[user_id]['token'] = response['access_token']
|
41
|
+
rescue RestClient::BadRequest => e
|
42
|
+
raise e if e.response !~ /Refresh token revoked/
|
41
43
|
end
|
42
44
|
private_class_method :refresh_token
|
43
45
|
|
@@ -68,7 +70,9 @@ module RSpotify
|
|
68
70
|
|
69
71
|
def initialize(options = {})
|
70
72
|
credentials = options['credentials']
|
73
|
+
extra = options['extra'].to_h
|
71
74
|
options = options['info'] if options['info']
|
75
|
+
options.merge!(extra['raw_info'].to_h)
|
72
76
|
|
73
77
|
@birthdate ||= options['birthdate']
|
74
78
|
@country ||= options['country']
|
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: 1.
|
4
|
+
version: 1.20.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: 2017-
|
11
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|