class MovieOrganizer::Video
Constants
- VIDEO_EXTENSIONS
Attributes
settings[R]
Public Class Methods
match?(filepath)
click to toggle source
This should be the last Media type to match on. Pretty much if the .ext matches video file types then consider it a video.
@return [Boolean] true if matches file extensions, false if not
# File lib/movie_organizer/video.rb, line 18 def match?(filepath) return true if VIDEO_EXTENSIONS.include?(extname(filepath)) false end
new(filename)
click to toggle source
Calls superclass method
MovieOrganizer::Medium::new
# File lib/movie_organizer/video.rb, line 24 def initialize(filename) @settings = Settings.instance super end
Public Instance Methods
date_time()
click to toggle source
# File lib/movie_organizer/video.rb, line 52 def date_time release_date&.strftime('%Y-%m-%d @ %l:%M %p') end
process!(file_copier = nil)
click to toggle source
# File lib/movie_organizer/video.rb, line 29 def process!(file_copier = nil) target_file = File.join(target_dir, processed_filename) Logger.instance.info(" target file: [#{target_file.green.bold}]") fc = file_copier || FileCopier.new(filename, target_file, options) fc.copy! end
processed_filename()
click to toggle source
# File lib/movie_organizer/video.rb, line 36 def processed_filename "#{title} (#{year})#{extname}" end
release_date()
click to toggle source
# File lib/movie_organizer/video.rb, line 71 def release_date st = File.stat(filename) return st.birthtime unless MovieOrganizer.os == :retarded st.ctime end
target_dir()
click to toggle source
# File lib/movie_organizer/video.rb, line 67 def target_dir File.join(MovieOrganizer.video_directory, "#{title} (#{date_time})") end
title()
click to toggle source
# File lib/movie_organizer/video.rb, line 40 def title @title ||= begin prompt = <<-STRING.here_with_pipe(' ') |Enter a friendly title for this video: [#{basename}] |or hit enter to keep the current title STRING new_title = MovieOrganizer.prompt_for(prompt, '') return File.basename(filename, extname) if new_title.nil? || new_title.empty? new_title end end
year()
click to toggle source
Return assumed year of video. First try to get it from the filename itself Next get it from the operating system's creation date of the file
@return [Fixnum] Assumed year of the video file
# File lib/movie_organizer/video.rb, line 61 def year derived = derived_year return derived if derived release_date&.year end