spotilocal 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spotilocal/cli.rb +15 -0
- data/lib/spotilocal/client.rb +27 -4
- data/lib/spotilocal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc6be62298a581fa787e3a2c1f5ab941366880a3
|
4
|
+
data.tar.gz: f0ac2a9b8cfd577c3c949de7503490b1f179e2e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '097ce07a68dc51b39ebac7498f31dfb018f178953796a0945d61ff8e0d5ad6cbb5077d54255553b7bd7dedd4b5681819380c0e2a6f9d63768868182034e80a4c'
|
7
|
+
data.tar.gz: f655daa036cc768c16da4389030bbd5d98efca2e1431f5fca0012f079f0e759494fc796d54addedbe37aebd2d781ec6441907c86b8963a1f8351138fb338fe97
|
data/lib/spotilocal/cli.rb
CHANGED
@@ -14,5 +14,20 @@ module Spotilocal
|
|
14
14
|
def unpause
|
15
15
|
Spotilocal::Client.new.unpause
|
16
16
|
end
|
17
|
+
|
18
|
+
desc 'status', 'display current client status (verbose)'
|
19
|
+
def status
|
20
|
+
puts Spotilocal::Client.new.status.to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'current RESOURCE', 'display information about playing resource'
|
24
|
+
method_option :only, aliases: '-o', desc: 'Display only given key'
|
25
|
+
def current(resource)
|
26
|
+
if options[:only]
|
27
|
+
puts Spotilocal::Client.new.current[resource][options[:only]]
|
28
|
+
else
|
29
|
+
puts Spotilocal::Client.new.current[resource].to_json
|
30
|
+
end
|
31
|
+
end
|
17
32
|
end
|
18
33
|
end
|
data/lib/spotilocal/client.rb
CHANGED
@@ -15,25 +15,48 @@ module Spotilocal
|
|
15
15
|
lcall(:status)
|
16
16
|
end
|
17
17
|
|
18
|
+
def current
|
19
|
+
current = {}
|
20
|
+
current['track'] = track_from_status status
|
21
|
+
current['album'] = album_from_status status
|
22
|
+
current['artist'] = artist_from_status status
|
23
|
+
|
24
|
+
current
|
25
|
+
end
|
26
|
+
|
18
27
|
def play(uri)
|
19
28
|
r = lcall(:play, params: { uri: uri })
|
20
|
-
r
|
29
|
+
r['playing'] && r['track']['track_resource']['uri'] == uri
|
21
30
|
end
|
22
31
|
|
23
32
|
def pause
|
24
|
-
!lcall(:pause, params: { pause: 'true' })
|
33
|
+
!lcall(:pause, params: { pause: 'true' })['playing']
|
25
34
|
end
|
26
35
|
|
27
36
|
def unpause
|
28
|
-
lcall(:pause, params: { pause: 'false' })
|
37
|
+
lcall(:pause, params: { pause: 'false' })['playing']
|
29
38
|
end
|
30
39
|
|
31
40
|
private
|
32
41
|
|
42
|
+
%w(artist album track).each do |res|
|
43
|
+
define_method("#{res}_from_status") do |stat|
|
44
|
+
h = {}
|
45
|
+
h['name'] = stat['track']["#{res}_resource"]['name']
|
46
|
+
h['uri'] = stat['track']["#{res}_resource"]['uri']
|
47
|
+
if res == 'track'
|
48
|
+
h['length'] = stat['track']['length']
|
49
|
+
h['type'] = stat['track']['track_type']
|
50
|
+
end
|
51
|
+
|
52
|
+
h
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
33
56
|
def lcall(loc, params: {}, resource: :remote)
|
34
57
|
req = Typhoeus.get("#{url}/#{resource}/#{loc}.json",
|
35
58
|
params: params.merge(csrf: csrf, oauth: oauth))
|
36
|
-
JSON.parse(req.response_body
|
59
|
+
JSON.parse(req.response_body)
|
37
60
|
end
|
38
61
|
|
39
62
|
def oauth_token
|
data/lib/spotilocal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spotilocal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flipez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|