paradiso 0.3.1 → 0.4.0
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 +20 -1
- data/VERSION +1 -1
- data/lib/paradiso/base.rb +28 -11
- data/lib/paradiso/playlist.rb +28 -16
- data/lib/paradiso.rb +4 -0
- data/paradiso.gemspec +2 -2
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -20,6 +20,12 @@ To play a playlist and remove the items that has been already played
|
|
20
20
|
|
21
21
|
paradiso -pd playlist
|
22
22
|
|
23
|
+
== RAR-archives
|
24
|
+
|
25
|
+
It's possible to stream rar-archives, it works exactly like other parameters, but will remove "duplicates", i.e. if there's a filename.rar, filename.r00 and filename.r01 then we'll just keep the first occurrence.
|
26
|
+
|
27
|
+
Note: There seems to be a problem with the unrar installed from the package manager port[http://www.macports.org/] for Mac OS X, but everything seems to work fine for the version installed through homebrew[http://github.com/mxcl/homebrew].
|
28
|
+
|
23
29
|
== Config file
|
24
30
|
|
25
31
|
Paradiso has some basic support for a config file
|
@@ -30,10 +36,23 @@ Sample config file, in YAML
|
|
30
36
|
|
31
37
|
fullscreen : true
|
32
38
|
aspectratio : "16:10"
|
39
|
+
|
40
|
+
It's also possible to tell where mplayer is located or specify another name
|
41
|
+
of mplayer by adding this to the config file:
|
42
|
+
|
43
|
+
player: /usr/local/bin/mplayer
|
44
|
+
|
45
|
+
Same goes for unrar:
|
46
|
+
|
47
|
+
unrar: /usr/local/bin/unrar
|
48
|
+
|
49
|
+
Ignore file endings:
|
50
|
+
|
51
|
+
ignore_endings: ["nfo", "sfv", "txt"] # default
|
52
|
+
ignore_endings: ["avi"]
|
33
53
|
|
34
54
|
== TODO
|
35
55
|
|
36
|
-
* Handling rar-archives
|
37
56
|
* Better playlist support
|
38
57
|
* Other mediums then just avi et al(DVD, Bluray and so on)
|
39
58
|
* Handle meta-data
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/paradiso/base.rb
CHANGED
@@ -13,17 +13,26 @@ module Paradiso
|
|
13
13
|
@pid = nil
|
14
14
|
@amount_played = 0
|
15
15
|
|
16
|
+
if args.empty?
|
17
|
+
puts "Error: needs atleast one argument"
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
16
21
|
if @options[:playlist] and not @options[:path]
|
17
22
|
args.each do |pl|
|
18
23
|
unless File.exist? pl
|
19
24
|
puts "Warning: playlist %s does not exist" % [pl]
|
20
25
|
next
|
21
26
|
end
|
22
|
-
|
23
|
-
|
27
|
+
|
28
|
+
begin
|
29
|
+
@playlist << Playlist.create_from_file(pl, @options[:ignore_endings])
|
30
|
+
rescue ArgumentError => e
|
31
|
+
puts "Warning: #{e}"
|
32
|
+
end
|
24
33
|
end
|
25
34
|
else
|
26
|
-
@playlist << Playlist.new(args, @options[:path])
|
35
|
+
@playlist << Playlist.new(args, @options[:path], @options[:ignore_endings])
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
@@ -36,12 +45,12 @@ module Paradiso
|
|
36
45
|
puts "Exiting..."
|
37
46
|
ensure
|
38
47
|
@playlist.each do |pl|
|
39
|
-
if @options[:delete] and
|
40
|
-
pl.
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
48
|
+
if (@options[:path] or @options[:delete]) and @options[:playlist]
|
49
|
+
if pl.started? and not pl.empty?
|
50
|
+
pl.create @options[:delete]
|
51
|
+
elsif pl.empty?
|
52
|
+
pl.delete
|
53
|
+
end
|
45
54
|
end
|
46
55
|
end
|
47
56
|
end
|
@@ -73,8 +82,11 @@ module Paradiso
|
|
73
82
|
end
|
74
83
|
|
75
84
|
puts "Playing #{item}"
|
76
|
-
|
77
|
-
|
85
|
+
|
86
|
+
play_command = player item
|
87
|
+
item = "-" if item =~ /(rar|r\d{2})$/
|
88
|
+
|
89
|
+
cmd = "#{play_command} #{options_str} \"#{item}\""
|
78
90
|
POpen4::popen4(cmd) do |stdout, stderr, stdin, pid|
|
79
91
|
@pid = pid
|
80
92
|
end
|
@@ -82,6 +94,11 @@ module Paradiso
|
|
82
94
|
|
83
95
|
true
|
84
96
|
end
|
97
|
+
|
98
|
+
def player file
|
99
|
+
return @options[:player] unless file =~ /(rar|r\d{2})$/
|
100
|
+
return "#{@options[:unrar]} p -inul #{file} | #{@options[:player]}"
|
101
|
+
end
|
85
102
|
end
|
86
103
|
end
|
87
104
|
|
data/lib/paradiso/playlist.rb
CHANGED
@@ -11,18 +11,22 @@ module Paradiso
|
|
11
11
|
include Enumerable
|
12
12
|
|
13
13
|
class << self
|
14
|
-
def create_from_file file
|
14
|
+
def create_from_file file, ignore_endings=[]
|
15
15
|
items = []
|
16
16
|
|
17
17
|
f = File.open(file, 'r').each_line do |line|
|
18
18
|
items << line.sub(/[\r\n]+/, '')
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
if items.empty?
|
22
|
+
raise ArgumentError, "no files in playlist #{file}"
|
23
|
+
end
|
24
|
+
|
25
|
+
new items, file, ignore_endings=[]
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
|
-
def initialize files, path=nil
|
29
|
+
def initialize files, path=nil, ignore_endings=[]
|
26
30
|
@files = []
|
27
31
|
@path = path
|
28
32
|
@current_idx = -1
|
@@ -30,9 +34,24 @@ module Paradiso
|
|
30
34
|
files.each do |file|
|
31
35
|
begin
|
32
36
|
tmp = []
|
37
|
+
rars = []
|
33
38
|
|
34
39
|
Find.find(file) do |f|
|
35
|
-
|
40
|
+
next if File.directory? f
|
41
|
+
next if ignore_endings.include? f.split('.')[-1]
|
42
|
+
|
43
|
+
if f =~ /(rar|r\d{2})$/
|
44
|
+
rar = File.expand_path(f).dup
|
45
|
+
rar.gsub! /r\d{2}$/i, "rar"
|
46
|
+
rar.gsub! /part\d{2}/i, ""
|
47
|
+
|
48
|
+
unless rars.include? rar
|
49
|
+
rars << rar
|
50
|
+
tmp << File.expand_path(f)
|
51
|
+
end
|
52
|
+
else
|
53
|
+
tmp << File.expand_path(f)
|
54
|
+
end
|
36
55
|
end
|
37
56
|
|
38
57
|
@files += tmp.sort
|
@@ -55,7 +74,7 @@ module Paradiso
|
|
55
74
|
end
|
56
75
|
|
57
76
|
def create delete=false
|
58
|
-
sp = delete ?
|
77
|
+
sp = delete ? @current_idx : 0
|
59
78
|
|
60
79
|
File.open(@path, 'w') do |f|
|
61
80
|
@files[sp..-1].each { |line| f.puts line }
|
@@ -68,24 +87,17 @@ module Paradiso
|
|
68
87
|
|
69
88
|
def each
|
70
89
|
@files.each_index do |idx|
|
71
|
-
yield @files[idx]
|
72
90
|
@current_idx = idx
|
91
|
+
yield @files[idx]
|
73
92
|
end
|
74
93
|
end
|
75
94
|
|
76
95
|
def empty?
|
77
|
-
|
96
|
+
@current_idx >= @files.size
|
78
97
|
end
|
79
98
|
|
80
|
-
|
81
|
-
|
82
|
-
def start_point
|
83
|
-
# can this be made in a nicer way?
|
84
|
-
case @current_idx
|
85
|
-
when -1 then 0
|
86
|
-
when 0 then 1
|
87
|
-
else @current_idx + 1
|
88
|
-
end
|
99
|
+
def started?
|
100
|
+
@current_idx > -1
|
89
101
|
end
|
90
102
|
end
|
91
103
|
end
|
data/lib/paradiso.rb
CHANGED
data/paradiso.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{paradiso}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Victor Bergoo"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-31}
|
13
13
|
s.default_executable = %q{paradiso}
|
14
14
|
s.description = %q{A simplified mplayer command line interface}
|
15
15
|
s.email = %q{victor.bergoo@gmail.com}
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Victor Bergoo
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-31 00:00:00 +02:00
|
18
18
|
default_executable: paradiso
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|