spotilocal 0.1.0 → 0.2.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/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +15 -0
- data/.travis.yml +8 -0
- data/README.md +13 -5
- data/Rakefile +2 -2
- data/bin/console +3 -3
- data/lib/spotilocal.rb +1 -1
- data/lib/spotilocal/{local.rb → client.rb} +21 -8
- data/lib/spotilocal/version.rb +1 -1
- data/spotilocal.gemspec +13 -9
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3042a37f2e758e8437cd73fe3142cc73c4f7d00
|
4
|
+
data.tar.gz: dcf7e8c8ce8028983f1ed68049a92d2e13e70cf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb84933e51b2078608940eaafab81c1a62dd2b6b8ca677be4fe0676036a7e54dde60f98da1d959cc13cbb7a87a0a50ff94a9972bb22efcbd97082cb61a4a4cc
|
7
|
+
data.tar.gz: 3589900b3eb8353aaf621380db9c43a9e525ab8d4fe10f8e2926554cd057d519401f132d26ba60e1abaf4d704147adb815c1f1d8b7f4bc11c13b79bcc23f3c35
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-12-24 13:20:03 +0100 using RuboCop version 0.42.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
Style/Documentation:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*'
|
13
|
+
- 'test/**/*'
|
14
|
+
- 'lib/spotilocal.rb'
|
15
|
+
- 'lib/spotilocal/client.rb'
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Spotilocal
|
2
|
+
[](https://travis-ci.org/Flipez/spotilocal)
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
4
|
+
Spotilocal allows you to query the local spotify client and fetch informations about the current status and perform actions such as start/stop.
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -22,7 +21,16 @@ Or install it yourself as:
|
|
22
21
|
|
23
22
|
## Usage
|
24
23
|
|
25
|
-
|
24
|
+
Currently you have to enter the port manually. Autodiscover is planned.
|
25
|
+
```ruby
|
26
|
+
# Create a new spotify object
|
27
|
+
s = Spotilocal::Local.new port: 4382
|
28
|
+
```
|
29
|
+
|
30
|
+
After that you can simply fetch some informations.
|
31
|
+
```ruby
|
32
|
+
s.status
|
33
|
+
```
|
26
34
|
|
27
35
|
## Development
|
28
36
|
|
@@ -32,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
40
|
|
33
41
|
## Contributing
|
34
42
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Flipez/spotilocal.
|
36
44
|
|
37
45
|
|
38
46
|
## License
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
task :
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'spotilocal'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "spotilocal"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/lib/spotilocal.rb
CHANGED
@@ -1,31 +1,44 @@
|
|
1
1
|
module Spotilocal
|
2
|
-
class
|
2
|
+
class Client
|
3
3
|
attr_accessor :port, :csrf, :url, :oauth
|
4
4
|
|
5
5
|
HEADERS = { Origin: 'https://open.spotify.com' }.freeze
|
6
6
|
|
7
|
-
def initialize
|
7
|
+
def initialize(port: nil)
|
8
8
|
raise 'Port required' unless port
|
9
9
|
@url = "http://localhost:#{port}"
|
10
|
-
@csrf =
|
11
|
-
@oauth =
|
10
|
+
@csrf = csrf_token
|
11
|
+
@oauth = oauth_token
|
12
12
|
end
|
13
13
|
|
14
14
|
def status
|
15
15
|
req = Typhoeus.get("#{url}/remote/status.json",
|
16
|
-
|
17
|
-
)
|
16
|
+
params: { csrf: csrf, oauth: oauth })
|
18
17
|
puts JSON.parse(req.response_body)
|
19
18
|
end
|
20
19
|
|
20
|
+
def pause
|
21
|
+
!lcall(:pause, params: { pause: 'true' })['playing']
|
22
|
+
end
|
23
|
+
|
24
|
+
def unpause
|
25
|
+
lcall(:pause, params: { pause: 'false' })['playing']
|
26
|
+
end
|
27
|
+
|
21
28
|
private
|
22
29
|
|
23
|
-
def
|
30
|
+
def lcall(loc, params: {}, resource: :remote)
|
31
|
+
req = Typhoeus.get("#{url}/#{resource}/#{loc}.json",
|
32
|
+
params: params.merge(csrf: csrf, oauth: oauth))
|
33
|
+
JSON.parse(req.response_body)
|
34
|
+
end
|
35
|
+
|
36
|
+
def oauth_token
|
24
37
|
req = Typhoeus.get('http://open.spotify.com/token', followlocation: true)
|
25
38
|
JSON.parse(req.response_body)['t']
|
26
39
|
end
|
27
40
|
|
28
|
-
def
|
41
|
+
def csrf_token
|
29
42
|
req = Typhoeus.get("#{url}/simplecsrf/token.json", headers: HEADERS)
|
30
43
|
JSON.parse(req.response_body)['token']
|
31
44
|
end
|
data/lib/spotilocal/version.rb
CHANGED
data/spotilocal.gemspec
CHANGED
@@ -4,24 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'spotilocal/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'spotilocal'
|
8
8
|
spec.version = Spotilocal::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Flipez']
|
10
|
+
spec.email = ['code@brauser.io']
|
11
11
|
|
12
12
|
spec.summary = 'Remote control your spotify client'
|
13
13
|
spec.description = 'Wrapper to remote control a local spotify client'
|
14
14
|
spec.homepage = 'https://brauser.io'
|
15
|
-
spec.license =
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files
|
18
|
-
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = 'exe'
|
19
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ['lib']
|
21
24
|
|
22
25
|
spec.add_dependency 'typhoeus'
|
23
26
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
29
|
spec.add_development_dependency 'pry'
|
30
|
+
spec.add_development_dependency 'rubocop'
|
27
31
|
end
|
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.2.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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Wrapper to remote control a local spotify client
|
70
84
|
email:
|
71
85
|
- code@brauser.io
|
@@ -74,6 +88,9 @@ extensions: []
|
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
76
90
|
- ".gitignore"
|
91
|
+
- ".rubocop.yml"
|
92
|
+
- ".rubocop_todo.yml"
|
93
|
+
- ".travis.yml"
|
77
94
|
- Gemfile
|
78
95
|
- LICENSE.txt
|
79
96
|
- README.md
|
@@ -81,7 +98,7 @@ files:
|
|
81
98
|
- bin/console
|
82
99
|
- bin/setup
|
83
100
|
- lib/spotilocal.rb
|
84
|
-
- lib/spotilocal/
|
101
|
+
- lib/spotilocal/client.rb
|
85
102
|
- lib/spotilocal/version.rb
|
86
103
|
- spotilocal.gemspec
|
87
104
|
homepage: https://brauser.io
|