Class: AppleTvConverter::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/apple_tv_converter/command_line.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CommandLine

Returns a new instance of CommandLine.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/apple_tv_converter/command_line.rb', line 3

def initialize(*args)
  @skip_subtitles = false
  @skip_metadata = false
  @skip_cleanup = false

  begin
    options = parse_arguments(args)

    media_objects = options.media

    converter = AppleTvConverter::MediaConverter.new(options)

    media_objects.sort { |a, b| a.original_filename <=> b.original_filename }.each_with_index do |media, index|
      puts "---[ Processing file #{index + 1} of #{media_objects.length}: #{File.basename(media.original_filename)} ]----------------"
      converter.process_media media
    end
  rescue ArgumentError => e
    puts "Error: #{e.message}"
  rescue => e
    puts "Error: #{e.message}"
    puts e.backtrace
  end
end