Sha256: 34bd6574546496d288e85c3594209825c4f655daa30b6a0752cf9b9e84dc29c6
Contents?: true
Size: 1.29 KB
Versions: 27
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require 'eac_ruby_utils/core_ext' require 'ehbrs/fs/compressed_package' module Ehbrs module Videos module Extract class PackageFile DEFAULT_QUALITY = '__default__' enable_simple_cache common_constructor :package, :path do self.path = path.to_pathname end def copy_to_selected_dir ::FileUtils.cp(path.to_path, selected_dir.to_path) end def match_quality?(quality) path.basename_sub { |b| b.to_s.downcase }.basename .fnmatch?("*#{quality.downcase}*".gsub(/\A\*+/, '*').gsub(/\*+\z/, '*')) end def move_to_quality_dir ::FileUtils.mv(path.to_path, quality_dir.to_path) end private def quality_uncached package.qualities.find { |q| match_quality?(q) } || DEFAULT_QUALITY end def quality_dir r = package.target_dir / quality r.mkpath r end def selected_dir r = nil r = package.target_dir / 'source' if /\.torrent/ =~ path.to_path r = package.target_dir / 'subtitle' if /\.srt/ =~ path.to_path raise "Destination unknown: #{path}" unless r r.mkpath r end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems