class MultimediaParadise::Video::VideoRenamer
Public Class Methods
[](i = ARGV)
click to toggle source
Public Instance Methods
all_titles?()
click to toggle source
dataset?()
click to toggle source
first_word?()
click to toggle source
input?()
click to toggle source
rename_this_video_file(i = input?)
click to toggle source
#¶ ↑
rename_this_video_file
¶ ↑
Only call this method when you are sure that we have an input file.
It will then proceed to rename the video file.
#¶ ↑
# File lib/multimedia_paradise/video/video_renamer.rb, line 120 def rename_this_video_file(i = input?) matching_dataset = dataset?.select {|key, hash| downcased_word = first_word?.downcase hash['title'].downcase.include? downcased_word } if matching_dataset file_extension = File.extname(i).delete('.') the_key = matching_dataset.keys.first new_filename = the_key.to_s+'_' # ===================================================================== # # Next, append the real name. # ===================================================================== # new_filename << matching_dataset[the_key]['title'].delete(' ')+'.'+file_extension opnn; e 'Now renaming `'+sfile(input?)+'` to `'+sfile(new_filename)+'`.' rename_file(i, new_filename) end end
reset()
click to toggle source
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/video/video_renamer.rb, line 82 def run # ======================================================================= # # First, determine whether we have a match. # ======================================================================= # _ = first_word? # ======================================================================= # # If a '.' is there, we will assume a file extension such as '.mp4' # which is not necessary, thus it will be removed.. # ======================================================================= # if _.include? '.' _.sub!(/#{File.extname(_)}$/,'') end video_is_registered = all_titles?.any? {|entry| entry.include? _ } if video_is_registered rename_this_video_file else opnn; e 'It appears as if we do not have a video for this '\ 'input ('+simp(_)+').' # ===================================================================== # # === Check for numbers only # ===================================================================== # if _.to_s =~ /^\d+$/ title = dataset?[_.to_i]['title'] e 'Only numbers were given. We will thus check for the given file' e 'position at number '+simp(_)+' which is `'+simp(title)+'`.' end end end