Sha256: eac8fc3ee8bfd48b4711ff82517452202ac82086d30cc9bf42c3e8c69c407777

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'ehbrs/tools/runner/videos/languages/labelized'

module Ehbrs
  module Tools
    class Runner
      class Videos
        class Languages
          class Track < ::Ehbrs::Tools::Runner::Videos::Languages::Labelized
            BLANK_LANGUAGE = 'BLANK'

            attr_reader :file

            def initialize(runner, object, file)
              super(runner, object)
              @file = file
            end

            def delete_ffmpeg_args
              return [] if included?

              ['-map', "-0:#{index}"]
            end

            def extract_ffmpeg_args
              return [] unless included?

              ['-map', "0:#{index}", extract_target]
            end

            def included?
              runner.keep_languages.include?(language)
            end

            def language
              language_with_title.presence || BLANK_LANGUAGE
            end

            def extract_target
              file.basename_sub('.*') { |b| "#{b}.#{language}_#{index}.srt" }
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ehbrs-tools-0.43.0 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.42.0 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.39.1 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.39.0 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.38.0 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.37.0 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.36.0 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.35.1 lib/ehbrs/tools/runner/videos/languages/track.rb
ehbrs-tools-0.35.0 lib/ehbrs/tools/runner/videos/languages/track.rb