Class: Dvdvrconv::Command
- Inherits:
-
Object
- Object
- Dvdvrconv::Command
- Defined in:
- lib/dvdvrconv/command.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#execute ⇒ Object
For now, this test code returns dummy dvd-vr information.
-
#initialize(argv) ⇒ Command
constructor
A new instance of Command.
-
#load_config(file) ⇒ Object
load yaml file and store in @options.
Constructor Details
#initialize(argv) ⇒ Command
Returns a new instance of Command.
7 8 9 10 11 12 13 14 15 |
# File 'lib/dvdvrconv/command.rb', line 7 def initialize(argv) @argv = argv = {} config_file = Dvdvrconv::DEFAULT_CONFIG_FILE if File.exist?(config_file) load_config(config_file) end end |
Class Method Details
.run(argv) ⇒ Object
3 4 5 |
# File 'lib/dvdvrconv/command.rb', line 3 def self.run(argv) new(argv).execute end |
Instance Method Details
#execute ⇒ Object
For now, this test code returns dummy dvd-vr information.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/dvdvrconv/command.rb', line 18 def execute = Dvdvrconv::Options.parse(@argv) dvd = Dvdvrconv::Dvdvr.new # Set the path specified in the yaml file. dvd.vrdisc.opts_ifo = [:vr_mangr_ifo] if [:vr_mangr_ifo] dvd.vrdisc.opts_vro = [:vr_movie_vro] if [:vr_movie_vro] dvd.vrdisc.cmd = [:dvd_vr_cmd] if [:dvd_vr_cmd] # dvd.vrdisc.opts_ifo = "test/DVD_RTAV/VR_MANGR.IFO" # dvd.vrdisc.opts_vro = "test/DVD_RTAV/VR_MOVIE.VRO" if [:opt][:config_file] puts "Use config file\n => #{options[:opt][:config_file]}" opt_config_file = [:opt][:config_file] load_config(opt_config_file) if File.exist?(opt_config_file) dvd.vrdisc.opts_ifo = [:vr_mangr_ifo] if [:vr_mangr_ifo] dvd.vrdisc.opts_vro = [:vr_movie_vro] if [:vr_movie_vro] dvd.vrdisc.cmd = [:dvd_vr_cmd] if [:dvd_vr_cmd] end # View the path of each files puts "== Use these paths ==" puts " => VR_MANGR.IFO: #{dvd.vrdisc.opts_ifo}" puts " => VR_MOVIE.VRO #{dvd.vrdisc.opts_vro}" puts " => dvd-vr.exe: #{dvd.vrdisc.cmd}" dvd.read_info if [:opt][:info] dvd.view_info exit end # Extract vob files dvd.adjust_title dvd.vro2vob # Change the file name to the title name dvd.change_to_title_name dvd.rename_vob # Concatenate Split titles concat_list = dvd.make_concat_list dvd.concat_titles(concat_list) # customize title of vob files case [:use_customize_title] when 1 puts "Specify individual file names." if [:base_dst_name].class == Array base_dst_name = [:base_dst_name] else puts "ERROR: base_dst_name should be an Array. \n ( => #{@options[:base_dst_name]})" exit end number_list = [] when 2 puts "Add sequence number to the file name." if [:base_dst_name].class == String base_dst_name = [:base_dst_name] else puts "ERROR: base_dst_name should be String. \n ( => #{@options[:base_dst_name]})" exit end number_list = [] when 3 puts "Specify sequence numbers individually." if [:base_dst_name].class == String base_dst_name = [:base_dst_name] else puts "ERROR: base_dst_name should be String. \n ( => #{@options[:base_dst_name]})" exit end if [:number_list].class == Array number_list = [:number_list] else puts "ERROR: number_list should be an Array." exit end else puts "No customize file names" base_dst_name = dvd.vrdisc.title.uniq.map { |file| file[0].gsub(/\s/, "_") } number_list = [] end dvd.customize_title(base_dst_name, number_list) dvd.rename_vob # convert vob to mp4 dvd.vob2mp4 end |
#load_config(file) ⇒ Object
load yaml file and store in @options.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/dvdvrconv/command.rb', line 118 def load_config(file) config = YAML.load(File.read(file)) %w(vr_mangr_ifo vr_movie_vro dvd_vr_cmd).each do |key| unless config.key?(key) puts "[ #{key} ] does not exist in #{file} file." exit end if File.exist?(config[key]) [key.to_sym] = config[key] else puts "File read error. No such file: #{config[key]}" end end [:use_customize_title] = config["use_customize_title"] || "no" [:base_dst_name] = config["base_dst_name"] || [] [:number_list] = config["number_list"] || [] end |