rubio-radio 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76a2b9f65b8a23dc9b85e85c94815701339e14e3f7fda6d15fd49e2668e5efae
4
- data.tar.gz: fa6cb61dda6e988098619c91c4bb32e0d764aaff9cd1b907cbe2207391ca3ced
3
+ metadata.gz: c84b293c3df7c60cb6c872ae7937795231e2342fce23e820e48d8fa5d735d64b
4
+ data.tar.gz: 3edbde25ee11784f71f798369458c71bd100c89cdb67120219507f127d95e968
5
5
  SHA512:
6
- metadata.gz: bc3eaa0c4894f9924d7acfa63e8d877b51c93096996f17351927dcd03b4c8cf2c5b0d02a014d8c8655df8b734be6bda824dd07c27b36766b3459e82b4e861bc9
7
- data.tar.gz: 2b044184d2978cbe1686c78a5453b01fc66530df583703bf20a390b86d4d35a5676749564cc3436a068e328f90239aef459d0c86e1362a626aa08561faf9c8c9
6
+ metadata.gz: 71c135dd2408f0ae936053509f9c23891aaaa3501599fb94bedcd167a1b3ca5a839db0f5e00b8a6a090ada073cae63e1487ef8ea909a4eaad70a88e3e0378e33
7
+ data.tar.gz: 399b6dd00ddfca35a3533384c43dce3a862d274c94c36228b4bf8e29f1624976b75d5dd73054ca63438f6119a33abf2a197f70819c79f95826acb882e4e49f73
data/README.md CHANGED
@@ -1,27 +1,49 @@
1
- # Rubio
1
+ # rubio-radio
2
+ [![Gem Version](https://badge.fury.io/rb/rubio-radio.svg)](https://badge.fury.io/rb/rubio-radio)
2
3
 
3
4
  ![img](https://user-images.githubusercontent.com/5798442/171986696-24bedc38-3811-4c62-a5ad-89c09d015c8a.png)
4
5
 
5
6
  :bowtie: Alpha
6
- ## installation
7
7
 
8
- Requirements : [cvlc](https://github.com/videolan/vlc)
8
+ ## Installation
9
+
10
+ ### Requirements:
11
+
12
+ **[VLC](https://github.com/videolan/vlc)**
13
+
14
+ `rubio` uses the `vlc -I dummy` as the audio playback backend.
15
+
16
+ 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:
17
+
18
+ ```
19
+ brew install vlc
20
+ ```
21
+
22
+ 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.
23
+
24
+ ### Ruby Gem:
9
25
 
10
26
  ```
11
27
  gem install rubio-radio
12
28
  ```
29
+
13
30
  ## Usage
14
31
 
15
32
  ```
16
33
  rubio
17
34
  ```
18
35
 
19
- Default player is `cvlc`. But you can use any command line player that can take URL of radio station as its first argument.
36
+ 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
37
 
21
38
  ```
22
39
  rubio --backend mpg123
23
40
  ```
24
41
 
42
+ ```
43
+ rubio --vlc # `vlc -I rc` (interactive command line interface)
44
+ rubio --mpg123 # `rubio --backend mpg123`
45
+ ```
46
+
25
47
  ## LICENSE
26
48
 
27
- MIT
49
+ MIT
data/exe/rubio CHANGED
@@ -4,10 +4,10 @@
4
4
  require 'rubio'
5
5
 
6
6
  require 'optparse'
7
- backend = 'cvlc'
7
+ backend = 'vlc -I dummy'
8
8
  debug = false
9
9
  opt = OptionParser.new
10
- opt.on('--vlc') { backend = 'cvlc' }
10
+ opt.on('--vlc') { backend = 'vlc -I rc' }
11
11
  opt.on('--mpg123') { backend = 'mpg123' }
12
12
  opt.on('--backend CMD') { |b| backend = b }
13
13
  opt.on('--debug') { debug = true }
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
- # do not include spaces in the command line
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 : command url
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
@@ -9,7 +9,7 @@ module Rubio
9
9
  attr_reader :stations, :player
10
10
 
11
11
  def initialize(backend, debug: false)
12
- @stations_all, @table = RadioBrowser.topvote(1000)
12
+ @stations_all, @table = RadioBrowser.topvote(500)
13
13
  @stations = @stations_all.dup
14
14
  @station_uuid = nil
15
15
  @player = Player.new(backend)
@@ -36,19 +36,18 @@ module Rubio
36
36
  stop_uuid(@station_uuid)
37
37
  if @station_uuid == station_uuid
38
38
  @station_uuid = nil
39
- else
40
- play_uuid(station_uuid)
39
+ elsif (station_uuid)
41
40
  @station_uuid = station_uuid
42
41
  end
43
42
  end
44
43
 
45
- def play_uuid(station_uuid)
44
+ def (station_uuid)
46
45
  station = uuid_to_station(station_uuid)
47
46
  begin
48
47
  @player.play(station.url)
49
48
  rescue StandardError => e
50
49
  message_box(e.message)
51
- raise e
50
+ return false
52
51
  end
53
52
  station.playing = true
54
53
  end
@@ -62,6 +61,19 @@ module Rubio
62
61
  end
63
62
 
64
63
  def launch
64
+ menu('Radio') do
65
+ menu_item('Stop') do
66
+ on_clicked do
67
+ stop_uuid(@station_uuid)
68
+ @station_uuid = nil
69
+ end
70
+ end
71
+ quit_menu_item do
72
+ on_clicked do
73
+ @player.stop_all
74
+ end
75
+ end
76
+ end
65
77
  window('Rubio', 400, 200) do
66
78
  vertical_box do
67
79
  horizontal_box do
data/lib/rubio/station.rb CHANGED
@@ -1,18 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubio
4
- BaseStation = Struct.new(:stationuuid, :name, :language, :url)
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
- @playing = false
9
+ self.playing = false
12
10
  end
13
11
 
14
- def play
15
- @playing ? '■' : '▶'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubio
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubio-radio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-04 00:00:00.000000000 Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer-dsl-libui