class MovieMasher::MetaReader

used to parse file's meta data

Public Class Methods

new(path) click to toggle source
Calls superclass method MovieMasher::Hashable::new
# File lib/util/meta_reader.rb, line 6
def initialize(path)
  # sequence outputs point to a directory
  path = Dir[Path.concat path, '*'].first if File.directory?(path)
  @path = path
  super({})
end

Public Instance Methods

[](symbol) click to toggle source
Calls superclass method MovieMasher::Hashable#[]
# File lib/util/meta_reader.rb, line 13
def [](symbol)
  @hash[symbol] ||= _meta(symbol)
  super
end
_info() click to toggle source
# File lib/util/meta_reader.rb, line 18
def _info
  Info.get(@path, __callee__.id2name)
end
_meta(symbol) click to toggle source
# File lib/util/meta_reader.rb, line 22
def _meta(symbol)
  s = ffmpeg
  metas = s.split('Metadata:')
  metas.shift
  unless metas.empty?
    sym_str = symbol.id2name
    metas.each do |meta|
      lines = meta.split "\n"
      lines.shift if lines.first.strip.empty?
      first_line = lines.first
      pad = first_line.match(/(\s+)\S/)[1]
      lines.each do |line|
        break unless line.start_with? pad

        pair = line.split(':').map(&:strip)
        return pair.last if pair.first == sym_str
      end
    end
  end
  ''
end
audio()
Alias for: _info
audio_duration()
Alias for: _info
dimensions()
Alias for: _info
duration()
Alias for: _info
ffmpeg()
Alias for: _info
fps()
Alias for: _info
http()
Alias for: _info
sox()
Alias for: _info
type()
Alias for: _info
video_duration()
Alias for: _info