vlcraptor 0.4.0 → 0.5.0

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: 62d27be7a5541a19d3e2f69cf98ee1506b8b65560deffa547c9e621f860977b9
4
- data.tar.gz: af56137e7d23b949a5ba94453f9d3bb4e0c45020722b3d0456393b7c7bfed4b5
3
+ metadata.gz: e68bc937ca2016f17771ea0b7db19729f0b91eb3a7cd94e8dae305e5d5feff9b
4
+ data.tar.gz: 3197d9195b81187bf3109e99440c61c906e5007095da0466098a15ad8d3b5fed
5
5
  SHA512:
6
- metadata.gz: 03d0920671d6dfa40dd866c70a915fe7ac6c13a5d84dd0507cdaa6104d0fc2352b2d4b4ab6af10957b7b3ad078f673a2ceda91552134c0b32172186fcafcb75d
7
- data.tar.gz: 8519f300d25106c8138cf4921c03f2394191f28f853220203b09079d39d9f972cf40331f6e30a2a9f8549028014a9d1542f6c1b841fef9a1f772fffa1d86c910
6
+ metadata.gz: b64e6b465e12a323b47ef33cbc3132f0f3256cb7c87f2b56c514f70bb8254f901f8e4e581b5873d1d0d328fc5ddfa589a0c4c585e75ee45315356856fcab6d86
7
+ data.tar.gz: 7b32b59ca121f4e35a10cacf7766dcb5c6e76a1cf0f47f0522e91425d476645d24f415943b864aee295534f579285903ad53ab47ae0cfeeb60adeb50d659c637
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vlcraptor (0.4.0)
4
+ vlcraptor (0.5.0)
5
5
  curses
6
6
  rainbow
7
7
  vlc-client
@@ -17,11 +17,11 @@ module Vlcraptor
17
17
  end
18
18
 
19
19
  def next
20
- return on_pause if @preferences.pause?
21
- return on_stop if @preferences.stop?
22
- return on_play if @preferences.play?
23
- return on_suspended if @suspended
24
- return when_playing if @player.playing?
20
+ return on_play if @preferences.play? && @suspended
21
+ return on_pause if @preferences.pause? && !@suspended
22
+ return on_stop if @preferences.stop? && !@suspended
23
+ return build if @suspended
24
+ return when_playing if @track && @player.playing?
25
25
  return when_auto if @preferences.continue?
26
26
 
27
27
  when_manual
@@ -36,32 +36,24 @@ module Vlcraptor
36
36
  private
37
37
 
38
38
  def on_pause
39
- when_suspended("Now Paused", :pause)
39
+ suspend("Now Paused", :pause)
40
40
  end
41
41
 
42
42
  def on_stop
43
- when_suspended("Now Stopped", :stop)
43
+ suspend("Now Stopped", :stop)
44
44
  end
45
45
 
46
- def when_suspended(status, method)
47
- if @player.playing?
48
- @player.fadeout
49
- @player.send(method)
50
- end
46
+ def suspend(status, method)
47
+ @player.fadeout
48
+ @player.send(method)
51
49
  @status = status
52
50
  @suspended = true
53
51
  @notifiers.track_suspended
54
- on_suspended
55
- end
56
-
57
- def on_suspended
58
52
  build
59
53
  end
60
54
 
61
55
  def on_play
62
- unless @player.playing?
63
- @player.fadein
64
- end
56
+ @player.fadein
65
57
  @suspended = false
66
58
  @notifiers.track_resumed(@track, @player.time)
67
59
  when_playing_track(@player.remaining)
@@ -115,12 +107,17 @@ module Vlcraptor
115
107
  remaining_color = remaining < 30 ? 9 : 5
116
108
  build(
117
109
  [2, @track[:title]],
118
- [0, "by"],
110
+ [0, "\n"],
111
+ [0, "by "],
119
112
  [11, @track[:artist]],
120
- [0, "from"],
113
+ [0, "\n"],
114
+ [0, "from "],
121
115
  [6, @track[:album]],
122
- [0, "(#{duration(@track[:length])})"],
123
- [remaining_color, "#{duration(remaining)} remaining"],
116
+ [0, "\n"],
117
+ [remaining_color, duration(remaining)],
118
+ [0, " of "],
119
+ [0, duration(@track[:length])],
120
+ [0, " remaining\n"],
124
121
  )
125
122
  end
126
123
 
@@ -152,9 +149,13 @@ module Vlcraptor
152
149
  scrobble = @preferences[:scrobble] ? "+" : "-"
153
150
  [
154
151
  [0, display_time(Time.now)],
152
+ [0, "\n"],
155
153
  [0, @status],
156
- [0, "#{Vlcraptor::Queue.length} items in queue"],
154
+ [0, "\n"],
155
+ [0, "#{Vlcraptor::Queue.length} queued tracks"],
156
+ [0, "\n"],
157
157
  [8, "#{autoplay}autoplay #{crossfade}crossfade #{scrobble}scrobble"],
158
+ [0, "\n"],
158
159
  ] + extra
159
160
  end
160
161
  end
@@ -65,15 +65,20 @@ module Vlcraptor
65
65
 
66
66
  puts "adding #{path}"
67
67
  tags = Vlcraptor::Ffmpeg.new(path)
68
- meta = {
68
+ enqueue(
69
69
  title: tags.title,
70
70
  artist: tags.artist,
71
71
  album: tags.album,
72
72
  length: tags.time,
73
- path: File.expand_path(path),
74
- }
73
+ path: File.expand_path(path)
74
+ )
75
+ end
76
+
77
+ def self.enqueue(track)
75
78
  `mkdir -p /tmp/queue`
76
- File.open("/tmp/queue/#{(Time.now.to_f * 1000).to_i}.yml", "w") { |f| f.puts meta.to_yaml }
79
+ File.open("/tmp/queue/#{(Time.now.to_f * 1000).to_i}.yml", "w") do |file|
80
+ file.puts track.to_yaml
81
+ end
77
82
  end
78
83
  end
79
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vlcraptor
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/vlcraptor.rb CHANGED
@@ -23,7 +23,9 @@ module Vlcraptor
23
23
  end
24
24
 
25
25
  def self.history
26
- system("cat #{File.expand_path("~")}/.player_history")
26
+ history_path = "#{File.expand_path("~")}/.player_history"
27
+ `touch #{history_path}`
28
+ system("cat #{history_path}")
27
29
  end
28
30
 
29
31
  def self.list
@@ -78,7 +80,6 @@ module Vlcraptor
78
80
  player_controller.next.each do |pair|
79
81
  window.attron(Curses.color_pair(pair.first)) { window << pair.last }
80
82
  Curses.clrtoeol
81
- window << "\n"
82
83
  end
83
84
  (window.maxy - window.cury).times { window.deleteln }
84
85
  window.refresh
@@ -96,7 +97,7 @@ module Vlcraptor
96
97
  break
97
98
  end
98
99
 
99
- sleep 0.1
100
+ sleep 0.2
100
101
  end
101
102
  ensure
102
103
  player_controller.cleanup
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vlcraptor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Ryall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-19 00:00:00.000000000 Z
11
+ date: 2022-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses