Sha256: 4b4dfc08ca17d260442f2afce61ad1686f98b277df0024c8abdd0dc4a63b88b2

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Abrizer
  # Copies over any WebVTT captions that are beside the original video resource
  # into the destination folder.
  # TODO: This may only be needed if fMP4 derivatives aren't created since captions are copied over.
  # TODO: Allow for more than one captions/subtitle file to be copied over.
  class Captions

    include FilepathHelpers

    def initialize(filename, output_dir)
      @filename = filename
      @output_directory = output_dir
      if vtt_dir_glob.length > 0
        FileUtils.mkdir_p vtt_output_directory
      end
    end

    def copy
      vtt_dir_glob.each do |vtt|
        # vtt_basename = File.basename vtt
        vtt_filename = File.join vtt_output_directory, 'captions.vtt'
        FileUtils.cp vtt, vtt_filename
      end
    end

    def vtt_dir_glob
      Dir.glob vtt_file_glob
    end

    # TODO: actually search for more than one VTT file
    def vtt_file_glob
      File.join filename_directory, "#{basename}.vtt"
    end

    def vtt_output_directory
      File.join @output_directory, 'vtt'
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
abrizer-0.6.0 lib/abrizer/captions.rb
abrizer-0.5.0 lib/abrizer/captions.rb