Sha256: 3943190dc45a93591acf7826fc2ee4b7ba75ccb882f79e5196d4d466288262a5

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

Contents

require "mkv2m4v/version"
require "mkv2m4v/file"
require "trollop"

module Mkv2m4v
  class Command
    def initialize
      parse_options
    end

    def run
      if @options[:info]
        each_file(&:print_info)
      else
        each_file(&:transcode)
      end
    end

    private

    def each_file
      Mkv2m4v::File.each(@filenames, @options) do |file|
        yield file
      end
    end

    def parse_options
      @options = Trollop::options do
        version Mkv2m4v::VersionDescription
        banner [Mkv2m4v::Description, Mkv2m4v::Usage].join("\n")
        opt :info, "Print media info only"
        opt :lang, "Preferred languages, comma separated", :type => :string, :default => "English"
        opt :dir, "Destination directory (default: same dir as source mkv)", :type => :string
      end
      parse_languages
      @filenames = ARGV
    end

    def parse_languages
      @options[:languages] =
        @options[:lang].split(/\s*,\s*/).map { |lang| Iso639[lang] }.compact
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mkv2m4v-1.0.0 lib/mkv2m4v.rb
mkv2m4v-0.3.1 lib/mkv2m4v.rb
mkv2m4v-0.3.0 lib/mkv2m4v.rb