Module: Paradiso

Defined in:
lib/paradiso.rb,
lib/paradiso/base.rb,
lib/paradiso/playlist.rb

Defined Under Namespace

Classes: Paradiso, Playlist

Constant Summary collapse

VERSION =
File.read(File.dirname(__FILE__) + "/../VERSION").chomp
Options =
{
  :fullscreen => false,
  :screen => 0,
  :playlist => false,
  :delete => false,
  :amount => nil,
  :path => nil,
  :aspectratio => '16:9',
  :player => 'mplayer',
  :unrar => 'unrar',
  :archive => false,
  :ignore_endings => ['nfo', 'sfv', 'txt'],
  :timestamp => false,
  :autosubs => false,
}

Class Method Summary collapse

Class Method Details

.config_fileObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/paradiso.rb', line 44

def config_file 
  options = Options.dup
  
  config_file = File.expand_path('~/.paradiso')
  if File.exist? config_file
    yaml = YAML::load(File.open(config_file, 'r').read())
    yaml.inject(options) { |memo, o| memo[o.first.to_sym] = o.last; memo }
  end

  return options
end

.parse_cl!(options, args) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/paradiso.rb', line 56

def parse_cl! options, args
  args.options do |o|
    o.set_summary_indent '  '
    o.banner = "Usage: #{File.basename $0} [Options]"
    o.define_head "Paradiso #{VERSION}: A simple mplayer CLI"

    o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
    o.on_tail("-v", "--version", "Show version number") { puts "Paradiso %s" % [VERSION]; exit}

    o.on("-a", "--amount n", Integer, "Play [n] items") { |amount|
      options[:amount] = amount
    }

    o.on("-A", "--aspect-ratio n", String, "Aspect ratio - 16:9, 4:3..") { |ratio|
      options[:aspectratio] = ratio
    }

    o.on("-d", "--delete", "Delete items from paylist") { 
      options[:delete] = true
    }

    o.on("-f", "--fullscreen", "Fullscreen mode") { 
      options[:fullscreen] = true
    } 

    o.on("-n", "--name path", String, "Playlist path to create") { |path|
      options[:path] = path
    }

    o.on("-p", "--playlist", "The arguments is playlists") { 
      options[:playlist] = true
    }

    o.on("-s", "--screen n", Integer, "Which screen to play from") { |screen|
      options[:screen] = screen
    }

    o.on("-S", "--autosubs", "Load automatic subs") {
      options[:autosubs] = true
    }

    o.parse!

    return options, args
  end
end

.runObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/paradiso.rb', line 33

def run
  options = config_file 
  options, args = parse_cl!(options, ARGV)
  
  para = Paradiso.new options, args
  para.run
rescue ArgumentError => e
  puts "Error: #{e}"
  exit 1
end