rspotify 1.3.0 → 1.4.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 +16 -9
- data/lib/rspotify/base.rb +1 -1
- data/lib/rspotify/user.rb +9 -2
- data/lib/rspotify/version.rb +1 -1
- data/spec/lib/rspotify/artist_spec.rb +1 -1
- data/spec/lib/rspotify/user_spec.rb +2 -3
- data/spec/vcr_cassettes/{artist_7Ln80lUS6He07XvHI8qqHH_albums.yml → artist_7Ln80lUS6He07XvHI8qqHH_albums_limit_20_offset_0.yml} +1 -1
- data/spec/vcr_cassettes/{user_wizzler_playlists.yml → user_wizzler_playlists_limit_20_offset_0.yml} +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d9e31b9626c059235d8ae9a280d2aeda3401bdb
|
4
|
+
data.tar.gz: d31cd52b6f9f42267a7eeac70a166f3386bb8cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e27b5891b2c93c8bd0a0d291372eb563e765020adfb4cd3de1da96525b835a99830fef3020706a6de841e33767880bcd06f8c4a6d91734085740667e77ebcdb
|
7
|
+
data.tar.gz: e5f1595da9fef102f1ccd0047336f23435d59bc3a510e689c1d38b781c8dd0336d3228ad23e210cd18f3f95b885db8948d4b26a958d8b7c524a21e618b4fd697
|
data/lib/rspotify/artist.rb
CHANGED
@@ -53,19 +53,26 @@ module RSpotify
|
|
53
53
|
super(options)
|
54
54
|
end
|
55
55
|
|
56
|
-
# Returns
|
56
|
+
# Returns array of albums from artist
|
57
57
|
#
|
58
|
+
# @param limit [Integer] Maximum number of albums to return. Maximum: 50. Default: 20.
|
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.
|
58
62
|
# @return [Array<Album>]
|
59
63
|
#
|
60
64
|
# @example
|
61
|
-
#
|
62
|
-
# albums
|
63
|
-
# albums
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
# artist.albums
|
66
|
+
# artist.albums(album_type: 'single,compilation')
|
67
|
+
# artist.albums(limit: 50, country: 'US')
|
68
|
+
def albums(limit: 20, offset: 0, **filters)
|
69
|
+
url = "artists/#{@id}/albums?limit=#{limit}&offset=#{offset}"
|
70
|
+
filters.each do |filter_name, filter_value|
|
71
|
+
url << "&#{filter_name}=#{filter_value}"
|
72
|
+
end
|
73
|
+
|
74
|
+
json = RSpotify.get(url)
|
75
|
+
json['items'].map { |i| Album.new i }
|
69
76
|
end
|
70
77
|
|
71
78
|
# Returns array of similar artists. Similarity is based on analysis of the Spotify community’s {http://news.spotify.com/se/2010/02/03/related-artists listening history}.
|
data/lib/rspotify/base.rb
CHANGED
@@ -56,7 +56,7 @@ module RSpotify
|
|
56
56
|
# Returns array of RSpotify objects matching the query, ordered by popularity
|
57
57
|
#
|
58
58
|
# @param query [String] The search query's keywords. See the q description in {https://developer.spotify.com/web-api/search-item here} for details.
|
59
|
-
# @param
|
59
|
+
# @param types [String] Valid types are: album, artist and track. Separate multiple types with commas.
|
60
60
|
# @param limit [Integer] Maximum number of objects to return. Maximum: 50. Default: 20.
|
61
61
|
# @param offset [Integer] The index of the first object to return. Use with limit to get the next set of objects. Default: 0.
|
62
62
|
# @return [Array<Base>]
|
data/lib/rspotify/user.rb
CHANGED
@@ -105,6 +105,8 @@ module RSpotify
|
|
105
105
|
|
106
106
|
# Returns all playlists from user
|
107
107
|
#
|
108
|
+
# @param limit [Integer] Maximum number of playlists to return. Maximum: 50. Default: 20.
|
109
|
+
# @param offset [Integer] The index of the first playlist to return. Use with limit to get the next set of playlists. Default: 0.
|
108
110
|
# @return [Array<Playlist>]
|
109
111
|
#
|
110
112
|
# @example
|
@@ -112,8 +114,13 @@ module RSpotify
|
|
112
114
|
# playlists.class #=> Array
|
113
115
|
# playlists.first.class #=> RSpotify::Playlist
|
114
116
|
# playlists.first.name #=> "Movie Soundtrack Masterpieces"
|
115
|
-
def playlists
|
116
|
-
|
117
|
+
def playlists(limit: 20, offset: 0)
|
118
|
+
url = "users/#{@id}/playlists?limit=#{limit}&offset=#{offset}"
|
119
|
+
json = if @credentials.nil?
|
120
|
+
RSpotify.auth_get(url)
|
121
|
+
else
|
122
|
+
User.oauth_get(@id, url)
|
123
|
+
end
|
117
124
|
json['items'].map { |i| Playlist.new i }
|
118
125
|
end
|
119
126
|
|
data/lib/rspotify/version.rb
CHANGED
@@ -22,7 +22,7 @@ describe RSpotify::Artist do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should find artist with correct albums' do
|
25
|
-
albums = VCR.use_cassette('artist:7Ln80lUS6He07XvHI8qqHH:albums') do
|
25
|
+
albums = VCR.use_cassette('artist:7Ln80lUS6He07XvHI8qqHH:albums:limit:20:offset:0') do
|
26
26
|
@artist.albums
|
27
27
|
end
|
28
28
|
expect(albums) .to be_an Array
|
@@ -21,12 +21,11 @@ describe RSpotify::User do
|
|
21
21
|
# Keys generated specifically for the tests. Should be removed in the future
|
22
22
|
client_id = '5ac1cda2ad354aeaa1ad2693d33bb98c'
|
23
23
|
client_secret = '155fc038a85840679b55a1822ef36b9b'
|
24
|
-
VCR.use_cassette('authenticate:5ac1cda2ad354aeaa1ad2693d33bb98c') do
|
24
|
+
VCR.use_cassette('authenticate:5ac1cda2ad354aeaa1ad2693d33bb98c') do
|
25
25
|
RSpotify.authenticate(client_id, client_secret)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
playlists = VCR.use_cassette('user:wizzler:playlists') do
|
28
|
+
playlists = VCR.use_cassette('user:wizzler:playlists:limit:20:offset:0') do
|
30
29
|
@user.playlists
|
31
30
|
end
|
32
31
|
expect(playlists) .to be_an Array
|
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.4.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-
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
@@ -161,7 +161,7 @@ files:
|
|
161
161
|
- spec/vcr_cassettes/album_search_AM_limit_10.yml
|
162
162
|
- spec/vcr_cassettes/album_search_AM_offset_10.yml
|
163
163
|
- spec/vcr_cassettes/album_search_AM_offset_10_limit_10.yml
|
164
|
-
- spec/vcr_cassettes/
|
164
|
+
- spec/vcr_cassettes/artist_7Ln80lUS6He07XvHI8qqHH_albums_limit_20_offset_0.yml
|
165
165
|
- spec/vcr_cassettes/artist_7Ln80lUS6He07XvHI8qqHH_related_artists.yml
|
166
166
|
- spec/vcr_cassettes/artist_7Ln80lUS6He07XvHI8qqHH_top_tracks_US.yml
|
167
167
|
- spec/vcr_cassettes/artist_find_0oSGxfWSnnOXhD2fKuz2Gy.yml
|
@@ -181,7 +181,7 @@ files:
|
|
181
181
|
- spec/vcr_cassettes/track_search_Wanna_Know_limit_10_offset_10.yml
|
182
182
|
- spec/vcr_cassettes/track_search_Wanna_Know_offset_10.yml
|
183
183
|
- spec/vcr_cassettes/user_find_wizzler.yml
|
184
|
-
- spec/vcr_cassettes/
|
184
|
+
- spec/vcr_cassettes/user_wizzler_playlists_limit_20_offset_0.yml
|
185
185
|
homepage: http://rubygems.org/gems/rspotify
|
186
186
|
licenses:
|
187
187
|
- MIT
|
@@ -221,7 +221,7 @@ test_files:
|
|
221
221
|
- spec/vcr_cassettes/album_search_AM_limit_10.yml
|
222
222
|
- spec/vcr_cassettes/album_search_AM_offset_10.yml
|
223
223
|
- spec/vcr_cassettes/album_search_AM_offset_10_limit_10.yml
|
224
|
-
- spec/vcr_cassettes/
|
224
|
+
- spec/vcr_cassettes/artist_7Ln80lUS6He07XvHI8qqHH_albums_limit_20_offset_0.yml
|
225
225
|
- spec/vcr_cassettes/artist_7Ln80lUS6He07XvHI8qqHH_related_artists.yml
|
226
226
|
- spec/vcr_cassettes/artist_7Ln80lUS6He07XvHI8qqHH_top_tracks_US.yml
|
227
227
|
- spec/vcr_cassettes/artist_find_0oSGxfWSnnOXhD2fKuz2Gy.yml
|
@@ -241,5 +241,5 @@ test_files:
|
|
241
241
|
- spec/vcr_cassettes/track_search_Wanna_Know_limit_10_offset_10.yml
|
242
242
|
- spec/vcr_cassettes/track_search_Wanna_Know_offset_10.yml
|
243
243
|
- spec/vcr_cassettes/user_find_wizzler.yml
|
244
|
-
- spec/vcr_cassettes/
|
244
|
+
- spec/vcr_cassettes/user_wizzler_playlists_limit_20_offset_0.yml
|
245
245
|
has_rdoc:
|