rspotify 1.4.0 → 1.5.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/artist.rb +2 -2
- data/lib/rspotify/playlist.rb +48 -2
- data/lib/rspotify/user.rb +1 -1
- 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: 915098c8b8896573470f1b8eeaccafc685352674
|
4
|
+
data.tar.gz: 666dddc4c95848340a2e0f1b0f4425c2e74c8bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c829c3d977cc9aa8dc2b9c1d4f2aaaa45626f425729b9135fac31c118c464d48ccabcc5ec7c5a74987237e46ec9e792b2f4b61f140955e1fa5848d510337d94b
|
7
|
+
data.tar.gz: ee4fcd289269c373f3a7e76dbc960818e75b3b7bd227b2918aeed9ee64bc0850f7fb16fb6d52c2c99aa817e4abfec8d34dda964233bbb0014cf7e0eb9c9b26e1
|
data/lib/rspotify/artist.rb
CHANGED
@@ -57,8 +57,8 @@ module RSpotify
|
|
57
57
|
#
|
58
58
|
# @param limit [Integer] Maximum number of albums to return. Maximum: 50. Default: 20.
|
59
59
|
# @param offset [Integer] The index of the first album to return. Use with limit to get the next set of albums. Default: 0.
|
60
|
-
# @param album_type [String] A comma-separated list of keywords that will be used to filter the response. If not supplied, all album types will be returned. Valid values are: album; single; appears_on; compilation.
|
61
|
-
# @param market [String] (synonym: country). An {http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2 country code}. Supply this parameter to limit the response to one particular geographical market. If not supplied, results will be returned for all markets. Note if you do not provide this field, you are likely to get duplicate results per album, one for each market in which the album is available.
|
60
|
+
# @param album_type [String] Optional. A comma-separated list of keywords that will be used to filter the response. If not supplied, all album types will be returned. Valid values are: album; single; appears_on; compilation.
|
61
|
+
# @param market [String] Optional. (synonym: country). An {http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2 country code}. Supply this parameter to limit the response to one particular geographical market. If not supplied, results will be returned for all markets. Note if you do not provide this field, you are likely to get duplicate results per album, one for each market in which the album is available.
|
62
62
|
# @return [Array<Album>]
|
63
63
|
#
|
64
64
|
# @example
|
data/lib/rspotify/playlist.rb
CHANGED
@@ -72,10 +72,34 @@ module RSpotify
|
|
72
72
|
url << "&position=#{position}" if position
|
73
73
|
|
74
74
|
User.oauth_post(@owner.id, url, {})
|
75
|
-
@
|
75
|
+
@tracks_cache = nil
|
76
76
|
tracks
|
77
77
|
end
|
78
78
|
|
79
|
+
# Change name and public/private state of playlist in user's Spotify account. Changing a public playlist
|
80
|
+
# requires the *playlist-modify* scope; changing a private playlist requires the *playlist-modify-private* scope.
|
81
|
+
#
|
82
|
+
# @param name [String] Optional. The new name for the playlist.
|
83
|
+
# @param public [Boolean] Optional. If true the playlist will be public, if false it will be private.
|
84
|
+
# @return [Playlist]
|
85
|
+
#
|
86
|
+
# @example
|
87
|
+
# playlist.name #=> "Movie Soundtrack Masterpieces"
|
88
|
+
# playlist.public #=> true
|
89
|
+
#
|
90
|
+
# playlist.change_details!(name: 'Movie Tracks', public: false)
|
91
|
+
#
|
92
|
+
# playlist.name #=> "Movie Tracks"
|
93
|
+
# playlist.public #=> false
|
94
|
+
def change_details!(**data)
|
95
|
+
url = "users/#{@owner.id}/playlists/#{@id}"
|
96
|
+
User.oauth_put(@owner.id, url, data.to_json)
|
97
|
+
data.each do |field, value|
|
98
|
+
instance_variable_set("@#{field}", value)
|
99
|
+
end
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
79
103
|
# When an object is obtained undirectly, Spotify usually returns a simplified version of it.
|
80
104
|
# This method updates it into a full object, with all attributes filled.
|
81
105
|
#
|
@@ -120,11 +144,33 @@ module RSpotify
|
|
120
144
|
RSpotify.auth_get(url)
|
121
145
|
end
|
122
146
|
|
123
|
-
tracks = json['items'].map
|
147
|
+
tracks = json['items'].map do |i|
|
148
|
+
Track.new i['track'] unless i['track'].nil?
|
149
|
+
end.compact
|
150
|
+
|
124
151
|
@tracks_cache = tracks if limit == 100 && offset == 0
|
125
152
|
tracks
|
126
153
|
end
|
127
154
|
|
155
|
+
# Replace all the tracks in a playlist, overwriting its existing tracks. Changing a public playlist
|
156
|
+
# requires the *playlist-modify* scope; changing a private playlist requires the *playlist-modify-private* scope.
|
157
|
+
#
|
158
|
+
# @param tracks [Array<Track>] The tracks that will replace the existing ones. Maximum: 100 per request
|
159
|
+
# @return [Array<Track>] The tracks that were added.
|
160
|
+
#
|
161
|
+
# @example
|
162
|
+
# playlist.tracks.map(&:name) #=> ["All of Me", "Wasted Love", "Love Runs Out"]
|
163
|
+
# tracks = RSpotify::Track.search('Know', limit: 2)
|
164
|
+
# playlist.replace_tracks!(tracks)
|
165
|
+
# playlist.tracks.map(&:name) #=> ["Somebody That I Used To Know", "Do I Wanna Know?"]
|
166
|
+
def replace_tracks!(tracks)
|
167
|
+
track_uris = tracks.map(&:uri).join(',')
|
168
|
+
url = "users/#{@owner.id}/playlists/#{@id}/tracks?uris=#{track_uris}"
|
169
|
+
User.oauth_put(@owner.id, url, {})
|
170
|
+
@tracks_cache = nil
|
171
|
+
tracks
|
172
|
+
end
|
173
|
+
|
128
174
|
private
|
129
175
|
|
130
176
|
def users_credentials
|
data/lib/rspotify/user.rb
CHANGED
@@ -99,7 +99,7 @@ module RSpotify
|
|
99
99
|
# playlist.public #=> false
|
100
100
|
def create_playlist!(name, public: true)
|
101
101
|
url = "users/#{@id}/playlists"
|
102
|
-
request_data =
|
102
|
+
request_data = { name: name, public: public }.to_json
|
103
103
|
Playlist.new User.oauth_post(@id, url, request_data)
|
104
104
|
end
|
105
105
|
|
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.5.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: 2014-10-
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|