vkpd 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vkpd.rb +1 -0
- data/lib/vkpd/cli.rb +24 -19
- data/lib/vkpd/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f0172230df5bc278a55b6381daeba78174cddd6
|
4
|
+
data.tar.gz: e075f4be0f23dd55099f70df865ccefd535e8bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31cec65e08e73c75a11d304cd2712668e97a76f24be1df3f54c925128eef2449c67b7fe43deaffcdb768aa3584e905bd07484a811f06722a91a50184dfa1ae00
|
7
|
+
data.tar.gz: 2413965094bf9397bdad20c0117818b7de9ed2e4f64accc95aa20f5e4157920164753da07d95b6d7ffee4663a31a7fb1e5b92a45c09e22bcc63e930a21d6a9c3
|
data/lib/vkpd.rb
CHANGED
data/lib/vkpd/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module Vkpd
|
|
9
9
|
do_clear = true
|
10
10
|
do_play = true
|
11
11
|
params["auto_complete"] = '1'
|
12
|
-
player = ENV['VKPD_PLAYER']
|
12
|
+
player = ENV['VKPD_PLAYER'] || 'mpd'
|
13
13
|
random = false
|
14
14
|
|
15
15
|
if ARGV.empty?
|
@@ -29,7 +29,6 @@ module Vkpd
|
|
29
29
|
random = true
|
30
30
|
when '-p', '--player', /^--player=\w+$/
|
31
31
|
player = current.include?("=") ? current.match(/=(.*)/)[1] : ARGV.shift
|
32
|
-
player = player.to_sym
|
33
32
|
when '-c', '--count', /^--count=\d+$/
|
34
33
|
value = current.include?("=") ? current.match(/=(.*)/)[1] : ARGV.shift
|
35
34
|
params["count"] = value
|
@@ -80,29 +79,17 @@ module Vkpd
|
|
80
79
|
response = response.shuffle if random
|
81
80
|
|
82
81
|
case player
|
83
|
-
when
|
82
|
+
when 'mpd'
|
84
83
|
mpd.clear if do_clear
|
85
84
|
response.each do |song|
|
86
85
|
puts song if @verbose
|
87
86
|
mpd.add song["url"]
|
88
87
|
end
|
89
88
|
mpd.play if do_play
|
90
|
-
when
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
system "#{player} -cache 8192 -cache-min 2 #{song['url']}"
|
95
|
-
begin
|
96
|
-
Timeout::timeout 0.25 do
|
97
|
-
case key = STDIN.getch
|
98
|
-
when 'q' then throw :stop
|
99
|
-
end
|
100
|
-
end
|
101
|
-
rescue Timeout::Error
|
102
|
-
# do nothing
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
89
|
+
when 'mplayer', 'mpv'
|
90
|
+
with_playlist(response){|pls| system "#{player} -cache 8192 -cache-min 2 -playlist #{pls}" }
|
91
|
+
else # e.g. "vlc -I ncurses"
|
92
|
+
with_playlist(response){|pls| system "#{player} #{pls}" }
|
106
93
|
end
|
107
94
|
end
|
108
95
|
|
@@ -133,5 +120,23 @@ module Vkpd
|
|
133
120
|
data["response"]
|
134
121
|
end
|
135
122
|
|
123
|
+
def with_playlist(response)
|
124
|
+
file = Tempfile.new(['vkpd','.pls'])
|
125
|
+
write_playlist(file, response)
|
126
|
+
file.close
|
127
|
+
yield file.path
|
128
|
+
ensure
|
129
|
+
file.unlink
|
130
|
+
end
|
131
|
+
|
132
|
+
def write_playlist(f, response)
|
133
|
+
f.puts '[playlist]'
|
134
|
+
f.puts "NumberOfEntries=#{response.size}"
|
135
|
+
response.each_with_index do |song,i|
|
136
|
+
f.puts "File#{i+1}=#{song['url']}"
|
137
|
+
f.puts "Title#{i+1}=#{song['artist']} - #{song['title']}"
|
138
|
+
f.puts "Length#{i+1}=#{song['duration']}"
|
139
|
+
end
|
140
|
+
end
|
136
141
|
end
|
137
142
|
end
|
data/lib/vkpd/version.rb
CHANGED