Class: Dvdvrconv::Command
- Inherits:
-
Object
- Object
- Dvdvrconv::Command
- Defined in:
- lib/dvdvrconv/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #dvdpath ⇒ Object
-
#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.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dvdvrconv/command.rb', line 9 def initialize(argv) @argv = argv = {} config_file = Dvdvrconv::DEFAULT_CONFIG_FILE if File.exist?(config_file) puts "Read the default config file. => #{config_file}" load_config(config_file) end end |
Class Method Details
.run(argv) ⇒ Object
5 6 7 |
# File 'lib/dvdvrconv/command.rb', line 5 def self.run(argv) new(argv).execute end |
Instance Method Details
#dvdpath ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/dvdvrconv/command.rb', line 200 def dvdpath { :vr_mangr_ifo => [:vr_mangr_ifo], :vr_movie_vro => [:vr_movie_vro], :dvd_vr_cmd => [:dvd_vr_cmd] } end |
#execute ⇒ Object
For now, this test code returns dummy dvd-vr information.
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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/dvdvrconv/command.rb', line 21 def execute = Dvdvrconv::Options.parse(@argv) dvd = Dvdvrconv::Dvdvr.new # Set the path specified in the yaml file. if [:vr_mangr_ifo] dvd.vrdisc.opts_ifo = [:vr_mangr_ifo] else dvd.vrdisc.opts_ifo = dvd.vrdisc.default_opts_ifo end if [:vr_movie_vro] dvd.vrdisc.opts_vro = [:vr_movie_vro] else dvd.vrdisc.opts_vro = dvd.vrdisc.default_opts_vro end if [:dvd_vr_cmd] dvd.vrdisc.cmd = [:dvd_vr_cmd] else dvd.vrdisc.cmd = dvd.vrdisc.default_cmd end 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 if [:concat_mode].nil? dvd.vrdisc.concat_mode = Dvdvrconv::DEFAULT_CONCAT_MODE else dvd.vrdisc.concat_mode = [:concat_mode] end if [:hardware_encode].nil? dvd.vrdisc.hardware_encode = DEFAULT_HARDWARE_ENCODE else dvd.vrdisc.hardware_encode = [:hardware_encode] end if [:global_quality].nil? dvd.vrdisc.global_quality = Dvdvrconv::DEFAULT_GLOBAL_QUALITY else dvd.vrdisc.global_quality = [:global_quality] 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}" puts '== Customize settings ==' puts " => use_customize_title: #{@options[:use_customize_title]}" puts " => base_dst_name: #{@options[:base_dst_name]}" puts " => number_list: #{@options[:number_list]}" puts " => concat_mode: #{@options[:concat_mode]}" puts " => hardware_encode: #{@options[:hardware_encode]}" puts " => global_quality: #{@options[:global_quality]}" dvd.read_info dvd.view_info if [:opt][:info] || [:opt].empty? exit unless [:opt][:exec] # 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 if dvd.vrdisc.concat_mode == true puts '== Concatenate Split titles ==' concat_list = dvd.make_concat_list dvd.concat_titles(concat_list) end # 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.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/dvdvrconv/command.rb', line 159 def load_config(file) config = YAML.safe_load(File.read(file)) || {} %w[vr_mangr_ifo vr_movie_vro dvd_vr_cmd].each do |key| [key.to_sym] = nil unless config.key?(key) puts "[ #{key} ] does not exist in #{file} file." else if File.exist?(config[key]) [key.to_sym] = config[key] else puts "File read error. No such file: #{config[key]}" end end end [:use_customize_title] = config['use_customize_title'] || 'no' [:base_dst_name] = config['base_dst_name'] || [] [:number_list] = config['number_list'] || [] if config['concat_mode'].nil? [:concat_mode] = Dvdvrconv::DEFAULT_CONCAT_MODE else [:concat_mode] = config['concat_mode'] end if config['hardware_encode'].nil? [:hardware_encode] = 'normal' else [:hardware_encode] = config['hardware_encode'] end if config['global_quality'].nil? [:global_quality] = Dvdvrconv::DEFAULT_GLOBAL_QUALITY else [:global_quality] = config['global_quality'] end end |