Sha256: 1eb71f34c65695b729a7454d59767bc9cc1f648207450ad08364dc69239aef69

Contents?: true

Size: 1.54 KB

Versions: 14

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require 'eac_fs/traversable'
require 'eac_ruby_utils/core_ext'
require 'ehbrs/videos/unsupported/file'

module Ehbrs
  module Videos
    module Unsupported
      class Search
        include ::EacFs::Traversable
        enable_speaker
        enable_simple_cache

        VALID_EXTENSIONS = %w[.avi .mp4 .mkv .m4v].freeze

        def initialize(root, file_options)
          @root = root
          @file_options = file_options
          @files = 0
          @videos = 0
          @unsupported = 0
          run
        end

        def traverser_recursive
          true
        end

        def traverser_sort
          true
        end

        private

        def run
          start_banner
          traverser_check_path(@root)
          end_banner
        end

        def traverser_check_file(file)
          @files += 1
          check_video(file) if video_file?(file)
        end

        def check_video(file)
          @videos += 1
          v = ::Ehbrs::Videos::Unsupported::File.new(file, @file_options)
          return if v.all_passed?

          @unsupported += 1
          v.banner
          v.check_fix
        end

        def start_banner
          infom "Searching in: \"#{@root}\""
        end

        def end_banner
          infom "Unsupported/Videos/Files: #{@unsupported}/#{@videos}/#{@files}"
        end

        def video_file?(path)
          valid_extensions.include?(::File.extname(path))
        end

        def valid_extensions
          self.class::VALID_EXTENSIONS
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ehbrs-tools-0.39.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.38.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.37.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.36.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.35.1 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.35.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.34.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.33.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.32.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.31.1 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.31.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.30.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.29.0 lib/ehbrs/videos/unsupported/search.rb
ehbrs-tools-0.28.3 lib/ehbrs/videos/unsupported/search.rb