ghetto-blaster 0.1.0 → 0.1.1
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/.gitignore +1 -0
- data/README.md +8 -16
- data/exe/ghetto-blaster +7 -0
- data/ghetto-blaster.gemspec +2 -0
- data/lib/ghetto/blaster/cli.rb +58 -0
- data/lib/ghetto/blaster/version.rb +1 -1
- metadata +33 -3
- data/Gemfile.lock +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd7de75a4e05abc6048bb5ad9e80aad610918531b4dc264423b0969eafdb53de
|
4
|
+
data.tar.gz: 7a5b7ce692df4520639df745b4c77e26eb1fa9bb1bd8d92a64d50bea46ec5441
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d6bf04b9129834a4a93ee978c54a7a3228c7bd7d5fae3f80ddbe521f9fd293c72fe2399e1388a278e660b6dab3203184fbb1ba95645874fc57a28310d4b623f
|
7
|
+
data.tar.gz: e97b69b4059adb6eac629da8e68e1fe169b1b6d88efeb69482f43fe11eea4482f40be83d821600551637cf376af1ce08ab410c75c1ec458a22c73a8828d0a919
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,28 +1,20 @@
|
|
1
1
|
# Ghetto::Blaster
|
2
2
|
|
3
|
-
|
3
|
+
A command line client for listening to soundcloud in your terminal.
|
4
4
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'ghetto-blaster'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
8
|
$ gem install ghetto-blaster
|
22
9
|
|
23
10
|
## Usage
|
24
11
|
|
25
|
-
|
12
|
+
You will need to lookup your soundcloud client id. There are
|
13
|
+
instructions on the internets on how to find this.
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ SOUNDCLOUD_CLIENT_ID=x ghetto-blaster play jodieoverland | xargs mplayer
|
17
|
+
```
|
26
18
|
|
27
19
|
## Development
|
28
20
|
|
@@ -32,7 +24,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
24
|
|
33
25
|
## Contributing
|
34
26
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
27
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mokhan/ghetto-blaster.
|
36
28
|
|
37
29
|
## License
|
38
30
|
|
data/exe/ghetto-blaster
ADDED
data/ghetto-blaster.gemspec
CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.add_dependency "net-hippie", "~> 0.1"
|
25
|
+
spec.add_dependency "thor", "~> 0.20"
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.16"
|
25
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'net/hippie'
|
3
|
+
|
4
|
+
module Ghetto
|
5
|
+
module Blaster
|
6
|
+
class CLI < Thor
|
7
|
+
class_option :client_id, default: ENV['SOUNDCLOUD_CLIENT_ID']
|
8
|
+
|
9
|
+
desc "play username", "play music by a specific user"
|
10
|
+
def play(username)
|
11
|
+
tracks_for(username).each do |track|
|
12
|
+
stream_url = "#{track[:stream_url]}s/?client_id=#{client_id}"
|
13
|
+
json = JSON.parse(client.get(stream_url).body, symbolize_names: true)
|
14
|
+
say json[json.keys.first]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "user username", "fetch user info"
|
19
|
+
def user(username)
|
20
|
+
say client.get(resolve(username)[:location]).body
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "tracks username", "fetch tracks for user"
|
24
|
+
def tracks(username)
|
25
|
+
say tracks_for(username, parse: false)
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "version", "print version"
|
29
|
+
def version
|
30
|
+
say Ghetto::Blaster::VERSION
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def tracks_for(username, parse: true)
|
36
|
+
user_id = resolve(username)[:location].split('?')[0].split('/').last
|
37
|
+
body = client.get(build_uri("/users/#{user_id}/tracks?client_id=#{client_id}")).body
|
38
|
+
parse ? JSON.parse(body, symbolize_names: true) : body
|
39
|
+
end
|
40
|
+
|
41
|
+
def client
|
42
|
+
@client ||= Net::Hippie::Client.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def client_id
|
46
|
+
options[:client_id]
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_uri(path)
|
50
|
+
URI.join("https://api.soundcloud.com", path)
|
51
|
+
end
|
52
|
+
|
53
|
+
def resolve(username)
|
54
|
+
JSON.parse(client.get(build_uri("/resolve?url=https://soundcloud.com/#{username}&client_id=#{client_id}")).body, symbolize_names: true)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghetto-blaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mo
|
@@ -10,6 +10,34 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-hippie
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.20'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.20'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,7 +83,8 @@ dependencies:
|
|
55
83
|
description: Play that funky music..
|
56
84
|
email:
|
57
85
|
- mo@mokhan.c
|
58
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- ghetto-blaster
|
59
88
|
extensions: []
|
60
89
|
extra_rdoc_files: []
|
61
90
|
files:
|
@@ -63,14 +92,15 @@ files:
|
|
63
92
|
- ".rspec"
|
64
93
|
- ".travis.yml"
|
65
94
|
- Gemfile
|
66
|
-
- Gemfile.lock
|
67
95
|
- LICENSE.txt
|
68
96
|
- README.md
|
69
97
|
- Rakefile
|
70
98
|
- bin/console
|
71
99
|
- bin/setup
|
100
|
+
- exe/ghetto-blaster
|
72
101
|
- ghetto-blaster.gemspec
|
73
102
|
- lib/ghetto/blaster.rb
|
103
|
+
- lib/ghetto/blaster/cli.rb
|
74
104
|
- lib/ghetto/blaster/version.rb
|
75
105
|
homepage: https://www.mokhan.ca
|
76
106
|
licenses:
|
data/Gemfile.lock
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ghetto-blaster (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.3)
|
10
|
-
rake (10.5.0)
|
11
|
-
rspec (3.7.0)
|
12
|
-
rspec-core (~> 3.7.0)
|
13
|
-
rspec-expectations (~> 3.7.0)
|
14
|
-
rspec-mocks (~> 3.7.0)
|
15
|
-
rspec-core (3.7.1)
|
16
|
-
rspec-support (~> 3.7.0)
|
17
|
-
rspec-expectations (3.7.0)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.7.0)
|
20
|
-
rspec-mocks (3.7.0)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.7.0)
|
23
|
-
rspec-support (3.7.1)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
bundler (~> 1.16)
|
30
|
-
ghetto-blaster!
|
31
|
-
rake (~> 10.0)
|
32
|
-
rspec (~> 3.0)
|
33
|
-
|
34
|
-
BUNDLED WITH
|
35
|
-
1.16.1
|