soundcloud9000 0.1.1 → 0.1.2
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/.travis.yml +32 -0
- data/README.md +38 -24
- data/Rakefile +26 -10
- data/lib/soundcloud9000/application.rb +27 -4
- data/lib/soundcloud9000/client.rb +1 -3
- data/lib/soundcloud9000/controllers/controller.rb +1 -1
- data/lib/soundcloud9000/controllers/track_controller.rb +47 -1
- data/lib/soundcloud9000/download_thread.rb +2 -2
- data/lib/soundcloud9000/models/player.rb +6 -2
- data/lib/soundcloud9000/models/track.rb +3 -1
- data/lib/soundcloud9000/models/track_collection.rb +5 -1
- data/lib/soundcloud9000/time_helper.rb +1 -1
- data/lib/soundcloud9000/ui/color.rb +12 -12
- data/lib/soundcloud9000/ui/input.rb +23 -22
- data/lib/soundcloud9000/ui/table.rb +4 -3
- data/lib/soundcloud9000/ui/view.rb +6 -6
- data/lib/soundcloud9000/views/player_view.rb +1 -2
- data/lib/soundcloud9000/views/splash.rb +1 -1
- data/lib/soundcloud9000/views/tracks_table.rb +2 -2
- data/lib/soundcloud9000.rb +12 -2
- data/soundcloud9000.gemspec +7 -1
- metadata +9 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85f45eb6382c77b4b5e6f025727a32c0136be683
|
|
4
|
+
data.tar.gz: 3a789fdcb6e2a325e0b82d6ac4b49ec5efccc249
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84f960223f42c5e507f2378eb602a8ca987bb3b6d7b376c373c2486353909f96be3d6099b8023cf5df4060ca573b0a1d22e33ec2a59304cd6a72931638732bb8
|
|
7
|
+
data.tar.gz: 20463d46b7aca681a04e5207f39d22571dc4164da1d044208292ce259c317588cf170d85ee4af6f589f7e705f509581f8a64533f94f859b02ffd95c65f3464b4
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
os:
|
|
2
|
+
- linux
|
|
3
|
+
- osx
|
|
4
|
+
- windows
|
|
5
|
+
language: ruby
|
|
6
|
+
rvm:
|
|
7
|
+
- 2.6.3
|
|
8
|
+
- 2.4.6
|
|
9
|
+
- 2.5.5
|
|
10
|
+
- 2.3.8
|
|
11
|
+
- 2.2.10
|
|
12
|
+
- 2.1.10
|
|
13
|
+
- 2.0.0-p648
|
|
14
|
+
- 1.9.3-p551
|
|
15
|
+
- 1.8.7-p374
|
|
16
|
+
- 1.6.7
|
|
17
|
+
env:
|
|
18
|
+
global:
|
|
19
|
+
secure: VchDDae2eYvQnsDXVDYb0V//LTxigkFsiLEGSw7meyfqS14T12k4q0b9rtCRaldjsUHs9L/vfv2qdu+ysafe3XvfL76ny7aYuupR4isFxHGADVvfaiiZCPUbaUsMQ92UzuopD5mpB5irnOWiNkq2xoyvG4wp27VKDKt1rbg2KjYz6OYG0/muk/VbJnxIW0IpMwaOJ63JlNGzuvf7rpkEmDlHHty1tnS4b5XCYQ2TjMBVQ3mdJiGdOC1mjTfRtVG/a478bTpHehpav4bqvviQKeyFbuAgqa9zqmG7LLZB7+Ep4Agfrk7tENhPc/AiYrTpFxulc8uLPER5Ol0gsj25dlJOhhQZUaD/XK37ZbgEQ2drxk7Y5FCNH5qD5Oy6ar3kyt+2K5pBw8+cukaABdYi/Ii5rdjGhUaQvJ7K5DV1C5CEwBn5YPhg2wt1RtIWsBj8dIuDjXEv+D+Nup6L//+8XowauKhdobel3zVvpfKB93H/aM2c/1xhmcn5F8F/l3XHwzFBGprqmTLvz1ca8DUCogdzYfqTfRXM41zmmvGh/EuvQZ+R9J/hR+SevK9asNMr0ZmSBkkyJh7iz2gyUrPHJQ4oXZZWE5hpxk5qonS/tNM+YKj3BPcVSLUF/oWabmpvZe/1m6nMLbDgvaG7I/E5tHqJh3JZ8n7cPssaLcXgPd0=
|
|
20
|
+
before_install:
|
|
21
|
+
- export SC_CLIENT_ID=$SOUNDCLOUD_CLIENT_ID soundcloud9000
|
|
22
|
+
install:
|
|
23
|
+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
|
|
24
|
+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install portaudio; fi
|
|
25
|
+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install mpg123; fi
|
|
26
|
+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then gem install soundcloud9000; fi
|
|
27
|
+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then gem uninstall audite; fi
|
|
28
|
+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then gem install --user audite -- --with-ldflags="-lmpg123"; fi
|
|
29
|
+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then apt-get install portaudio19-dev libmpg123-dev libncurses-dev ruby1.9.1-dev; fi
|
|
30
|
+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then gem install soundcloud9000; fi
|
|
31
|
+
script:
|
|
32
|
+
- soundcloud9000
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# soundcloud9000
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://badge.fury.io/rb/soundcloud9000)
|
|
4
|
+
|
|
5
|
+
The next generation SoundCloud client. Without all these stupid CSS files. Runs on macOS and Linux.
|
|
4
6
|
|
|
5
7
|

|
|
6
8
|
|
|
@@ -8,18 +10,25 @@ The next generation SoundCloud client. Without all these stupid CSS files. Runs
|
|
|
8
10
|
|
|
9
11
|
This hack was originally built at the [Music Hack Day Stockholm 2013](http://stockholm.musichackday.org/2013).
|
|
10
12
|
|
|
13
|
+
## What's the Difference?
|
|
14
|
+
|
|
15
|
+
The original software, soundcloud2000, is no longer maintained, and so I've picked it back up so I can add new features.
|
|
16
|
+
|
|
11
17
|
## Requirements
|
|
12
18
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
19
|
+
- Ruby (1.9)
|
|
20
|
+
- Portaudio (19)
|
|
21
|
+
- Mpg123 (1.14)
|
|
22
|
+
|
|
23
|
+
## Legal
|
|
24
|
+
|
|
25
|
+
See [this comment](https://github.com/grobie/soundcloud2000/issues/93#issuecomment-233182516).
|
|
16
26
|
|
|
17
27
|
## Installation
|
|
18
28
|
|
|
19
|
-
Assuming you have Ruby/
|
|
20
|
-
library to compile the native extensions.
|
|
29
|
+
Assuming you have Ruby/RubyGems installed, you need portaudio and mpg123 installed as libraries to compile the native extensions.
|
|
21
30
|
|
|
22
|
-
###
|
|
31
|
+
### macOS
|
|
23
32
|
|
|
24
33
|
```bash
|
|
25
34
|
xcode-select --install
|
|
@@ -56,32 +65,37 @@ SC_CLIENT_ID=YOUR_CLIENT_ID soundcloud9000
|
|
|
56
65
|
|
|
57
66
|
## Features
|
|
58
67
|
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
68
|
+
- stream SoundCloud tracks in your terminal (`enter`)
|
|
69
|
+
- scroll through sound lists (`down` / `up`)
|
|
70
|
+
- play / pause support (`space`)
|
|
71
|
+
- forward / rewind support (`right` / `left`)
|
|
72
|
+
- play tracks of different users (`u`)
|
|
73
|
+
- play favorites from a user (`f`)
|
|
74
|
+
- play sets/playlists from a user (`s`)
|
|
75
|
+
- level meter
|
|
76
|
+
- play songs in random order (`m`)
|
|
77
|
+
- no advertisements
|
|
78
|
+
- live help (`h`)
|
|
67
79
|
|
|
68
80
|
## Planned
|
|
69
81
|
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
82
|
+
- custom configuration file
|
|
83
|
+
- sorting tracks
|
|
84
|
+
- favoriting tracks
|
|
85
|
+
- play any streams, sets or sounds
|
|
86
|
+
- better browsing between users and sound lists
|
|
87
|
+
- live lyrics (don't get your hopes up for this one)
|
|
74
88
|
|
|
75
89
|
## Authors
|
|
76
90
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
91
|
+
- [Matthias Georgi](https://github.com/georgi) ([@mgeorgi](https://twitter.com/mgeorgi))
|
|
92
|
+
- [Tobias Schmidt](https://github.com/grobie) ([@dagrobie](https://twitter.com/dagrobie))
|
|
79
93
|
|
|
80
94
|
## Contributors
|
|
81
95
|
|
|
82
|
-
-
|
|
83
|
-
-
|
|
96
|
+
- [Travis Thieman](https://github.com/tthieman) ([@tthieman](https://twitter.com/thieman))
|
|
97
|
+
- [Sean Lewis](https://github.com/sophisticasean) ([@FricSean](https://twitter.com/fricsean))
|
|
84
98
|
|
|
85
99
|
## Current Maintainer
|
|
86
100
|
|
|
87
|
-
-
|
|
101
|
+
- [Sumanth Ratna](https://github.com/sumanthratna) ([@sumanthratna](https://twitter.com/sumanthratna))
|
data/Rakefile
CHANGED
|
@@ -3,19 +3,35 @@ require 'rake'
|
|
|
3
3
|
require 'yaml'
|
|
4
4
|
|
|
5
5
|
def dependencies(file)
|
|
6
|
-
`otool -L #{file}`.split("\n")[1..-1].map {|line| line.split[0] }
|
|
6
|
+
`otool -L #{file}`.split("\n")[1..-1].map { |line| line.split[0] }
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
task :dirs do
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
begin
|
|
11
|
+
Dir.mkdir 'vendor'
|
|
12
|
+
rescue StandardError
|
|
13
|
+
nil
|
|
14
|
+
end
|
|
15
|
+
begin
|
|
16
|
+
Dir.mkdir 'vendor/bin'
|
|
17
|
+
rescue StandardError
|
|
18
|
+
nil
|
|
19
|
+
end
|
|
20
|
+
begin
|
|
21
|
+
Dir.mkdir 'vendor/lib'
|
|
22
|
+
rescue StandardError
|
|
23
|
+
nil
|
|
24
|
+
end
|
|
25
|
+
begin
|
|
26
|
+
Dir.mkdir 'vendor/dyld'
|
|
27
|
+
rescue StandardError
|
|
28
|
+
nil
|
|
29
|
+
end
|
|
14
30
|
end
|
|
15
31
|
|
|
16
|
-
task :
|
|
32
|
+
task ruby: :dirs do
|
|
17
33
|
lines = `rvm info`.split("\n")[6..-1]
|
|
18
|
-
ruby = YAML.
|
|
34
|
+
ruby = YAML.safe_load(lines.join("\n"))
|
|
19
35
|
|
|
20
36
|
version = ruby.keys.first
|
|
21
37
|
home = ruby[version]['homes']['ruby']
|
|
@@ -27,8 +43,8 @@ task :ruby => :dirs do
|
|
|
27
43
|
# `cp #{dylib} vendor/dyld`
|
|
28
44
|
end
|
|
29
45
|
|
|
30
|
-
task :
|
|
31
|
-
[
|
|
46
|
+
task libs: :dirs do
|
|
47
|
+
%i[audite portaudio mpg123].each do |name|
|
|
32
48
|
lib = `gem which #{name}`.chomp
|
|
33
49
|
`cp #{lib} vendor/lib`
|
|
34
50
|
if File.extname(lib) == '.bundle'
|
|
@@ -38,7 +54,7 @@ task :libs => :dirs do
|
|
|
38
54
|
end
|
|
39
55
|
end
|
|
40
56
|
|
|
41
|
-
task :
|
|
57
|
+
task package: %i[ruby libs] do
|
|
42
58
|
`cp soundcloud9000 vendor`
|
|
43
59
|
`cp -a bin/* vendor/bin`
|
|
44
60
|
`cp -a lib/* vendor/lib`
|
|
@@ -25,17 +25,23 @@ module Soundcloud9000
|
|
|
25
25
|
|
|
26
26
|
@splash_controller = Controller.new(
|
|
27
27
|
Splash.new(
|
|
28
|
-
UI::Rect.new(0, 0, Curses.cols, Curses.lines)
|
|
28
|
+
UI::Rect.new(0, 0, Curses.cols, Curses.lines)
|
|
29
|
+
)
|
|
30
|
+
)
|
|
29
31
|
|
|
30
32
|
@track_controller = TrackController.new(
|
|
31
33
|
TracksTable.new(
|
|
32
|
-
UI::Rect.new(0, 5, Curses.cols, Curses.lines - 5)
|
|
34
|
+
UI::Rect.new(0, 5, Curses.cols, Curses.lines - 5)
|
|
35
|
+
), client
|
|
36
|
+
)
|
|
33
37
|
|
|
34
38
|
@track_controller.bind_to(TrackCollection.new(client))
|
|
35
39
|
|
|
36
40
|
@player_controller = PlayerController.new(
|
|
37
41
|
PlayerView.new(
|
|
38
|
-
UI::Rect.new(0, 0, Curses.cols, 5)
|
|
42
|
+
UI::Rect.new(0, 0, Curses.cols, 5)
|
|
43
|
+
), client
|
|
44
|
+
)
|
|
39
45
|
|
|
40
46
|
@track_controller.events.on(:select) do |track|
|
|
41
47
|
@player_controller.play(track)
|
|
@@ -73,7 +79,7 @@ module Soundcloud9000
|
|
|
73
79
|
case key
|
|
74
80
|
when :left, :right, :space, :one, :two, :three, :four, :five, :six, :seven, :eight, :nine
|
|
75
81
|
@player_controller.events.trigger(:key, key)
|
|
76
|
-
when :down, :up, :enter, :u, :f, :s, :j, :k, :m
|
|
82
|
+
when :down, :up, :enter, :u, :f, :s, :j, :k, :m, :h
|
|
77
83
|
@track_controller.events.trigger(:key, key)
|
|
78
84
|
end
|
|
79
85
|
end
|
|
@@ -89,5 +95,22 @@ module Soundcloud9000
|
|
|
89
95
|
def self.logger
|
|
90
96
|
@logger ||= Logger.new('debug.log')
|
|
91
97
|
end
|
|
98
|
+
|
|
99
|
+
def self.get_version
|
|
100
|
+
"soundcloud9000, version #{Gem.latest_spec_for('soundcloud9000').version}"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def self.get_help
|
|
104
|
+
%(
|
|
105
|
+
#{get_version}
|
|
106
|
+
Usage: soundcloud9000
|
|
107
|
+
soundcloud9000 -h | --help
|
|
108
|
+
soundcloud9000 -v | --version
|
|
109
|
+
|
|
110
|
+
Options:
|
|
111
|
+
-h --help show this message, then exit
|
|
112
|
+
-v --version show soundcloud9000 version, then exit
|
|
113
|
+
)
|
|
114
|
+
end
|
|
92
115
|
end
|
|
93
116
|
end
|
|
@@ -20,9 +20,7 @@ module Soundcloud9000
|
|
|
20
20
|
|
|
21
21
|
def resolve(permalink)
|
|
22
22
|
res = get('/resolve', url: "http://soundcloud.com/#{permalink}")
|
|
23
|
-
if res['location']
|
|
24
|
-
get URI.parse(res['location']).path
|
|
25
|
-
end
|
|
23
|
+
get URI.parse(res['location']).path if res['location']
|
|
26
24
|
end
|
|
27
25
|
|
|
28
26
|
def uri_escape(params)
|
|
@@ -55,7 +55,53 @@ module Soundcloud9000
|
|
|
55
55
|
# when :im grown up, im gonna go to brown and be smarter than u, sumanth <333 (Rahel Selemon, April 29, 2019)
|
|
56
56
|
when :m
|
|
57
57
|
@tracks.shuffle = !@tracks.shuffle
|
|
58
|
-
UI::Input.message("Shuffle #{
|
|
58
|
+
UI::Input.message("Shuffle #{@tracks.shuffle ? 'enabled' : 'disabled'}.")
|
|
59
|
+
when :h
|
|
60
|
+
puts "h"
|
|
61
|
+
@tracks.help = !@tracks.help
|
|
62
|
+
if @tracks.help
|
|
63
|
+
height = 40
|
|
64
|
+
width = 80
|
|
65
|
+
top = (Curses.lines - height) / 2
|
|
66
|
+
left = (Curses.cols - width) / 2
|
|
67
|
+
win = Curses::Window.new(height, width, top, left)
|
|
68
|
+
win.attrset(Curses.color_pair(4) | Curses::A_REVERSE | Curses::A_BOLD)
|
|
69
|
+
win.setpos(2, 3)
|
|
70
|
+
help = Application.get_help
|
|
71
|
+
win.addstr(help)
|
|
72
|
+
win.setpos(help.lines.count, 0)
|
|
73
|
+
win.addstr('-' * width)
|
|
74
|
+
win.setpos(help.lines.count + 1, 3)
|
|
75
|
+
shortcuts = %(
|
|
76
|
+
Shortcuts:
|
|
77
|
+
[enter] play selected track from beginning
|
|
78
|
+
[down]/j select track below currently selected track
|
|
79
|
+
[up]/k select track above currently selected track
|
|
80
|
+
[space] play or pause the current track
|
|
81
|
+
[right]/[left] move backward or forward in current track
|
|
82
|
+
1 jump to the time at 1/10 of the current track
|
|
83
|
+
2 jump to the time at 2/10 of the current track
|
|
84
|
+
3 jump to the time at 3/10 of the current track
|
|
85
|
+
4 jump to the time at 4/10 of the current track
|
|
86
|
+
5 jump to the time at 5/10 of the current track
|
|
87
|
+
6 jump to the time at 6/10 of the current track
|
|
88
|
+
7 jump to the time at 7/10 of the current track
|
|
89
|
+
8 jump to the time at 8/10 of the current track
|
|
90
|
+
9 jump to the time at 9/10 of the current track
|
|
91
|
+
u play tracks of different users
|
|
92
|
+
f play favorites from a user
|
|
93
|
+
s play sets/playlists from a user
|
|
94
|
+
m play songs in random order
|
|
95
|
+
h toggle this help screen
|
|
96
|
+
)
|
|
97
|
+
win.addstr(shortcuts)
|
|
98
|
+
win.box('|', '-')
|
|
99
|
+
win.refresh
|
|
100
|
+
win.getch
|
|
101
|
+
win.close
|
|
102
|
+
else
|
|
103
|
+
@tracks.clear_and_replace
|
|
104
|
+
end
|
|
59
105
|
end
|
|
60
106
|
end
|
|
61
107
|
end
|
|
@@ -8,7 +8,7 @@ module Soundcloud9000
|
|
|
8
8
|
def initialize(url, filename)
|
|
9
9
|
@events = Events.new
|
|
10
10
|
@url = URI.parse(url)
|
|
11
|
-
@file = File.open(filename,
|
|
11
|
+
@file = File.open(filename, 'w')
|
|
12
12
|
@progress = 0
|
|
13
13
|
start!
|
|
14
14
|
end
|
|
@@ -37,7 +37,7 @@ module Soundcloud9000
|
|
|
37
37
|
@file.close if @progress == @total
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
-
rescue => e
|
|
40
|
+
rescue StandardError => e
|
|
41
41
|
log e.message
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -57,7 +57,11 @@ module Soundcloud9000
|
|
|
57
57
|
@file = "#{@folder}/#{track.id}.mp3"
|
|
58
58
|
|
|
59
59
|
if !File.exist?(@file) || track.duration / 1000 > length_in_seconds * 0.95
|
|
60
|
-
|
|
60
|
+
begin
|
|
61
|
+
File.unlink(@file)
|
|
62
|
+
rescue StandardError
|
|
63
|
+
nil
|
|
64
|
+
end
|
|
61
65
|
@download = DownloadThread.new(location, @file)
|
|
62
66
|
else
|
|
63
67
|
@download = nil
|
|
@@ -93,7 +97,7 @@ module Soundcloud9000
|
|
|
93
97
|
@seek_speed[direction] = 1
|
|
94
98
|
end
|
|
95
99
|
|
|
96
|
-
@seek_time[direction] =
|
|
100
|
+
@seek_time[direction] = Time.now
|
|
97
101
|
@seek_speed[direction]
|
|
98
102
|
end
|
|
99
103
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
require_relative 'user'
|
|
2
|
+
require_relative '../application'
|
|
2
3
|
|
|
3
4
|
module Soundcloud9000
|
|
4
5
|
module Models
|
|
5
6
|
# stores information for each track that hits the player
|
|
6
7
|
class Track
|
|
7
8
|
def initialize(hash)
|
|
9
|
+
Application.logger.debug(hash)
|
|
8
10
|
@hash = hash
|
|
9
11
|
end
|
|
10
12
|
|
|
@@ -45,7 +47,7 @@ module Soundcloud9000
|
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
def comments
|
|
48
|
-
@hash['
|
|
50
|
+
@hash['comment_count']
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def stream_url
|
|
@@ -10,13 +10,14 @@ module Soundcloud9000
|
|
|
10
10
|
DEFAULT_LIMIT = 50
|
|
11
11
|
|
|
12
12
|
attr_reader :limit
|
|
13
|
-
attr_accessor :collection_to_load, :user, :playlist, :shuffle
|
|
13
|
+
attr_accessor :collection_to_load, :user, :playlist, :shuffle, :help
|
|
14
14
|
|
|
15
15
|
def initialize(client)
|
|
16
16
|
super
|
|
17
17
|
@limit = DEFAULT_LIMIT
|
|
18
18
|
@collection_to_load = :recent
|
|
19
19
|
@shuffle = false
|
|
20
|
+
@help = false
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def size
|
|
@@ -45,6 +46,7 @@ module Soundcloud9000
|
|
|
45
46
|
|
|
46
47
|
def favorites_tracks
|
|
47
48
|
return [] if @client.current_user.nil?
|
|
49
|
+
|
|
48
50
|
@client.get(@client.current_user.uri + '/favorites', offset: @limit * @page, limit: @limit)
|
|
49
51
|
end
|
|
50
52
|
|
|
@@ -54,6 +56,7 @@ module Soundcloud9000
|
|
|
54
56
|
|
|
55
57
|
def user_tracks
|
|
56
58
|
return [] if @client.current_user.nil?
|
|
59
|
+
|
|
57
60
|
user_tracks = @client.get(@client.current_user.uri + '/tracks', offset: @limit * @page, limit: @limit)
|
|
58
61
|
if user_tracks.empty?
|
|
59
62
|
UI::Input.error("'#{@client.current_user.username}' has not authored any tracks. Use f to switch to their favorites, or s to switch to their playlists.")
|
|
@@ -65,6 +68,7 @@ module Soundcloud9000
|
|
|
65
68
|
|
|
66
69
|
def playlist_tracks
|
|
67
70
|
return [] if @playlist.nil?
|
|
71
|
+
|
|
68
72
|
@client.get(@playlist.uri + '/tracks', offset: @limit * @page, limit: @limit)
|
|
69
73
|
end
|
|
70
74
|
end
|
|
@@ -6,29 +6,29 @@ module Soundcloud9000
|
|
|
6
6
|
class Color
|
|
7
7
|
PAIRS = {
|
|
8
8
|
white: 0,
|
|
9
|
-
red:
|
|
10
|
-
blue:
|
|
9
|
+
red: 1,
|
|
10
|
+
blue: 2,
|
|
11
11
|
green: 3,
|
|
12
|
-
cyan:
|
|
13
|
-
}
|
|
12
|
+
cyan: 4
|
|
13
|
+
}.freeze
|
|
14
14
|
|
|
15
15
|
DEFINITION = {
|
|
16
16
|
PAIRS[:white] => [Curses::COLOR_WHITE, Curses::COLOR_BLACK],
|
|
17
|
-
PAIRS[:red]
|
|
18
|
-
PAIRS[:blue]
|
|
17
|
+
PAIRS[:red] => [Curses::COLOR_RED, Curses::COLOR_BLACK],
|
|
18
|
+
PAIRS[:blue] => [Curses::COLOR_BLUE, Curses::COLOR_WHITE],
|
|
19
19
|
PAIRS[:green] => [Curses::COLOR_GREEN, Curses::COLOR_BLACK],
|
|
20
|
-
PAIRS[:cyan]
|
|
21
|
-
}
|
|
20
|
+
PAIRS[:cyan] => [Curses::COLOR_BLACK, Curses::COLOR_CYAN]
|
|
21
|
+
}.freeze
|
|
22
22
|
|
|
23
23
|
COLORS = {
|
|
24
24
|
white: Curses.color_pair(PAIRS[:white]),
|
|
25
25
|
black: Curses.color_pair(PAIRS[:white]) | Curses::A_REVERSE,
|
|
26
|
-
red:
|
|
27
|
-
blue:
|
|
26
|
+
red: Curses.color_pair(PAIRS[:red]),
|
|
27
|
+
blue: Curses.color_pair(PAIRS[:blue]),
|
|
28
28
|
green: Curses.color_pair(PAIRS[:green]),
|
|
29
29
|
green_reverse: Curses.color_pair(PAIRS[:green]) | Curses::A_REVERSE,
|
|
30
|
-
cyan:
|
|
31
|
-
}
|
|
30
|
+
cyan: Curses.color_pair(PAIRS[:cyan])
|
|
31
|
+
}.freeze
|
|
32
32
|
|
|
33
33
|
def self.init
|
|
34
34
|
Curses.start_color
|
|
@@ -6,29 +6,30 @@ module Soundcloud9000
|
|
|
6
6
|
# handles getting input from the user
|
|
7
7
|
class Input
|
|
8
8
|
MAPPING = {
|
|
9
|
-
Curses::KEY_LEFT
|
|
10
|
-
Curses::KEY_RIGHT
|
|
11
|
-
Curses::KEY_DOWN
|
|
12
|
-
Curses::KEY_UP
|
|
9
|
+
Curses::KEY_LEFT => :left,
|
|
10
|
+
Curses::KEY_RIGHT => :right,
|
|
11
|
+
Curses::KEY_DOWN => :down,
|
|
12
|
+
Curses::KEY_UP => :up,
|
|
13
13
|
Curses::KEY_CTRL_J => :enter,
|
|
14
|
-
Curses::KEY_ENTER
|
|
15
|
-
' '
|
|
16
|
-
'j'
|
|
17
|
-
'k'
|
|
18
|
-
's'
|
|
19
|
-
'u'
|
|
20
|
-
'1'
|
|
21
|
-
'2'
|
|
22
|
-
'3'
|
|
23
|
-
'4'
|
|
24
|
-
'5'
|
|
25
|
-
'6'
|
|
26
|
-
'7'
|
|
27
|
-
'8'
|
|
28
|
-
'9'
|
|
29
|
-
'f'
|
|
30
|
-
'm'
|
|
31
|
-
|
|
14
|
+
Curses::KEY_ENTER => :enter,
|
|
15
|
+
' ' => :space,
|
|
16
|
+
'j' => :j,
|
|
17
|
+
'k' => :k,
|
|
18
|
+
's' => :s,
|
|
19
|
+
'u' => :u,
|
|
20
|
+
'1' => :one,
|
|
21
|
+
'2' => :two,
|
|
22
|
+
'3' => :three,
|
|
23
|
+
'4' => :four,
|
|
24
|
+
'5' => :five,
|
|
25
|
+
'6' => :six,
|
|
26
|
+
'7' => :seven,
|
|
27
|
+
'8' => :eight,
|
|
28
|
+
'9' => :nine,
|
|
29
|
+
'f' => :f,
|
|
30
|
+
'm' => :m,
|
|
31
|
+
'h' => :h
|
|
32
|
+
}.freeze
|
|
32
33
|
|
|
33
34
|
def self.get(delay = 0)
|
|
34
35
|
Curses.timeout = delay
|
|
@@ -4,7 +4,7 @@ module Soundcloud9000
|
|
|
4
4
|
module UI
|
|
5
5
|
# responsible for drawing our table of tracks
|
|
6
6
|
class Table < View
|
|
7
|
-
SEPARATOR = ' | '
|
|
7
|
+
SEPARATOR = ' | '.freeze
|
|
8
8
|
|
|
9
9
|
attr_reader :current, :collection
|
|
10
10
|
attr_accessor :header, :keys
|
|
@@ -22,7 +22,7 @@ module Soundcloud9000
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def bind_to(collection)
|
|
25
|
-
|
|
25
|
+
raise ArgumentError if @collection
|
|
26
26
|
|
|
27
27
|
@collection = collection
|
|
28
28
|
@collection.events.on(:append) { render }
|
|
@@ -91,7 +91,8 @@ module Soundcloud9000
|
|
|
91
91
|
@sizes = []
|
|
92
92
|
(rows + [header]).each do |row|
|
|
93
93
|
row.each_with_index do |value, index|
|
|
94
|
-
current
|
|
94
|
+
current = value.to_s.length
|
|
95
|
+
max = @sizes[index] || 0
|
|
95
96
|
@sizes[index] = current if max < current
|
|
96
97
|
end
|
|
97
98
|
end
|
|
@@ -6,14 +6,15 @@ module Soundcloud9000
|
|
|
6
6
|
module UI
|
|
7
7
|
# class responsible for helping keep our app tidy and populated
|
|
8
8
|
class View
|
|
9
|
-
ROW_SEPARATOR =
|
|
10
|
-
LINE_SEPARATOR =
|
|
11
|
-
INTERSECTION =
|
|
9
|
+
ROW_SEPARATOR = '|'.freeze
|
|
10
|
+
LINE_SEPARATOR = '-'.freeze
|
|
11
|
+
INTERSECTION = '+'.freeze
|
|
12
12
|
|
|
13
13
|
attr_reader :rect
|
|
14
14
|
|
|
15
15
|
def initialize(rect)
|
|
16
16
|
@rect = rect
|
|
17
|
+
# use Pad instead of Window?
|
|
17
18
|
@window = Curses::Window.new(rect.height, rect.width, rect.y, rect.x)
|
|
18
19
|
@line = 0
|
|
19
20
|
@padding = 0
|
|
@@ -62,11 +63,10 @@ module Soundcloud9000
|
|
|
62
63
|
@window.refresh
|
|
63
64
|
end
|
|
64
65
|
|
|
65
|
-
def perform_layout
|
|
66
|
-
end
|
|
66
|
+
def perform_layout; end
|
|
67
67
|
|
|
68
68
|
def draw
|
|
69
|
-
|
|
69
|
+
raise NotImplementedError
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|
|
@@ -23,7 +23,6 @@ module Soundcloud9000
|
|
|
23
23
|
|
|
24
24
|
def draw
|
|
25
25
|
line progress + download_progress
|
|
26
|
-
# p @tracks
|
|
27
26
|
with_color(:green) do
|
|
28
27
|
line((duration + ' - ' + status).ljust(16) + @player.title)
|
|
29
28
|
end
|
|
@@ -32,7 +31,7 @@ module Soundcloud9000
|
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def status
|
|
35
|
-
(@player.playing? ? 'playing' : 'paused')
|
|
34
|
+
(@player.playing? ? 'playing' : 'paused')
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
def progress
|
|
@@ -6,8 +6,8 @@ module Soundcloud9000
|
|
|
6
6
|
class TracksTable < UI::Table
|
|
7
7
|
def initialize(*args)
|
|
8
8
|
super
|
|
9
|
-
self.header = %w
|
|
10
|
-
self.keys = [
|
|
9
|
+
self.header = %w[Title User Length Plays Likes Comments]
|
|
10
|
+
self.keys = %i[title username length plays likes comments]
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
data/lib/soundcloud9000.rb
CHANGED
|
@@ -5,10 +5,21 @@ module Soundcloud9000
|
|
|
5
5
|
|
|
6
6
|
def self.start
|
|
7
7
|
unless client_id = ENV['SC_CLIENT_ID']
|
|
8
|
-
puts
|
|
8
|
+
puts 'You need to set SC_CLIENT_ID to a valid client ID'
|
|
9
9
|
exit 1
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
if ARGV.include?('-v') || ARGV.include?('--version')
|
|
13
|
+
puts Application.get_version
|
|
14
|
+
puts "Copyright (C) #{Time.new.year} Sumanth Ratna"
|
|
15
|
+
exit 0
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
if ARGV.include?('-h') || ARGV.include?('--help')
|
|
19
|
+
puts Application.get_help
|
|
20
|
+
exit 0
|
|
21
|
+
end
|
|
22
|
+
|
|
12
23
|
client = Client.new(client_id)
|
|
13
24
|
application = Application.new(client)
|
|
14
25
|
|
|
@@ -18,5 +29,4 @@ module Soundcloud9000
|
|
|
18
29
|
|
|
19
30
|
application.run
|
|
20
31
|
end
|
|
21
|
-
|
|
22
32
|
end
|
data/soundcloud9000.gemspec
CHANGED
|
@@ -2,10 +2,16 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = "soundcloud9000"
|
|
5
|
-
s.version = "0.1.
|
|
5
|
+
s.version = "0.1.2"
|
|
6
6
|
s.authors = ["Tobias Schmidt", "Matthias Georgi", "Sumanth Ratna"]
|
|
7
7
|
s.email = "sratna@sumanthratna.gq"
|
|
8
8
|
s.homepage = "http://www.github.com/sumanthratna/soundcloud9000"
|
|
9
|
+
s.metadata = {
|
|
10
|
+
"source_code_uri" => "http://www.github.com/sumanthratna/soundcloud9000",
|
|
11
|
+
"bug_tracker_uri" => "http://www.github.com/sumanthratna/soundcloud9000/issues"
|
|
12
|
+
}
|
|
13
|
+
s.requirements << "PortAudio"
|
|
14
|
+
s.requirements << "mpg123"
|
|
9
15
|
s.summary = "SoundCloud without the stupid CSS files"
|
|
10
16
|
s.description = "The next generation SoundCloud client"
|
|
11
17
|
s.license = 'MIT'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: soundcloud9000
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Schmidt
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2019-
|
|
13
|
+
date: 2019-05-25 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: json
|
|
@@ -105,6 +105,7 @@ extra_rdoc_files:
|
|
|
105
105
|
- README.md
|
|
106
106
|
files:
|
|
107
107
|
- ".gitignore"
|
|
108
|
+
- ".travis.yml"
|
|
108
109
|
- Gemfile
|
|
109
110
|
- LICENSE
|
|
110
111
|
- README.md
|
|
@@ -141,7 +142,9 @@ files:
|
|
|
141
142
|
homepage: http://www.github.com/sumanthratna/soundcloud9000
|
|
142
143
|
licenses:
|
|
143
144
|
- MIT
|
|
144
|
-
metadata:
|
|
145
|
+
metadata:
|
|
146
|
+
source_code_uri: http://www.github.com/sumanthratna/soundcloud9000
|
|
147
|
+
bug_tracker_uri: http://www.github.com/sumanthratna/soundcloud9000/issues
|
|
145
148
|
post_install_message:
|
|
146
149
|
rdoc_options: []
|
|
147
150
|
require_paths:
|
|
@@ -156,7 +159,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
156
159
|
- - ">="
|
|
157
160
|
- !ruby/object:Gem::Version
|
|
158
161
|
version: '0'
|
|
159
|
-
requirements:
|
|
162
|
+
requirements:
|
|
163
|
+
- PortAudio
|
|
164
|
+
- mpg123
|
|
160
165
|
rubyforge_project:
|
|
161
166
|
rubygems_version: 2.5.2.3
|
|
162
167
|
signing_key:
|