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']
}

Class Method Summary collapse

Class Method Details

.config_fileObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/paradiso.rb', line 39

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.each_pair do |key, value|
      options[key.to_sym] = value
    end
  end

  return options
end

.parse_cl!(options, args) ⇒ Object



53
54
55
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
# File 'lib/paradiso.rb', line 53

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.parse!

    return options, args
  end
end

.runObject



31
32
33
34
35
36
37
# File 'lib/paradiso.rb', line 31

def run
  options = config_file 
  options, args = parse_cl!(options, ARGV)
  
  para = Paradiso.new options, args
  para.run
end