paradiso 0.1.5

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2009-2010 Victor Bergöö
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.rst ADDED
@@ -0,0 +1,15 @@
1
+ Paradiso
2
+ ========
3
+
4
+ A small lightweight command line interface for mplayer_.
5
+
6
+ TODO
7
+ ----
8
+
9
+ * Handling rar-archives(code already exists but doesn't work that great with OS X unrar)
10
+ * Better playlist support
11
+ * Other mediums then just avi et al(DVD, Bluray and so on)
12
+ * Proper ID3 et al parsing
13
+ * Config stuff, file ratios and such.
14
+
15
+ .. _mplayer: http://www.mplayerhq.hu
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "paradiso"
8
+ gem.summary = %Q{A command line interface for mplayer}
9
+ gem.description = %Q{A simplified mplayer command line interface}
10
+ gem.email = "victor.bergoo@gmail.com"
11
+ gem.homepage = "http://github.com/netfeed/paradiso"
12
+ gem.authors = ["Victor Bergoo"]
13
+ gem.add_dependency "popen4"
14
+ gem.add_dependency "json"
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.5
data/bin/paradiso ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2010 Victor Bergöö
4
+ # This program is made available under the terms of the MIT License.
5
+
6
+ require 'rubygems'
7
+ require File.dirname(__FILE__) + '/../lib/paradiso'
8
+
9
+ Paradiso.run
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2010 Victor Bergöö
3
+ # This program is made available under the terms of the MIT License.
4
+
5
+ require 'popen4'
6
+ require 'paradiso/playlist'
7
+
8
+ module Paradiso
9
+ class Paradiso
10
+ def initialize options, args
11
+ @options = options
12
+ @pl_file = nil
13
+ @pid = nil
14
+
15
+ if @options[:playlist] and args.size > 1 and not @options[:path]
16
+ puts "Error: Can only handle one playlist"
17
+ exit 1
18
+ end
19
+
20
+ if @options[:playlist] and not @options[:path]
21
+ @pl_file = args.pop
22
+ @playlist = Playlist.create_from_file @pl_file
23
+ else
24
+ @playlist = Playlist.new args
25
+ end
26
+ end
27
+
28
+ def run
29
+ options_str = handle_options
30
+ amount = 0
31
+
32
+ @playlist.each do |item|
33
+ if @options[:amount]
34
+ break if amount == @options[:amount]
35
+ amount += 1
36
+ end
37
+
38
+ puts "Playing #{item}"
39
+
40
+ cmd = "mplayer #{options_str} \"#{item}\""
41
+ POpen4::popen4(cmd) do |stdout, stderr, stdin, pid|
42
+ @pid = pid
43
+ end
44
+ end
45
+ rescue Interrupt
46
+ Process.kill(9, @pid) if @pid
47
+ puts "Exiting..."
48
+ ensure
49
+ if (@options[:path] or @options[:delete]) and @options[:playlist]
50
+ file = @options[:path] ? @options[:path] : @pl_file
51
+ @playlist.create file, @options[:delete]
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def handle_options
58
+ str = []
59
+ ratio = @options[:aspectratio]
60
+
61
+ str += ['-monitoraspect', ratio, '-aspect', ratio]
62
+ if @options[:fullscreen]
63
+ str << "-fs"
64
+ end
65
+
66
+ # more platforms needs to be added
67
+ if RUBY_PLATFORM =~ /darwin10/
68
+ str += ['-vo', 'corevideo:device_id=%d' % [@options[:screen]]]
69
+ end
70
+
71
+ str.join " "
72
+ end
73
+ end
74
+ end
75
+
@@ -0,0 +1,82 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2010 Victor Bergöö
3
+ # This program is made available under the terms of the MIT License.
4
+
5
+ require 'find'
6
+
7
+ module Paradiso
8
+ class Playlist
9
+ attr_reader :files
10
+
11
+ include Enumerable
12
+
13
+ class << self
14
+ def create_from_file file
15
+ items = []
16
+
17
+ f = File.open(file, 'r').each_line do |line|
18
+ items << line.sub(/[\r\n]+/, '')
19
+ end
20
+
21
+ new items
22
+ end
23
+ end
24
+
25
+ def initialize files
26
+ @files = []
27
+ @current_idx = -1
28
+
29
+ files.each do |file|
30
+ begin
31
+ tmp = []
32
+
33
+ Find.find(file) do |f|
34
+ tmp << File.expand_path(f) unless File.directory? f
35
+ end
36
+
37
+ @files += tmp.sort
38
+ rescue Errno::ENOENT => e
39
+ puts "Couldn't find: #{file}"
40
+ end
41
+ end
42
+ end
43
+
44
+ def + other
45
+ raise ArgumentError "argument needs to be a of type Playlist" unless other.instance_of? Playlist
46
+
47
+ new(files + other.files)
48
+ end
49
+
50
+ def << other
51
+ raise ArgumentError "argument needs to be a of type Playlist" unless other.instance_of? Playlist
52
+
53
+ @files << other.files
54
+ end
55
+
56
+ def create path, delete=false
57
+ # can this be made in a nicer way?
58
+ start_point = case @current_idx
59
+ when -1 then 0
60
+ when 0 then 1
61
+ else @current_idx + 1
62
+ end
63
+ start_point = 0 unless delete
64
+
65
+ if (start_point >= @files.size) and delete
66
+ File.delete path
67
+ return
68
+ end
69
+
70
+ File.open(path, 'w') do |f|
71
+ @files[start_point..-1].each { |line| f.puts line }
72
+ end
73
+ end
74
+
75
+ def each
76
+ @files.each_index do |idx|
77
+ yield @files[idx]
78
+ @current_idx = idx
79
+ end
80
+ end
81
+ end
82
+ end
data/lib/paradiso.rb ADDED
@@ -0,0 +1,95 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2010 Victor Bergöö
3
+ # This program is made available under the terms of the MIT License.
4
+
5
+ dir = File.dirname(__FILE__)
6
+ $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include? dir
7
+
8
+ require 'json'
9
+ require 'optparse'
10
+ require 'paradiso/base'
11
+
12
+ module Paradiso
13
+ VERSION = File.read(File.dirname(__FILE__) + "/../VERSION").chomp
14
+
15
+ Options = {
16
+ :fullscreen => false,
17
+ :screen => 0,
18
+ :playlist => false,
19
+ :delete => false,
20
+ :amount => nil,
21
+ :path => nil,
22
+ :aspectratio => '16:9',
23
+ }
24
+
25
+ class << self
26
+ def run
27
+ options = config_file
28
+ options, args = parse_cl!(options, ARGV)
29
+
30
+ para = Paradiso.new options, args
31
+ para.run
32
+ end
33
+
34
+ def config_file
35
+ options = Options.dup
36
+
37
+ config_file = File.expand_path('~/.paradiso')
38
+ if File.exist? config_file
39
+ begin
40
+ json = JSON.parse(File.open(config_file, 'r').read())
41
+ json.each_pair do |key, value|
42
+ options[key.to_sym] = value
43
+ end
44
+ rescue JSON::ParserError => e
45
+ puts "Error: Parsing the config file failed, please check it"
46
+ end
47
+ end
48
+
49
+ return options
50
+ end
51
+
52
+ def parse_cl! options, args
53
+ args.options do |o|
54
+ o.set_summary_indent ' '
55
+ o.banner = "Usage: #{File.basename $0} [Options]"
56
+ o.define_head "A simple mplayer CLI"
57
+
58
+ o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
59
+ o.on_tail("-v", "--version", "Show version number") { puts "Paradiso %s" % [VERSION]; exit}
60
+
61
+ o.on("-a", "--amount n", Integer, "Play [n] items") { |amount|
62
+ options[:amount] = amount
63
+ }
64
+
65
+ o.on("-A", "--aspect-ratio n", String, "Aspect ratio - 16:9, 4:3..") { |ratio|
66
+ options[:aspectratio] = ratio
67
+ }
68
+
69
+ o.on("-d", "--delete", "Delete items from paylist") {
70
+ options[:delete] = true
71
+ }
72
+
73
+ o.on("-f", "--fullscreen", "Fullscreen mode") {
74
+ options[:fullscreen] = true
75
+ }
76
+
77
+ o.on("-n", "--name path", String, "Playlist path to create") { |path|
78
+ options[:path] = path
79
+ }
80
+
81
+ o.on("-p", "--playlist", "The argument is a playlist") {
82
+ options[:playlist] = true
83
+ }
84
+
85
+ o.on("-s", "--screen n", Integer, "Which screen to play from") { |screen|
86
+ options[:screen] = screen
87
+ }
88
+
89
+ o.parse!
90
+
91
+ return options, args
92
+ end
93
+ end
94
+ end
95
+ end
data/paradiso.gemspec ADDED
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{paradiso}
8
+ s.version = "0.1.5"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Victor Bergoo"]
12
+ s.date = %q{2010-10-04}
13
+ s.default_executable = %q{paradiso}
14
+ s.description = %q{A simplified mplayer command line interface}
15
+ s.email = %q{victor.bergoo@gmail.com}
16
+ s.executables = ["paradiso"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rst"
20
+ ]
21
+ s.files = [
22
+ "LICENSE",
23
+ "README.rst",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/paradiso",
27
+ "lib/paradiso.rb",
28
+ "lib/paradiso/base.rb",
29
+ "lib/paradiso/playlist.rb",
30
+ "paradiso.gemspec"
31
+ ]
32
+ s.homepage = %q{http://github.com/netfeed/paradiso}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.7}
36
+ s.summary = %q{A command line interface for mplayer}
37
+
38
+ if s.respond_to? :specification_version then
39
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_runtime_dependency(%q<popen4>, [">= 0"])
44
+ s.add_runtime_dependency(%q<json>, [">= 0"])
45
+ else
46
+ s.add_dependency(%q<popen4>, [">= 0"])
47
+ s.add_dependency(%q<json>, [">= 0"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<popen4>, [">= 0"])
51
+ s.add_dependency(%q<json>, [">= 0"])
52
+ end
53
+ end
54
+
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paradiso
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 5
10
+ version: 0.1.5
11
+ platform: ruby
12
+ authors:
13
+ - Victor Bergoo
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-04 00:00:00 +02:00
19
+ default_executable: paradiso
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: popen4
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: json
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: A simplified mplayer command line interface
50
+ email: victor.bergoo@gmail.com
51
+ executables:
52
+ - paradiso
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - LICENSE
57
+ - README.rst
58
+ files:
59
+ - LICENSE
60
+ - README.rst
61
+ - Rakefile
62
+ - VERSION
63
+ - bin/paradiso
64
+ - lib/paradiso.rb
65
+ - lib/paradiso/base.rb
66
+ - lib/paradiso/playlist.rb
67
+ - paradiso.gemspec
68
+ has_rdoc: true
69
+ homepage: http://github.com/netfeed/paradiso
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --charset=UTF-8
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.3.7
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: A command line interface for mplayer
102
+ test_files: []
103
+