ruby-ampache 0.0.9 → 0.0.10
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.
- data/README.rdoc +14 -2
- data/VERSION +1 -1
- data/bin/ruby-ampache +3 -2
- data/lib/lib-classes.rb +19 -9
- metadata +6 -22
data/README.rdoc
CHANGED
@@ -6,6 +6,16 @@ Ruby-ampache is a really simple command line player for the ampache music server
|
|
6
6
|
|
7
7
|
You need to have mplayer installed to use ruby-ampache. Mplayer is used for playing music streams.
|
8
8
|
|
9
|
+
The big issue within this design is that if mplayer hangs up waiting on your ampache server
|
10
|
+
you can enconter issues on adding songs to playlist and playing them
|
11
|
+
|
12
|
+
the simple fix right now is to
|
13
|
+
set TIMEOUT variable in your .ruby-ampache config file
|
14
|
+
tuning it depending on your ampache server delay
|
15
|
+
|
16
|
+
Yes, this should be handled different
|
17
|
+
I'm free to any kind of suggestion on how to refactor this simple piece of software :)
|
18
|
+
|
9
19
|
Gem can be installed as usual
|
10
20
|
|
11
21
|
gem install ruby-ampache
|
@@ -18,8 +28,10 @@ example file:
|
|
18
28
|
AMPACHE_USER="username"
|
19
29
|
AMPACHE_USER_PSW="userpsw"
|
20
30
|
|
21
|
-
|
22
|
-
|
31
|
+
#optional (default is /usr/bin/mplayer)
|
32
|
+
MPLAYER_PATH="/usr/bin/mplayer"
|
33
|
+
# try to increase this value if you experience issues like "err on reading data"
|
34
|
+
TIMEOUT=20 #20 is a good value for a remote host
|
23
35
|
|
24
36
|
Simply execute ruby-ampache that should be found in you $PATH after installation
|
25
37
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/bin/ruby-ampache
CHANGED
@@ -68,7 +68,7 @@ end
|
|
68
68
|
def print_artists(artists)
|
69
69
|
if artists.empty?
|
70
70
|
reset_token
|
71
|
-
say("
|
71
|
+
say("No results, retrying")
|
72
72
|
artists = @ar.artists
|
73
73
|
end
|
74
74
|
choose do |menu|
|
@@ -106,6 +106,7 @@ end
|
|
106
106
|
@ar =AmpacheRuby.new(ar_config.get_value('AMPACHE_HOST'),ar_config.get_value('AMPACHE_USER'), ar_config.get_value('AMPACHE_USER_PSW'))
|
107
107
|
$options = {}
|
108
108
|
$options[:path] = ar_config.get_value('MPLAYER_PATH')
|
109
|
+
$options[:timeout] = ar_config.get_value('TIMEOUT').to_i
|
109
110
|
@pl = AmpachePlaylist.new
|
110
111
|
|
111
112
|
while true
|
@@ -116,7 +117,7 @@ while true
|
|
116
117
|
menu.choice("add another album to playlist") { print_artists(@ar.artists); say(HighLine.new.color(@pl.nowPlaying, :red)) }
|
117
118
|
menu.choice("look for an artist") { print_artists(@ar.artists(ask("Artist name?"))); say(HighLine.new.color(@pl.nowPlaying, :red)) }
|
118
119
|
menu.choice("stop playing") { @pl.stop }
|
119
|
-
menu.choice("pause playing") { @pl.pause; say(HighLine.new.color("
|
120
|
+
menu.choice("pause playing") { @pl.pause; say(HighLine.new.color("pause toggle!",:red)) }
|
120
121
|
menu.choice("about ruby-ampache") { say(HighLine.new.color credits, :red) }
|
121
122
|
menu.choice("quit") { @pl.stop; exit}
|
122
123
|
end
|
data/lib/lib-classes.rb
CHANGED
@@ -61,24 +61,29 @@ end
|
|
61
61
|
|
62
62
|
class AmpachePlaylist
|
63
63
|
def add(song)
|
64
|
+
puts song.title
|
64
65
|
if !@pid
|
65
66
|
$options[:path] ||= '/usr/bin/mplayer'
|
67
|
+
$options[:timeout] ||= 15
|
66
68
|
mplayer_options = "-slave -quiet"
|
67
69
|
mplayer = "#{$options[:path]} #{mplayer_options} \"#{song.url}\""
|
68
70
|
@pid,@stdin,@stdout,@stderr = Open4.popen4(mplayer)
|
69
71
|
begin
|
70
|
-
t = Timeout::timeout(
|
72
|
+
t = Timeout::timeout($options[:timeout]) do
|
71
73
|
until @stdout.gets.inspect =~ /playback/ do
|
74
|
+
# puts @stdout.gets.inspect
|
75
|
+
|
72
76
|
end
|
77
|
+
|
73
78
|
end
|
74
|
-
rescue Timeout::Error
|
79
|
+
rescue Timeout::Error
|
75
80
|
puts "err on reading data"
|
76
81
|
end
|
77
82
|
else
|
78
83
|
begin
|
79
84
|
@stdin.puts "loadfile \"#{song.url}\" 1"
|
80
85
|
rescue Errno::EPIPE
|
81
|
-
|
86
|
+
puts "error on adding song to playlist"
|
82
87
|
@pid = nil
|
83
88
|
add(song)
|
84
89
|
end
|
@@ -109,8 +114,8 @@ class AmpachePlaylist
|
|
109
114
|
def next
|
110
115
|
begin
|
111
116
|
@stdin.puts "pt_step 1 1" if @pid
|
112
|
-
rescue Errno::EPIPE
|
113
|
-
puts "playlist is over"
|
117
|
+
rescue Errno::EPIPE => e
|
118
|
+
puts "playlist is over on next"
|
114
119
|
@pid = nil
|
115
120
|
end
|
116
121
|
end
|
@@ -139,13 +144,14 @@ class AmpachePlaylist
|
|
139
144
|
return nowPlaying
|
140
145
|
end
|
141
146
|
end
|
142
|
-
rescue Errno::EPIPE
|
143
|
-
return "playlist is over"
|
147
|
+
rescue Errno::EPIPE => e
|
144
148
|
@pid = nil
|
149
|
+
return "playlist is over here" #, or you got an ERROR from mplayer: #{e.to_s}"
|
150
|
+
|
145
151
|
end
|
146
152
|
end
|
147
153
|
|
148
|
-
# I borrowed these two
|
154
|
+
# I borrowed these two methods from the author of mplayer-ruby!
|
149
155
|
# so my thanks to Artuh Chiu and his great gem mplayer-ruby
|
150
156
|
def get(value)
|
151
157
|
field = value.to_s
|
@@ -166,7 +172,11 @@ class AmpachePlaylist
|
|
166
172
|
response = @stdout.gets
|
167
173
|
#XXX escaping bad utf8 chars
|
168
174
|
ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
|
169
|
-
|
175
|
+
if response
|
176
|
+
response =ic.iconv(response + ' ')[0..-2]
|
177
|
+
else
|
178
|
+
response == ''
|
179
|
+
end
|
170
180
|
end
|
171
181
|
response.gsub("\e[A\r\e[K","")
|
172
182
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-ampache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 9
|
9
|
-
version: 0.0.9
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.10
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- ghedmat
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-02-22 00:00:00 +01:00
|
18
14
|
default_executable: ruby-ampache
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,8 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
24
|
version: "0"
|
31
25
|
type: :runtime
|
32
26
|
version_requirements: *id001
|
@@ -38,8 +32,6 @@ dependencies:
|
|
38
32
|
requirements:
|
39
33
|
- - ">="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
35
|
version: "0"
|
44
36
|
type: :runtime
|
45
37
|
version_requirements: *id002
|
@@ -51,8 +43,6 @@ dependencies:
|
|
51
43
|
requirements:
|
52
44
|
- - ">="
|
53
45
|
- !ruby/object:Gem::Version
|
54
|
-
segments:
|
55
|
-
- 0
|
56
46
|
version: "0"
|
57
47
|
type: :runtime
|
58
48
|
version_requirements: *id003
|
@@ -64,8 +54,6 @@ dependencies:
|
|
64
54
|
requirements:
|
65
55
|
- - ">="
|
66
56
|
- !ruby/object:Gem::Version
|
67
|
-
segments:
|
68
|
-
- 0
|
69
57
|
version: "0"
|
70
58
|
type: :runtime
|
71
59
|
version_requirements: *id004
|
@@ -93,8 +81,8 @@ homepage: http://github.com/ghedamat/ruby-ampache
|
|
93
81
|
licenses: []
|
94
82
|
|
95
83
|
post_install_message:
|
96
|
-
rdoc_options:
|
97
|
-
|
84
|
+
rdoc_options: []
|
85
|
+
|
98
86
|
require_paths:
|
99
87
|
- lib
|
100
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -102,21 +90,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
90
|
requirements:
|
103
91
|
- - ">="
|
104
92
|
- !ruby/object:Gem::Version
|
105
|
-
segments:
|
106
|
-
- 0
|
107
93
|
version: "0"
|
108
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
95
|
none: false
|
110
96
|
requirements:
|
111
97
|
- - ">="
|
112
98
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
99
|
version: "0"
|
116
100
|
requirements: []
|
117
101
|
|
118
102
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.5.0
|
120
104
|
signing_key:
|
121
105
|
specification_version: 3
|
122
106
|
summary: Ruby ampache command line client
|