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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86ed84fdd85f9e551759817dea9a12460349a4b8
4
- data.tar.gz: e455df5cc613e94a65d78af348b6e775a21b2335
3
+ metadata.gz: 36f4e80d9142dc5193f056b22e94e8ff632e4a81
4
+ data.tar.gz: 87dc03fabf423e54e67a781c4bfa2850a302f649
5
5
  SHA512:
6
- metadata.gz: f1c2cad5eaf9f7d00a62ce9a2ef61360779ec5264873e44634c75f291bb034cea5734b1fb5f43d59b7f870603d233d444fc598418ceffd273f2121c58e8444a0
7
- data.tar.gz: 4653d34b828be1ae1575771eadbc76c76fd4416f2a08a55e84845cb909d5633ae0751ee3e6fd1bd1bf7819c85a1c80b03bee6ba5b411114390289b93778f9330
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('Paranoid')
26
+ tracks = RSpotify::Track.search('Do I wanna know?')
27
27
 
28
- tracks.first.name #=> "Paranoid"
29
- tracks.first.popularity #=> 68
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 #=> "Paranoid (Remastered)"
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", "Hardcore Rap", "Hip Hop", "Midwest Rap", "Pop-Rap", "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
 
@@ -2,7 +2,8 @@ module RSpotify
2
2
 
3
3
  class Album < Base
4
4
 
5
- attr_accessor :album_type, :images, :name, :tracks
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 = options['album_type']
17
- @images = options['images']
18
- @name = options['name']
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']
@@ -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
- super(options)
28
- end
25
+ if options['owner']
26
+ @owner = User.new options['owner']
27
+ end
29
28
 
30
- def tracks
31
- json = RSpotify.auth_get("users/#{@owner['id']}/playlists/#{@id}/tracks")
32
- json['items'].map{ |t| Track.new t['track'] }
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module RSpotify
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Sad