rspotify 0.2.0 → 0.3.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 +12 -11
- data/lib/rspotify/album.rb +16 -4
- data/lib/rspotify/playlist.rb +9 -7
- data/lib/rspotify/track.rb +9 -2
- data/lib/rspotify/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36f4e80d9142dc5193f056b22e94e8ff632e4a81
|
4
|
+
data.tar.gz: 87dc03fabf423e54e67a781c4bfa2850a302f649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7edc724a34dbfa0fba08048b6b968b0db3ec37f98bd5f2cb6f61967d0d63e1e284e49a451d1051aa94bd9f5c8611c689cb55a00e78299649fa24de47ff018d50
|
7
|
+
data.tar.gz: 5c1ec4d1fcd29fcfcd49edc17908a290f211392d4ad11db8c6484f91489b7b3ad750e1d6c27ee1c2f513383f6ba2abb0cc1daafbf4274826d6cf76d873f9b231
|
data/README.md
CHANGED
@@ -18,27 +18,27 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Directly access public data such as albums, tracks, artists and users:
|
21
|
+
Directly access Spotify public data such as albums, tracks, artists and users:
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
require 'rspotify'
|
25
25
|
|
26
|
-
tracks = RSpotify::Track.search('
|
26
|
+
tracks = RSpotify::Track.search('Do I wanna know?')
|
27
27
|
|
28
|
-
tracks.first.name #=> "
|
29
|
-
tracks.first.popularity #=>
|
28
|
+
tracks.first.name #=> "Do I Wanna Know?"
|
29
|
+
tracks.first.popularity #=> 86
|
30
|
+
|
31
|
+
artists = tracks.first.artists
|
32
|
+
artists.first.name #=> "Arctic Monkeys"
|
33
|
+
artists.first.uri #=> "spotify:artist:7Ln80lUS6He07XvHI8qqHH"
|
30
34
|
|
31
35
|
album = tracks.first.album
|
32
|
-
album.name #=> "
|
36
|
+
album.name #=> "AM"
|
33
37
|
album.images #=> (Image array)
|
34
38
|
|
35
|
-
artists = tracks.first.artists
|
36
|
-
artists.first.name #=> "Black Sabbath"
|
37
|
-
artists.first.uri #=> "spotify:artist:5M52tdBnJaKSvOpJGz8mfZ"
|
38
|
-
|
39
39
|
# Find by id
|
40
40
|
artist = RSpotify::Artist.find('5K4W6rqBFWDnAN6FQUkS6x')
|
41
|
-
artist.genres #=> ["Alternative Rap", "East Coast Rap",
|
41
|
+
artist.genres #=> ["Alternative Rap", "East Coast Rap", ...]
|
42
42
|
|
43
43
|
album = RSpotify::Album.find('0uZ8zQLHru4BiNTL2PQY91')
|
44
44
|
album.album_type #=> "single"
|
@@ -49,10 +49,11 @@ track.duration_ms #=> 270800
|
|
49
49
|
track.album #=> (Album object)
|
50
50
|
|
51
51
|
user = RSpotify::User.find('wizzler')
|
52
|
+
user.href #=> "https://api.spotify.com/v1/users/wizzler"
|
52
53
|
user.external_urls["spotify"] #=> "https://open.spotify.com/user/wizzler"
|
53
54
|
```
|
54
55
|
|
55
|
-
Some data require authentication to be accessed, such as playlists. You can easily get your credentials [here](https://developer.spotify.com/my-applications)
|
56
|
+
Some data require authentication to be accessed, such as playlists. You can easily get your credentials [here](https://developer.spotify.com/my-applications).
|
56
57
|
|
57
58
|
Then just copy and paste them like so:
|
58
59
|
|
data/lib/rspotify/album.rb
CHANGED
@@ -2,7 +2,8 @@ module RSpotify
|
|
2
2
|
|
3
3
|
class Album < Base
|
4
4
|
|
5
|
-
attr_accessor :album_type, :
|
5
|
+
attr_accessor :album_type, :artists, :available_markets, :external_ids, :genres, :images,
|
6
|
+
:name, :popularity, :release_date, :release_date_precision, :tracks
|
6
7
|
|
7
8
|
def self.find(id)
|
8
9
|
super(id, 'album')
|
@@ -13,9 +14,20 @@ module RSpotify
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def initialize(options = {})
|
16
|
-
@album_type
|
17
|
-
@
|
18
|
-
@
|
17
|
+
@album_type = options['album_type']
|
18
|
+
@available_markets = options['available_markets']
|
19
|
+
@external_ids = options['external_ids']
|
20
|
+
@genres = options['genres']
|
21
|
+
@images = options['images']
|
22
|
+
@name = options['name']
|
23
|
+
@popularity = options['popularity']
|
24
|
+
@release_date = options['release_date']
|
25
|
+
@release_date_precision = options['release_date_precision']
|
26
|
+
|
27
|
+
if options['artists']
|
28
|
+
artists = options['artists']
|
29
|
+
@artists = artists.map { |a| Artist.new a }
|
30
|
+
end
|
19
31
|
|
20
32
|
if options['tracks']
|
21
33
|
tracks = options['tracks']['items']
|
data/lib/rspotify/playlist.rb
CHANGED
@@ -20,16 +20,18 @@ module RSpotify
|
|
20
20
|
@followers = options['followers']
|
21
21
|
@images = options['images']
|
22
22
|
@name = options['name']
|
23
|
-
@owner = options['owner']
|
24
23
|
@public = options['public']
|
25
|
-
@tracks = options['tracks']
|
26
24
|
|
27
|
-
|
28
|
-
|
25
|
+
if options['owner']
|
26
|
+
@owner = User.new options['owner']
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
if options['tracks']
|
30
|
+
tracks = options['tracks']['items']
|
31
|
+
@tracks = tracks.map { |t| Track.new t['track'] }
|
32
|
+
end
|
33
|
+
|
34
|
+
super(options)
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
data/lib/rspotify/track.rb
CHANGED
@@ -14,8 +14,6 @@ module RSpotify
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize(options = {})
|
17
|
-
@album = Album.new options['album'] if options['album']
|
18
|
-
@artists = options['artists'].map { |a| Artist.new a }
|
19
17
|
@available_markets = options['available_markets']
|
20
18
|
@disc_number = options['disc_number']
|
21
19
|
@duration_ms = options['duration_ms']
|
@@ -26,6 +24,15 @@ module RSpotify
|
|
26
24
|
@preview_url = options['preview_url']
|
27
25
|
@track_number = options['track_number']
|
28
26
|
|
27
|
+
if options['album']
|
28
|
+
@album = Album.new options['album']
|
29
|
+
end
|
30
|
+
|
31
|
+
if options['artists']
|
32
|
+
artists = options['artists']
|
33
|
+
@artists = artists.map { |a| Artist.new a }
|
34
|
+
end
|
35
|
+
|
29
36
|
super(options)
|
30
37
|
end
|
31
38
|
|
data/lib/rspotify/version.rb
CHANGED