rspotify 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/rspotify/artist.rb +17 -1
- data/lib/rspotify/connection.rb +10 -0
- data/lib/rspotify/version.rb +1 -1
- data/spec/lib/rspotify/album_spec.rb +1 -1
- data/spec/lib/rspotify/artist_spec.rb +10 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a915d527294d8772bf9f21e87660fce4241a9beb
|
4
|
+
data.tar.gz: 494e4a78f576a65780077bbd98e2a11aeb610c78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e604afc1b2830bf9bb3e07b5a9e7e042bb184d61bf2476efee94759c2e3f5fc2163b1cd4c7830343f3bb90d91e48256e92c26573c80ac62b5f34f27f466e7b8
|
7
|
+
data.tar.gz: e7fa3c1792e6f9dbc456758f5677ba9c6b2bdc4795631cd07c7694c2dadeba0a31675719b8a8812f2f019d532d86c300556d770a4b24fc510d2998e52276b2a1
|
data/README.md
CHANGED
@@ -61,7 +61,7 @@ Find by id:
|
|
61
61
|
|
62
62
|
```ruby
|
63
63
|
arctic_monkeys = RSpotify::Artist.find('7Ln80lUS6He07XvHI8qqHH')
|
64
|
-
arctic_monkeys.
|
64
|
+
arctic_monkeys.related_artists #=> (Artist array)
|
65
65
|
|
66
66
|
am = RSpotify::Album.find('41vPD50kQ7JeamkxQW7Vuy')
|
67
67
|
am.album_type #=> "single"
|
@@ -111,7 +111,7 @@ You'll may want your application to access an user's Spotify account.
|
|
111
111
|
|
112
112
|
For instance, suppose you want your app to create playlists for the user based on his taste, or to add a feature that syncs user's playlists with some external app.
|
113
113
|
|
114
|
-
If so, add the following
|
114
|
+
If so, add the following to your application (Remember to [get your credentials](https://developer.spotify.com/my-applications))
|
115
115
|
|
116
116
|
```ruby
|
117
117
|
# config/application.rb
|
@@ -123,7 +123,7 @@ RSpotify::authenticate("<your_client_id>", "<your_client_secret>")
|
|
123
123
|
# config/initializers/omniauth.rb
|
124
124
|
|
125
125
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
126
|
-
provider :spotify, "<your_client_id>", "<your_client_secret>", scope: 'user-read-email playlist-modify'
|
126
|
+
provider :spotify, "<your_client_id>", "<your_client_secret>", scope: 'user-read-email playlist-modify-public'
|
127
127
|
end
|
128
128
|
```
|
129
129
|
|
@@ -170,7 +170,7 @@ end
|
|
170
170
|
|
171
171
|
The user's access token is automatically refreshed by RSpotify when needed. This is specially useful if you persist the user data on a database: this way he only needs to log in to Spotify once in his entire use of your application.
|
172
172
|
|
173
|
-
RSpotify provides a way to
|
173
|
+
RSpotify provides a way to facilitate persistence:
|
174
174
|
|
175
175
|
```ruby
|
176
176
|
hash = spotify_user.to_hash
|
data/lib/rspotify/artist.rb
CHANGED
@@ -68,9 +68,25 @@ module RSpotify
|
|
68
68
|
@albums = json['items'].map { |a| Album.new a }
|
69
69
|
end
|
70
70
|
|
71
|
+
# 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}.
|
72
|
+
#
|
73
|
+
# @return [Array<Artist>]
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# artist.name #=> "Arctic Monkeys"
|
77
|
+
# related_artists = artist.related_artists
|
78
|
+
#
|
79
|
+
# related_artists.size #=> 20
|
80
|
+
# related_artists.first.name #=> "Miles Kane"
|
81
|
+
def related_artists
|
82
|
+
return @related_artists unless @related_artists.nil?
|
83
|
+
json = RSpotify.get("artists/#{@id}/related-artists")
|
84
|
+
@related_artists = json['artists'].map { |a| Artist.new a }
|
85
|
+
end
|
86
|
+
|
71
87
|
# Returns artist's 10 top tracks by country.
|
72
88
|
#
|
73
|
-
# @param country [Symbol]
|
89
|
+
# @param country [Symbol] An {http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ISO 3166-1 alpha-2 country code}
|
74
90
|
# @return [Array<Track>]
|
75
91
|
#
|
76
92
|
# @example
|
data/lib/rspotify/connection.rb
CHANGED
@@ -15,6 +15,16 @@ module RSpotify
|
|
15
15
|
end
|
16
16
|
private_class_method :auth_header
|
17
17
|
|
18
|
+
# Authenticates access to restricted data. Requires {https://developer.spotify.com/my-applications user credentials}.
|
19
|
+
#
|
20
|
+
# @param client_id [String]
|
21
|
+
# @param client_secret [String]
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
# RSpotify.authenticate("<your_client_id>", "<your_client_secret>")
|
25
|
+
#
|
26
|
+
# playlist = RSpotify::Playlist.find('wizzler', '00wHcTN0zQiun4xri9pmvX')
|
27
|
+
# playlist.name #=> "Movie Soundtrack Masterpieces"
|
18
28
|
def self.authenticate(client_id, client_secret)
|
19
29
|
@client_id, @client_secret = client_id, client_secret
|
20
30
|
request_body = { grant_type: 'client_credentials' }
|
data/lib/rspotify/version.rb
CHANGED
@@ -74,7 +74,7 @@ describe RSpotify::Album do
|
|
74
74
|
|
75
75
|
albums = RSpotify::Album.search('AM', offset: 10)
|
76
76
|
expect(albums.size) .to eq 20
|
77
|
-
expect(albums.map(&:name)) .to include('Melody AM', 'I Am
|
77
|
+
expect(albums.map(&:name)) .to include('Melody AM', 'I Am')
|
78
78
|
|
79
79
|
albums = RSpotify::Album.search('AM', limit: 10, offset: 10)
|
80
80
|
expect(albums.size) .to eq 10
|
@@ -34,6 +34,14 @@ describe RSpotify::Artist do
|
|
34
34
|
expect(top_tracks.first) .to be_an RSpotify::Track
|
35
35
|
expect(top_tracks.map(&:name)) .to include('Do I Wanna Know?', 'R U Mine?', 'Arabella', 'Knee Socks')
|
36
36
|
end
|
37
|
+
|
38
|
+
it 'should find artist with correct related artists' do
|
39
|
+
related_artists = @artist.related_artists
|
40
|
+
expect(related_artists) .to be_an Array
|
41
|
+
expect(related_artists.size) .to eq 20
|
42
|
+
expect(related_artists.first) .to be_an RSpotify::Artist
|
43
|
+
expect(related_artists.map(&:name)) .to include('Miles Kane', 'We Are Scientists', 'Razorlight')
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
describe 'Artist::find receiving array of ids' do
|
@@ -69,11 +77,11 @@ describe RSpotify::Artist do
|
|
69
77
|
|
70
78
|
artists = RSpotify::Artist.search('Arctic', offset: 10)
|
71
79
|
expect(artists.size) .to eq 20
|
72
|
-
expect(artists.map(&:name)) .to include('Arctic
|
80
|
+
expect(artists.map(&:name)) .to include('Arctic Light', 'Arctic Night')
|
73
81
|
|
74
82
|
artists = RSpotify::Artist.search('Arctic', limit: 10, offset: 10)
|
75
83
|
expect(artists.size) .to eq 10
|
76
|
-
expect(artists.map(&:name)) .to include('Arctic
|
84
|
+
expect(artists.map(&:name)) .to include('Arctic Light')
|
77
85
|
end
|
78
86
|
end
|
79
87
|
end
|
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.1.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-07-
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
@@ -172,3 +172,4 @@ test_files:
|
|
172
172
|
- spec/lib/rspotify/user_spec.rb
|
173
173
|
- spec/lib/rspotify_spec.rb
|
174
174
|
- spec/spec_helper.rb
|
175
|
+
has_rdoc:
|