rspotify 1.15.3 → 1.15.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rspotify/playlist.rb +13 -13
- data/lib/rspotify/version.rb +1 -1
- data/spec/lib/rspotify/playlist_spec.rb +1 -0
- 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: 2fd80779809352fce753b966ed286fd6c3aacda8
|
4
|
+
data.tar.gz: c6f8e9585e6a0f2b18f8b99edbfb30c5f3f43cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fd0b013fe4eb6bde6c7da158164517b952346b06e11010afe47962f13e7877defe71d2447c433b38dabb0a99f886045f953597b47786f5a9d5db0b08706c251
|
7
|
+
data.tar.gz: 7c15704769259deef7469c100a3c3da7a5240652a33c308e6f874e0a81d4171ac709234c734b6792cd052f94cfc380f4f8e43852c4aa9f67513ed95d03c31ae0
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/rspotify.svg)](http://badge.fury.io/rb/rspotify)
|
4
4
|
[![Build Status](https://travis-ci.org/guilhermesad/rspotify.svg?branch=master)](https://travis-ci.org/guilhermesad/rspotify)
|
5
5
|
|
6
|
-
This is a ruby wrapper for the [
|
6
|
+
This is a ruby wrapper for the [Spotify Web API](https://developer.spotify.com/web-api).
|
7
7
|
|
8
8
|
## Features
|
9
9
|
|
@@ -29,7 +29,7 @@ Or install it yourself as:
|
|
29
29
|
|
30
30
|
RSpotify was designed with usability as its primary goal, so that you can forget the API and intuitively interact with your playlists, favorite artists, users and so on.
|
31
31
|
|
32
|
-
You can write things like `
|
32
|
+
You can write things like `my_playlist.tracks.sort_by(&:popularity).last.album` without having to think which API calls must be done. RSpotify fills the gaps for you.
|
33
33
|
|
34
34
|
Below are some basic usage examples. Check the [documentation](http://rdoc.info/github/guilhermesad/rspotify/master/frames) for the complete reference.
|
35
35
|
|
data/lib/rspotify/playlist.rb
CHANGED
@@ -49,11 +49,8 @@ module RSpotify
|
|
49
49
|
# playlist.class #=> RSpotify::Playlist
|
50
50
|
# playlist.name #=> "Movie Soundtrack Masterpieces"
|
51
51
|
def self.find(user_id, id)
|
52
|
-
url =
|
53
|
-
|
54
|
-
else
|
55
|
-
"users/#{user_id}/playlists/#{id}"
|
56
|
-
end
|
52
|
+
url = "users/#{user_id}/"
|
53
|
+
url << (id == 'starred' ? id : "playlists/#{id}")
|
57
54
|
|
58
55
|
response = RSpotify.resolve_auth_request(user_id, url)
|
59
56
|
return response if RSpotify.raw_response
|
@@ -110,6 +107,9 @@ module RSpotify
|
|
110
107
|
end
|
111
108
|
|
112
109
|
super(options)
|
110
|
+
|
111
|
+
@path = "users/#{@owner.instance_variable_get('@id')}/"
|
112
|
+
@path << (@href =~ /\/starred$/ ? 'starred' : "playlists/#{@id}")
|
113
113
|
end
|
114
114
|
|
115
115
|
# Adds one or more tracks to a playlist in user's Spotify account. This method is only available when the
|
@@ -131,7 +131,7 @@ module RSpotify
|
|
131
131
|
# playlist.tracks[20].name #=> "Somebody That I Used To Know"
|
132
132
|
def add_tracks!(tracks, position: nil)
|
133
133
|
track_uris = tracks.map(&:uri).join(',')
|
134
|
-
url = "#{@
|
134
|
+
url = "#{@path}/tracks?uris=#{track_uris}"
|
135
135
|
url << "&position=#{position}" if position
|
136
136
|
|
137
137
|
response = User.oauth_post(@owner.id, url, {})
|
@@ -163,7 +163,7 @@ module RSpotify
|
|
163
163
|
# playlist.name #=> "Movie Tracks"
|
164
164
|
# playlist.public #=> false
|
165
165
|
def change_details!(**data)
|
166
|
-
User.oauth_put(@owner.id, @
|
166
|
+
User.oauth_put(@owner.id, @path, data.to_json)
|
167
167
|
data.each do |field, value|
|
168
168
|
instance_variable_set("@#{field}", value)
|
169
169
|
end
|
@@ -182,7 +182,7 @@ module RSpotify
|
|
182
182
|
# playlist.complete!
|
183
183
|
# playlist.instance_variable_get("@description") #=> "Iconic soundtracks..."
|
184
184
|
def complete!
|
185
|
-
initialize RSpotify.resolve_auth_request(@owner.id, @
|
185
|
+
initialize RSpotify.resolve_auth_request(@owner.id, @path)
|
186
186
|
end
|
187
187
|
|
188
188
|
# Check if one or more Spotify users are following a specified playlist. Checking if the user is privately
|
@@ -200,7 +200,7 @@ module RSpotify
|
|
200
200
|
# playlist.is_followed_by?([oauth-user]) #=> [true] (User publicly or privately following playlist)
|
201
201
|
def is_followed_by?(users)
|
202
202
|
user_ids = users.map(&:id).join(',')
|
203
|
-
url = "#{@
|
203
|
+
url = "#{@path}/followers/contains?ids=#{user_ids}"
|
204
204
|
|
205
205
|
users_credentials = if User.class_variable_defined?('@@users_credentials')
|
206
206
|
User.class_variable_get('@@users_credentials')
|
@@ -232,7 +232,7 @@ module RSpotify
|
|
232
232
|
return @tracks_cache[offset..last_track]
|
233
233
|
end
|
234
234
|
|
235
|
-
url = "#{@
|
235
|
+
url = "#{@path}/tracks?limit=#{limit}&offset=#{offset}"
|
236
236
|
response = RSpotify.resolve_auth_request(@owner.id, url)
|
237
237
|
|
238
238
|
json = RSpotify.raw_response ? JSON.parse(response) : response
|
@@ -288,7 +288,7 @@ module RSpotify
|
|
288
288
|
|
289
289
|
params = {
|
290
290
|
method: :delete,
|
291
|
-
url: URI::encode(
|
291
|
+
url: URI::encode(RSpotify::API_URI + @path + '/tracks'),
|
292
292
|
headers: User.send(:oauth_header, @owner.id),
|
293
293
|
payload: positions ? { positions: positions } : { tracks: tracks }
|
294
294
|
}
|
@@ -317,7 +317,7 @@ module RSpotify
|
|
317
317
|
# # Move the tracks at index 10-14 to the start of the playlist
|
318
318
|
# playlist.reorder_tracks!(range_start, insert_before, range_length: 5)
|
319
319
|
def reorder_tracks!(range_start, insert_before, **options)
|
320
|
-
url = "#{@
|
320
|
+
url = "#{@path}/tracks"
|
321
321
|
data = {
|
322
322
|
range_start: range_start,
|
323
323
|
insert_before: insert_before
|
@@ -344,7 +344,7 @@ module RSpotify
|
|
344
344
|
# playlist.tracks.map(&:name) #=> ["Somebody That I Used To Know", "Do I Wanna Know?"]
|
345
345
|
def replace_tracks!(tracks)
|
346
346
|
track_uris = tracks.map(&:uri).join(',')
|
347
|
-
url = "#{@
|
347
|
+
url = "#{@path}/tracks?uris=#{track_uris}"
|
348
348
|
User.oauth_put(@owner.id, url, {})
|
349
349
|
|
350
350
|
@total = tracks.size
|
data/lib/rspotify/version.rb
CHANGED
@@ -169,6 +169,7 @@ describe RSpotify::Playlist do
|
|
169
169
|
let(:href) { 'https://api.spotify.com/v1/users/wizzler/playlists/00wHcTN0zQiun4xri9pmvX' }
|
170
170
|
let(:playlist) do
|
171
171
|
min_attrs = {
|
172
|
+
'id' => '00wHcTN0zQiun4xri9pmvX',
|
172
173
|
'href' => href,
|
173
174
|
'owner' => {'id' => 'wizzler'},
|
174
175
|
'tracks' => {'total' => 53 }
|
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.15.
|
4
|
+
version: 1.15.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Sad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|