rubio-radio 0.0.1 → 0.0.4
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/CHANGELOG.md +27 -0
- data/LICENSE.txt +1 -1
- data/README.md +99 -6
- data/TODO.md +3 -0
- data/exe/rubio +33 -13
- data/lib/rubio/player.rb +5 -5
- data/lib/rubio/radio.rb +109 -53
- data/lib/rubio/station.rb +6 -7
- data/lib/rubio/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfd627d6056a51e35b6ba16a55f6e87ad2e05820ffe16172862c2df5222242b7
|
4
|
+
data.tar.gz: 0bbdcb38795e7a55e00a0699bc0a30e5e2f53ed6b0a0defcaf43d81b0ea641c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d6682d2602e24709eabcf65f1110acaf04b6f543e516775f6b9b29661e1c886fbf3c3d647a7e33cba78b159a044aa42a823de0e1046b1cf37b749b778e98907
|
7
|
+
data.tar.gz: d5c4ae797ab9d3985fdeb56c135738f545226dcb0eb5ca199624a17d72a645f4ee4abfbdb0687492099edfa75137527e658d78f2df0414e737e55b5969304ea5
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.0.4
|
4
|
+
|
5
|
+
- Upgrade to glimmer-dsl-libui v0.5.18
|
6
|
+
- Replace `table` with new `refined_table` having pagination and filtering support across all columns (including language column)
|
7
|
+
- Request the top 10,000 radio stations upon starting the app
|
8
|
+
- Command option `--count` for configuring count of top radio stations (`10_000` by default)
|
9
|
+
- Command option `--per-page` for number of rows per page to display
|
10
|
+
- Command option `--page-count` for displaying page count ("of PAGE_COUNT pages")
|
11
|
+
- Command option `--width` for initial window width
|
12
|
+
- Command option `--height` for initial window height
|
13
|
+
- Command option `--no-menu` to remove the top menu bar and save screen space when not needed (on Mac it is always on because the menu bar does not take application screen space)
|
14
|
+
- Help menu About menu item to display message box with application license
|
15
|
+
- If `--per-page` is specified and `--height` is not specified, attempt to calculate intial window height for each platform automatically based on number of rows per page
|
16
|
+
|
17
|
+
## 0.0.3
|
18
|
+
|
19
|
+
- Fix bug
|
20
|
+
|
21
|
+
## 0.0.2
|
22
|
+
|
23
|
+
- Support Mac and Windows
|
24
|
+
|
25
|
+
## 0.0.1
|
26
|
+
|
27
|
+
- Initial implementation of rubio-radio
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,27 +1,120 @@
|
|
1
|
-
#
|
1
|
+
# rubio-radio
|
2
|
+
[](https://badge.fury.io/rb/rubio-radio)
|
2
3
|
|
3
|
-
|
4
|
+
Linux
|
5
|
+
|
6
|
+

|
7
|
+
|
8
|
+
Mac
|
9
|
+
|
10
|
+

|
11
|
+
|
12
|
+
Windows
|
13
|
+
|
14
|
+

|
4
15
|
|
5
16
|
:bowtie: Alpha
|
6
|
-
## installation
|
7
17
|
|
8
|
-
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
### Requirements:
|
21
|
+
|
22
|
+
**[VLC](https://github.com/videolan/vlc)**
|
23
|
+
|
24
|
+
`rubio` uses the `vlc -I dummy` as the audio playback backend.
|
25
|
+
|
26
|
+
On Mac, it is recommended that you install VLC via [Homebrew](https://brew.sh/) to ensure the `vlc` command is added to the PATH environment variable automatically:
|
27
|
+
|
28
|
+
```
|
29
|
+
brew install vlc
|
30
|
+
```
|
31
|
+
|
32
|
+
On Windows, install VLC using the [Windows installer](https://www.videolan.org/vlc/download-windows.html), and then add the installed VLC app directory to the PATH environment variable (e.g. `C:\Program Files (x86)\VideoLAN\VLC`) to make the `vlc` command available.
|
33
|
+
|
34
|
+
### Ruby Gem:
|
9
35
|
|
10
36
|
```
|
11
37
|
gem install rubio-radio
|
12
38
|
```
|
39
|
+
|
13
40
|
## Usage
|
14
41
|
|
42
|
+
Run with this command:
|
43
|
+
|
15
44
|
```
|
16
45
|
rubio
|
17
46
|
```
|
18
47
|
|
19
|
-
|
48
|
+
The top 10,000 [Radio Browser](https://www.radio-browser.info/) stations are displayed by default. But, you can customize the count (note that currently, there are only about 32,000 [Radio Browser](https://www.radio-browser.info/) stations total).
|
49
|
+
|
50
|
+
```
|
51
|
+
rubio --count 20000
|
52
|
+
```
|
53
|
+
|
54
|
+
Default player is `vlc -I dummy`. But, you can use any command line player that can take URL of radio station as its first argument.
|
20
55
|
|
21
56
|
```
|
22
57
|
rubio --backend mpg123
|
23
58
|
```
|
24
59
|
|
60
|
+
Learn more about `rubio` options:
|
61
|
+
|
62
|
+
```
|
63
|
+
rubio --help
|
64
|
+
```
|
65
|
+
|
66
|
+
```
|
67
|
+
Usage: rubio [options]
|
68
|
+
--vlc [STR] use VLC interface STR on the backend [dummy]
|
69
|
+
--mpg123 use mpg123 on the backend
|
70
|
+
-b, --backend STR command to use as backend player ['vlc -I dummy']
|
71
|
+
-c, --count INT number of stations to fetch from radio-browser [10000]
|
72
|
+
--per-page INT number of stations per page [20]
|
73
|
+
--[no-]page-count show/hide page count
|
74
|
+
-w, --width INT main window width
|
75
|
+
-h, --height INT main window height
|
76
|
+
--[no-]menu show/hide menu
|
77
|
+
--debug output status of monitored threads
|
78
|
+
--help show this help message
|
79
|
+
--version show the rubio version number
|
80
|
+
```
|
81
|
+
|
82
|
+
Examples:
|
83
|
+
|
84
|
+
```
|
85
|
+
rubio --vlc # `vlc -I rc` (interactive command line interface)
|
86
|
+
rubio --mpg123 # `rubio --backend mpg123`
|
87
|
+
rubio --count 1000 # Displays the top 1,000 Radio Browser stations
|
88
|
+
```
|
89
|
+
|
90
|
+
Small Screen Example:
|
91
|
+
|
92
|
+
```
|
93
|
+
rubio --per-page 6 --no-menu
|
94
|
+
```
|
95
|
+
|
96
|
+

|
97
|
+
|
98
|
+
Page Count Example:
|
99
|
+
|
100
|
+
```
|
101
|
+
rubio --page-count
|
102
|
+
```
|
103
|
+
|
104
|
+

|
105
|
+
|
106
|
+
## Links
|
107
|
+
|
108
|
+
* [Ruby](https://github.com/ruby/ruby)
|
109
|
+
* spawn
|
110
|
+
* [Radio Browser](https://www.radio-browser.info/)
|
111
|
+
* [Radio Browser API](https://de1.api.radio-browser.info/)
|
112
|
+
* [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui)
|
113
|
+
|
114
|
+
## Change Log
|
115
|
+
|
116
|
+
[CHANGELOG.md](CHANGELOG.md)
|
117
|
+
|
25
118
|
## LICENSE
|
26
119
|
|
27
|
-
MIT
|
120
|
+
[MIT](LICENSE.txt)
|
data/TODO.md
ADDED
data/exe/rubio
CHANGED
@@ -2,29 +2,49 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'rubio'
|
5
|
-
|
6
5
|
require 'optparse'
|
7
|
-
|
8
|
-
|
6
|
+
|
7
|
+
options = { backend: 'vlc -I dummy' }
|
8
|
+
|
9
9
|
opt = OptionParser.new
|
10
|
-
opt.
|
11
|
-
opt.on('--
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
opt.summary_width = 23
|
11
|
+
opt.on('--vlc [STR]', 'use VLC interface STR on the backend [dummy]') do |i|
|
12
|
+
i ||= 'dummy'
|
13
|
+
options[:backend] = "vlc -I #{i}"
|
14
|
+
end
|
15
|
+
opt.on('--mpg123', 'use mpg123 on the backend') { options[:backend] = 'mpg123' }
|
16
|
+
opt.on('-b', '--backend STR', String, 'command to use as backend player [\'vlc -I dummy\']') do |b|
|
17
|
+
options[:backend] = b
|
18
|
+
end
|
19
|
+
opt.on('-c', '--count INT', Numeric, 'number of stations to fetch from radio-browser [10000]') do |c|
|
20
|
+
options[:radio_station_count] = c
|
21
|
+
end
|
22
|
+
opt.on('--per-page INT', Numeric, 'number of stations per page [20]') { |c| options[:table_per_page] = c }
|
23
|
+
opt.on('--[no-]page-count', TrueClass, 'show/hide page count') { |b| options[:show_page_count] = b }
|
24
|
+
opt.on('-w', '--width INT', Numeric, 'main window width') { |w| options[:initial_width] = w }
|
25
|
+
opt.on('-h', '--height INT', Numeric, 'main window height') { |h| options[:initial_height] = h }
|
26
|
+
opt.on('--[no-]menu', TrueClass, 'show/hide menu') { |b| options[:visible_menu] = b }
|
27
|
+
opt.on('--debug', 'output status of monitored threads') { options[:debug] = true }
|
28
|
+
opt.on('--help', 'show this help message') do
|
15
29
|
puts opt
|
16
30
|
exit
|
17
31
|
end
|
18
|
-
opt.on('--version') do
|
32
|
+
opt.on('--version', 'show the rubio version number') do
|
19
33
|
puts Rubio::VERSION
|
20
34
|
exit
|
21
35
|
end
|
22
|
-
opt.parse!(ARGV)
|
23
36
|
|
24
|
-
radio = Rubio::Radio.new(backend, debug: debug)
|
25
37
|
begin
|
26
|
-
|
38
|
+
opt.parse!(ARGV)
|
39
|
+
rescue OptionParser::InvalidOption, OptionParser::AmbiguousOption => e
|
40
|
+
puts e.message
|
41
|
+
puts opt
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
|
45
|
+
begin
|
46
|
+
Rubio::Radio.launch(**options)
|
27
47
|
rescue StandardError => e
|
28
|
-
|
48
|
+
Rubio::Radio.launched_application&.player&.stop_all
|
29
49
|
raise e
|
30
50
|
end
|
data/lib/rubio/player.rb
CHANGED
@@ -4,7 +4,7 @@ module Rubio
|
|
4
4
|
class Player
|
5
5
|
attr_accessor :backend, :pid, :thr, :status, :history
|
6
6
|
|
7
|
-
def initialize(backend = 'cvlc')
|
7
|
+
def initialize(backend = OS.linux? ? 'cvlc' : 'vlc -I rc')
|
8
8
|
raise unless backend.is_a?(String)
|
9
9
|
|
10
10
|
@backend = backend
|
@@ -25,11 +25,11 @@ module Rubio
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def play(url)
|
28
|
-
#
|
28
|
+
# Do not include spaces in the command line
|
29
29
|
# if a space exist :
|
30
30
|
# * sh -c command url # this process with @pid will be killed
|
31
31
|
# * cmmand url # will not be killd because pid is differennt
|
32
|
-
# if no space :
|
32
|
+
# if no space :
|
33
33
|
# * cmmand url # will be killed by @pid
|
34
34
|
raise if url.match(/\s/)
|
35
35
|
|
@@ -42,7 +42,7 @@ module Rubio
|
|
42
42
|
def stop
|
43
43
|
return unless alive?
|
44
44
|
|
45
|
-
r = Process.kill(:TERM, pid)
|
45
|
+
r = Process.kill(OS.windows? ? :KILL : :TERM, pid)
|
46
46
|
@thr = nil
|
47
47
|
@pid = nil
|
48
48
|
r
|
@@ -50,7 +50,7 @@ module Rubio
|
|
50
50
|
|
51
51
|
def stop_all
|
52
52
|
@history.each do |pid, thr|
|
53
|
-
Process.kill(:TERM, pid) if thr.alive?
|
53
|
+
Process.kill(OS.windows? ? :KILL : :TERM, pid) if thr.alive?
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/rubio/radio.rb
CHANGED
@@ -4,40 +4,109 @@ require 'glimmer-dsl-libui'
|
|
4
4
|
|
5
5
|
module Rubio
|
6
6
|
class Radio
|
7
|
-
include Glimmer
|
7
|
+
include Glimmer::LibUI::Application
|
8
|
+
|
9
|
+
options :backend, :initial_width, :initial_height
|
10
|
+
option :radio_station_count, default: 10_000
|
11
|
+
option :debug, default: false
|
12
|
+
option :visible_menu, default: true
|
13
|
+
option :show_page_count, default: false
|
14
|
+
option :table_per_page, default: 20
|
8
15
|
|
9
16
|
attr_reader :stations, :player
|
10
17
|
|
11
|
-
|
12
|
-
@stations_all, @table = RadioBrowser.topvote(
|
18
|
+
before_body do
|
19
|
+
@stations_all, @table = RadioBrowser.topvote(radio_station_count)
|
13
20
|
@stations = @stations_all.dup
|
14
21
|
@station_uuid = nil
|
15
22
|
@player = Player.new(backend)
|
23
|
+
@initial_width = (initial_width || 400).to_i
|
24
|
+
@initial_height = (initial_height || calculate_initial_height).to_i
|
16
25
|
|
17
26
|
monitor_thread(debug)
|
18
27
|
end
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
p @player.history if debug
|
23
|
-
next if @station_uuid.nil? || @player.alive?
|
29
|
+
body do
|
30
|
+
radio_menu_bar
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
window('Rubio', @initial_width, @initial_height) do
|
33
|
+
vertical_box do
|
34
|
+
horizontal_box do
|
35
|
+
@station_table = refined_table(
|
36
|
+
table_columns: {
|
37
|
+
'Play' => { button: {
|
38
|
+
on_clicked: lambda { |row|
|
39
|
+
station = @station_table.paginated_model_array[row]
|
40
|
+
select_station(station)
|
41
|
+
}
|
42
|
+
} },
|
43
|
+
'name' => :text,
|
44
|
+
'language' => :text
|
45
|
+
},
|
46
|
+
model_array: stations,
|
47
|
+
per_page: table_per_page.to_i,
|
48
|
+
visible_page_count: show_page_count
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
on_closing do
|
54
|
+
@player.stop_all
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def radio_menu_bar
|
60
|
+
return unless OS.mac? || visible_menu
|
61
|
+
|
62
|
+
menu('Radio') do
|
63
|
+
menu_item('Stop') do
|
64
|
+
on_clicked do
|
65
|
+
stop_uuid(@station_uuid)
|
66
|
+
@station_uuid = nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if OS.mac?
|
71
|
+
about_menu_item do
|
72
|
+
on_clicked do
|
73
|
+
about_message_box
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
quit_menu_item do
|
79
|
+
on_clicked do
|
80
|
+
@player.stop_all
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
menu('Help') do
|
86
|
+
menu_item('About') do
|
87
|
+
on_clicked do
|
88
|
+
about_message_box
|
89
|
+
end
|
90
|
+
end
|
29
91
|
end
|
30
92
|
end
|
31
93
|
|
32
|
-
def
|
33
|
-
|
94
|
+
def about_message_box
|
95
|
+
license = begin
|
96
|
+
File.read(File.expand_path('../../LICENSE.txt', __dir__))
|
97
|
+
rescue StandardError
|
98
|
+
''
|
99
|
+
end
|
100
|
+
product = "rubio-radio #{Rubio::VERSION}"
|
101
|
+
message_box(product, "#{product}\n\n#{license}")
|
102
|
+
end
|
34
103
|
|
35
|
-
|
104
|
+
def select_station(station)
|
105
|
+
station_uuid = station.stationuuid
|
36
106
|
stop_uuid(@station_uuid)
|
37
107
|
if @station_uuid == station_uuid
|
38
108
|
@station_uuid = nil
|
39
|
-
|
40
|
-
play_uuid(station_uuid)
|
109
|
+
elsif play_uuid(station_uuid)
|
41
110
|
@station_uuid = station_uuid
|
42
111
|
end
|
43
112
|
end
|
@@ -48,7 +117,7 @@ module Rubio
|
|
48
117
|
@player.play(station.url)
|
49
118
|
rescue StandardError => e
|
50
119
|
message_box(e.message)
|
51
|
-
|
120
|
+
return false
|
52
121
|
end
|
53
122
|
station.playing = true
|
54
123
|
end
|
@@ -61,44 +130,31 @@ module Rubio
|
|
61
130
|
station.playing = false
|
62
131
|
end
|
63
132
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
row_data.name.downcase.include?(filter_value.downcase)
|
77
|
-
end)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
horizontal_box do
|
83
|
-
table do
|
84
|
-
button_column('Play') do
|
85
|
-
on_clicked do |row|
|
86
|
-
selected_station_at(row)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
text_column('name')
|
90
|
-
text_column('language')
|
91
|
-
cell_rows <= [self, :stations]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
on_closing do
|
96
|
-
@player.stop_all
|
97
|
-
end
|
98
|
-
end.show
|
133
|
+
private
|
134
|
+
|
135
|
+
def calculate_initial_height
|
136
|
+
if OS.linux?
|
137
|
+
107 + (visible_menu ? 26 : 0) + 24 * table_per_page.to_i
|
138
|
+
elsif OS.mac? && OS.host_cpu == 'arm64'
|
139
|
+
90 + 24 * table_per_page.to_i
|
140
|
+
elsif OS.mac?
|
141
|
+
85 + 19 * table_per_page.to_i
|
142
|
+
else # Windows
|
143
|
+
95 + 19 * table_per_page.to_i
|
144
|
+
end
|
99
145
|
end
|
100
146
|
|
101
|
-
|
147
|
+
def monitor_thread(debug)
|
148
|
+
Glimmer::LibUI.timer(1) do
|
149
|
+
p @player.history if debug
|
150
|
+
next if @station_uuid.nil? || @player.alive?
|
151
|
+
|
152
|
+
message_box("player '#{@player.backend}' stopped!", @player.thr.to_s)
|
153
|
+
stop_uuid(@station_uuid)
|
154
|
+
@station_uuid = nil
|
155
|
+
true
|
156
|
+
end
|
157
|
+
end
|
102
158
|
|
103
159
|
def uuid_to_station(uuid)
|
104
160
|
idx = @table[uuid]
|
data/lib/rubio/station.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Rubio
|
4
|
-
|
5
|
-
|
6
|
-
class Station < BaseStation
|
7
|
-
attr_accessor :playing
|
4
|
+
Station = Struct.new(:stationuuid, :name, :language, :url, :play) do
|
5
|
+
attr_reader :playing
|
8
6
|
|
9
7
|
def initialize(*args, **kwargs)
|
10
8
|
super(*args, **kwargs)
|
11
|
-
|
9
|
+
self.playing = false
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
15
|
-
|
12
|
+
def playing=(value)
|
13
|
+
self.play = value ? '■' : '▶'
|
14
|
+
@playing = value
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
data/lib/rubio/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubio-radio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
|
+
- Andy Maleh
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2022-
|
12
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: glimmer-dsl-libui
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- -
|
18
|
+
- - '='
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
+
version: 0.5.18
|
20
21
|
type: :runtime
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- -
|
25
|
+
- - '='
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
+
version: 0.5.18
|
27
28
|
description: Rubio is a simple radio player written in Ruby.
|
28
29
|
email:
|
29
30
|
- 2xijok@gmail.com
|
@@ -32,8 +33,10 @@ executables:
|
|
32
33
|
extensions: []
|
33
34
|
extra_rdoc_files: []
|
34
35
|
files:
|
36
|
+
- CHANGELOG.md
|
35
37
|
- LICENSE.txt
|
36
38
|
- README.md
|
39
|
+
- TODO.md
|
37
40
|
- exe/rubio
|
38
41
|
- lib/rubio.rb
|
39
42
|
- lib/rubio/player.rb
|