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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7f112a228d4a745e4a0856808fdcb5c9380f852
4
- data.tar.gz: b13cbfa86d18bcd1f747ed8767fb710e19249381
3
+ metadata.gz: 5d9e31b9626c059235d8ae9a280d2aeda3401bdb
4
+ data.tar.gz: d31cd52b6f9f42267a7eeac70a166f3386bb8cf5
5
5
  SHA512:
6
- metadata.gz: 75306911e3e1cb4c6b2c156fa97a106e0cb205711d4ea913878dbc725f8ef6bc767d6a5d07bbba68128252ecd04c671130baea05f096327c83c562ec20d43f65
7
- data.tar.gz: f3422f96d4299b9ef58399a843c2bbbf43a4df3ce99126e0d636b1605d2e8759280cc424ab2ba4fabfd04514f545b2a29ae6e6fd644d1692f4e3a1ebea4d9d86
6
+ metadata.gz: 9e27b5891b2c93c8bd0a0d291372eb563e765020adfb4cd3de1da96525b835a99830fef3020706a6de841e33767880bcd06f8c4a6d91734085740667e77ebcdb
7
+ data.tar.gz: e5f1595da9fef102f1ccd0047336f23435d59bc3a510e689c1d38b781c8dd0336d3228ad23e210cd18f3f95b885db8948d4b26a958d8b7c524a21e618b4fd697
@@ -53,19 +53,26 @@ module RSpotify
53
53
  super(options)
54
54
  end
55
55
 
56
- # Returns all albums from artist
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
- # albums = artist.albums
62
- # albums.class #=> Array
63
- # albums.first.class #=> RSpotify::Album
64
- # albums.first.name #=> "AM"
65
- def albums
66
- return @albums unless @albums.nil?
67
- json = RSpotify.get("artists/#{@id}/albums")
68
- @albums = json['items'].map { |i| Album.new i }
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 type [String] Valid types are: album, artist and track. Separate multiple types with commas.
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
- json = RSpotify.auth_get("users/#{@id}/playlists")
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
 
@@ -1,3 +1,3 @@
1
1
  module RSpotify
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -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
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.spotify.com/v1/artists/7Ln80lUS6He07XvHI8qqHH/albums
5
+ uri: https://api.spotify.com/v1/artists/7Ln80lUS6He07XvHI8qqHH/albums?limit=20&offset=0
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.spotify.com/v1/users/wizzler/playlists
5
+ uri: https://api.spotify.com/v1/users/wizzler/playlists?limit=20&offset=0
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
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.3.0
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-09-23 00:00:00.000000000 Z
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/artist_7Ln80lUS6He07XvHI8qqHH_albums.yml
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/user_wizzler_playlists.yml
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/artist_7Ln80lUS6He07XvHI8qqHH_albums.yml
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/user_wizzler_playlists.yml
244
+ - spec/vcr_cassettes/user_wizzler_playlists_limit_20_offset_0.yml
245
245
  has_rdoc: