Sha256: f0cd61acc478ec82484794bef69126a83412dff8a3b60e35aec47f907b6e66d6
Contents?: true
Size: 1.7 KB
Versions: 13
Compression:
Stored size: 1.7 KB
Contents
# frozen_string_literal: true require 'eac_cli/core_ext' require 'ehbrs/videos/extract/package' module Ehbrs class Runner class Videos class Extract require_sub __FILE__ DEFAULT_QUALITIES = %w[1080 720 web webrip hdtv].freeze runner_with :help do desc 'Extrai arquivos de seriados.' arg_opt '-d', '--dir', 'Extraí para diretório.' bool_opt '-D', '--delete', 'Remove o pacote após o processamento.' arg_opt '-q', '--qualities', 'Lista de qualidades.' pos_arg 'packages', repeat: true end def run start_banner packages.each do |package| infov 'Package', package package.run(parsed.delete?) end end private def packages_uncached parsed.packages?.map do |p| ::Ehbrs::Videos::Extract::Package.new(p, target_dir, qualities) end end def qualities_uncached (parsed.qualities.to_s.split(',') + DEFAULT_QUALITIES).uniq end def start_banner infov 'Packages', packages.count infov 'Qualities', qualities infov 'Target directory', target_dir end def target_dir_uncached parsed.dir.if_present(&:to_pathname) || default_target_dir end def default_target_dir r = parsed.packages.first.to_pathname.basename('.*') return r unless r.exist? r = r.basename_sub { |b| "#{b}_extract" } index = 0 loop do return r unless r.exist? index += 1 r = r.basename_sub { |b| "#{b}_#{index}" } end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems