rspotify 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/rspotify.rb +3 -2
- data/lib/rspotify/album.rb +10 -1
- data/lib/rspotify/artist.rb +6 -1
- data/lib/rspotify/base.rb +7 -4
- data/lib/rspotify/track.rb +8 -3
- data/lib/rspotify/user.rb +18 -0
- data/lib/rspotify/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41767dc3420c792c7cffc69f25a468adf3e8eb61
|
4
|
+
data.tar.gz: 143d31600e35010404e0709a1baec81c7c413fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e65c1ae80cd2e3c455fc7ea25f7f94bd32850cd921962b5f3d5e224c7f504dff5009041e9ec8c259d893d8164606e73361f08847e727dacbabe779ff6bc015c4
|
7
|
+
data.tar.gz: 02d62eb595182b7fbe4e224b668206c398b18f2f274e813384cabbfeb034be43689d5fb74396eda540baa02c29ec5a2610682719bd84f2493b6323bbbb1a616b
|
data/README.md
CHANGED
@@ -33,6 +33,19 @@ album.images #=> (Image array)
|
|
33
33
|
artists = tracks.first.artists
|
34
34
|
artists.first.name #=> "Black Sabbath"
|
35
35
|
artists.first.uri #=> "spotify:artist:5M52tdBnJaKSvOpJGz8mfZ"
|
36
|
+
|
37
|
+
# Find by id
|
38
|
+
artist = RSpotify::Artist.find('5K4W6rqBFWDnAN6FQUkS6x')
|
39
|
+
artist.genres #=> ["Alternative Rap", "East Coast Rap", "Hardcore Rap", "Hip Hop", "Midwest Rap", "Pop-Rap", "Rap"]
|
40
|
+
|
41
|
+
album = RSpotify::Album.find('0uZ8zQLHru4BiNTL2PQY91')
|
42
|
+
album.album_type #=> "single"
|
43
|
+
|
44
|
+
track = RSpotify::Track.find('2qmxggATKFIeg68guRSG3r')
|
45
|
+
track.duration_ms #=> 270800
|
46
|
+
|
47
|
+
user = RSpotify::User.find('wizzler')
|
48
|
+
user.external_urls["spotify"] #=> "https://open.spotify.com/user/wizzler"
|
36
49
|
```
|
37
50
|
More documentation will follow
|
38
51
|
|
data/lib/rspotify.rb
CHANGED
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
require 'restclient'
|
5
5
|
|
6
6
|
module RSpotify
|
7
|
-
|
7
|
+
|
8
8
|
BASE_URI = 'https://api.spotify.com/v1/'
|
9
9
|
VERBS = %w(get post put delete)
|
10
10
|
|
@@ -12,7 +12,8 @@ module RSpotify
|
|
12
12
|
autoload :Artist, 'rspotify/artist'
|
13
13
|
autoload :Album, 'rspotify/album'
|
14
14
|
autoload :Track, 'rspotify/track'
|
15
|
-
|
15
|
+
autoload :User, 'rspotify/user'
|
16
|
+
|
16
17
|
VERBS.each do |verb|
|
17
18
|
define_singleton_method verb do |path, *params|
|
18
19
|
url = BASE_URI + path
|
data/lib/rspotify/album.rb
CHANGED
@@ -2,7 +2,11 @@ module RSpotify
|
|
2
2
|
|
3
3
|
class Album < Base
|
4
4
|
|
5
|
-
attr_accessor :album_type, :images
|
5
|
+
attr_accessor :album_type, :images, :name, :tracks
|
6
|
+
|
7
|
+
def self.find(id)
|
8
|
+
super(id, 'album')
|
9
|
+
end
|
6
10
|
|
7
11
|
def self.search(query, limit = 20, offset = 0)
|
8
12
|
super(query, 'album', limit, offset)
|
@@ -11,6 +15,11 @@ module RSpotify
|
|
11
15
|
def initialize(options = {})
|
12
16
|
@album_type = options['album_type']
|
13
17
|
@images = options['images']
|
18
|
+
@name = options['name']
|
19
|
+
|
20
|
+
if options['tracks']
|
21
|
+
@tracks = options['tracks']['items'].map { |t| Track.new (t) }
|
22
|
+
end
|
14
23
|
|
15
24
|
super(options)
|
16
25
|
end
|
data/lib/rspotify/artist.rb
CHANGED
@@ -2,7 +2,11 @@ module RSpotify
|
|
2
2
|
|
3
3
|
class Artist < Base
|
4
4
|
|
5
|
-
attr_accessor :genres, :images, :popularity
|
5
|
+
attr_accessor :genres, :images, :name, :popularity
|
6
|
+
|
7
|
+
def self.find(id)
|
8
|
+
super(id, 'artist')
|
9
|
+
end
|
6
10
|
|
7
11
|
def self.search(query, limit = 20, offset = 0)
|
8
12
|
super(query, 'artist', limit, offset)
|
@@ -11,6 +15,7 @@ module RSpotify
|
|
11
15
|
def initialize(options = {})
|
12
16
|
@genres = options['genres']
|
13
17
|
@images = options['images']
|
18
|
+
@name = options['name']
|
14
19
|
@popularity = options['popularity']
|
15
20
|
|
16
21
|
super(options)
|
data/lib/rspotify/base.rb
CHANGED
@@ -2,10 +2,14 @@ module RSpotify
|
|
2
2
|
|
3
3
|
class Base
|
4
4
|
|
5
|
-
attr_accessor :external_urls, :href, :id, :
|
5
|
+
attr_accessor :external_urls, :href, :id, :type, :uri
|
6
6
|
|
7
|
-
def self.find(id)
|
8
|
-
#
|
7
|
+
def self.find(id, type)
|
8
|
+
pluralized_type = "#{type}s"
|
9
|
+
type_class = eval type.capitalize
|
10
|
+
|
11
|
+
json = RSpotify.get "#{pluralized_type}/#{id}"
|
12
|
+
type_class.new json
|
9
13
|
end
|
10
14
|
|
11
15
|
def self.search(query, type, limit = 20, offset = 0)
|
@@ -28,7 +32,6 @@ module RSpotify
|
|
28
32
|
@external_urls = options['external_urls']
|
29
33
|
@href = options['href']
|
30
34
|
@id = options['id']
|
31
|
-
@name = options['name']
|
32
35
|
@type = options['type']
|
33
36
|
@uri = options['uri']
|
34
37
|
end
|
data/lib/rspotify/track.rb
CHANGED
@@ -2,21 +2,26 @@ module RSpotify
|
|
2
2
|
|
3
3
|
class Track < Base
|
4
4
|
|
5
|
-
attr_accessor :album, :artists, :available_markets, :disc_number, :duration_ms,
|
6
|
-
:
|
5
|
+
attr_accessor :album, :artists, :available_markets, :disc_number, :duration_ms, :explicit,
|
6
|
+
:external_ids, :name, :popularity, :preview_url, :track_number
|
7
|
+
|
8
|
+
def self.find(id)
|
9
|
+
super(id, 'track')
|
10
|
+
end
|
7
11
|
|
8
12
|
def self.search(query, limit = 20, offset = 0)
|
9
13
|
super(query, 'track', limit, offset)
|
10
14
|
end
|
11
15
|
|
12
16
|
def initialize(options = {})
|
13
|
-
@album = Album.new options['album']
|
17
|
+
@album = Album.new options['album'] if options['album']
|
14
18
|
@artists = options['artists'].map { |a| Artist.new a }
|
15
19
|
@available_markets = options['available_markets']
|
16
20
|
@disc_number = options['disc_number']
|
17
21
|
@duration_ms = options['duration_ms']
|
18
22
|
@explicit = options['explicit']
|
19
23
|
@external_ids = options['external_ids']
|
24
|
+
@name = options['name']
|
20
25
|
@popularity = options['popularity']
|
21
26
|
@preview_url = options['preview_url']
|
22
27
|
@track_number = options['track_number']
|
data/lib/rspotify/version.rb
CHANGED
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Sad
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/rspotify/artist.rb
|
98
98
|
- lib/rspotify/base.rb
|
99
99
|
- lib/rspotify/track.rb
|
100
|
+
- lib/rspotify/user.rb
|
100
101
|
- lib/rspotify/version.rb
|
101
102
|
- rspotify.gemspec
|
102
103
|
homepage: http://rubygems.org/gems/rspotify
|