Method: Musical::DVD#rip

Defined in:
lib/musical/dvd.rb

#ripObject



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
# File 'lib/musical/dvd.rb', line 83

def rip
  raise RuntimeError.new DETECT_ERROR_MESSAGE unless @@path
  save_dir = Musical.configuration.output
  FileUtils.mkdir_p save_dir

  chapters = []

  title_sets.each do |title_set|
    chapters << (1..title_set[:chapter]).map do |chapter_index|
      commands = []
      commands << 'dvdbackup'
      commands << "--input='#{@@path}'"
      commands << "--title='#{title_set[:title]}'"
      commands << "--start=#{chapter_index}"
      commands << "--end=#{chapter_index}"
      commands << "--output='#{Musical.configuration.working_dir}'"
      execute_command(commands.join(' '), true)

      vob_save_path = "#{save_dir}/TITLE_#{title_set[:title]}_#{chapter_index}.VOB"
      FileUtils.mv(vob_path, vob_save_path)

      yield if block_given?

      Chapter.new(vob_save_path, title_number: title_set[:title], chapter_number: chapter_index)
    end
  end
  chapters.flatten
end