class MultimediaParadise::Video::MissingVideoFiles

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

[](i = '') click to toggle source
#

MultimediaParadise::Video::MissingVideoFiles[]

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 278
def self.[](i = '')
  new(i)
end
new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 36
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Public Instance Methods

determine_all_local_videos() click to toggle source
#

determine_all_local_videos

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 82
def determine_all_local_videos
  @video_files = obtain_filelisting_from_this_directory
end
determine_the_yaml_dataset() click to toggle source
#

determine_the_yaml_dataset

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 190
def determine_the_yaml_dataset
  @dataset = MultimediaParadise.return_all_video_files
end
filelisting?()
Alias for: video_files?
iterate_over_the_dataset_from_the_file_video_collection_yml() click to toggle source
#

iterate_over_the_dataset_from_the_file_video_collection_yml

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 197
def iterate_over_the_dataset_from_the_file_video_collection_yml
  # ======================================================================= #
  # The next variable has just the filename, without any '/' characters.
  # ======================================================================= #
  shortened_video_files = @video_files.map {|entry| File.basename(entry) }
  determine_the_yaml_dataset
  @dataset.each_pair {|key, hash_dataset|
    padded_key = '%03d' % key.to_i
    if shortened_video_files.any? {|entry|
        entry.start_with? padded_key
      } # pass through in this case, as all is fine.
    else
      @found_n_missing_files += 1
      e crimson('Missing video-file')+' at position '+steelblue(key)
      local_path = target_dir?+'230_'+hash_dataset['title'].tr(' ','_')+
                   '.mp4'
      e '  The local path would be: '+
        sfile(local_path)
      @array_missing_videofiles << local_path
    end
  }
end
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
notify_the_user_as_to_which_directory_will_be_processed() click to toggle source
#

notify_the_user_as_to_which_directory_will_be_processed

Notify the user as to which directory will be scanned for locally existing videofiles.

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 235
def notify_the_user_as_to_which_directory_will_be_processed
  opnn; e "Videofiles will be fetched from #{sdir(which_dir?)}."
  opnn; e 'This dataset was generated from the file '+
          '`'+sfile(MultimediaParadise.yaml_file?)+'`.'
end
obtain_filelisting_from_this_directory( i = @work_on_this_directory ) click to toggle source
#

obtain_filelisting_from_this_directory

Note that this method will return a sorted Array.

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 91
def obtain_filelisting_from_this_directory(
    i = @work_on_this_directory
  )
  Dir["#{i}**"].select {|entry|
    is_this_a_video_file?(entry)
  }.sort
end
Also aliased as: update_filelisting, update
report_happy_message_if_no_local_video_file_is_missing() click to toggle source
#

report_happy_message_if_no_local_video_file_is_missing

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 223
def report_happy_message_if_no_local_video_file_is_missing
  if @found_n_missing_files == 0
    e 'Everything is fine - no local videofile is missing. This is good!'
  end
end
report_missing_videofiles() click to toggle source
#

report_missing_videofiles

This method will report which videofiles are missing.

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 246
  def report_missing_videofiles
    unless @array_missing_videofiles.empty?
      e
      opnn; e 'The following videofiles have been determined to be missing:'
      e
      @array_missing_videofiles.each {|original_entry|
        if Object.const_defined? :Colours and use_colours?
          entry  = COLOURS.limegreen(original_entry.to_s+')')
          result = COLOURS.lavender(result.to_s)
        else
          entry = sfancy(original_entry.to_s+')')
        end
        e entry+' '+result.to_s
      }
    }
  end

  # ========================================================================= #
  # === run                                                         (run tag)
  # ========================================================================= #
  def run
    menu
    notify_the_user_as_to_which_directory_will_be_processed
    determine_all_local_videos
    iterate_over_the_dataset_from_the_file_video_collection_yml
    report_happy_message_if_no_local_video_file_is_missing
    report_missing_videofiles
  end

  # ========================================================================= #
  # === MultimediaParadise::Video::MissingVideoFiles[]
  # ========================================================================= #
  def self.[](i = '')
    new(i)
  end

end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 50
def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
  # ======================================================================= #
  # === @work_on_this_directory
  # ======================================================================= #
  @work_on_this_directory = return_pwd
  # ======================================================================= #
  # === @video_files
  # ======================================================================= #
  @video_files = []
  # ======================================================================= #
  # === @found_n_missing_files
  #
  # This variable will keep track as to how many missing local video
  # files have been "found".
  # ======================================================================= #
  @found_n_missing_files = 0
  # ======================================================================= #
  # === @array_missing_videofiles
  #
  # This Array will store all missing (local) videofiles.
  # ======================================================================= #
  @array_missing_videofiles = []
end
run() click to toggle source
#

run (run tag)

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 266
def run
  menu
  notify_the_user_as_to_which_directory_will_be_processed
  determine_all_local_videos
  iterate_over_the_dataset_from_the_file_video_collection_yml
  report_happy_message_if_no_local_video_file_is_missing
  report_missing_videofiles
end
set_dir(i = return_pwd)
set_target_dir(i = return_pwd)
set_work_on_this_directory(i = return_pwd) click to toggle source
#

set_work_on_this_directory

By default, the current working directory will be used (Dir.pwd, or more accurately, the String returned by return_pwd()).

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 113
def set_work_on_this_directory(i = return_pwd)
  i = i.dup if i.frozen?
  i << '/' unless i.end_with? '/'
  @work_on_this_directory = i
end
Also aliased as: set_target_dir, set_dir
show_help( shall_we_exit = false ) click to toggle source
#

show_help (help tag)

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 131
def show_help(
    shall_we_exit = false
  )
  shall_we_exit = true if shall_we_exit == :then_exit
  opnn
  e
  e
  e 'This class tries to show which video files are missing (locally).'
  e
  e 'A very few options are available to control '\
    'the behaviour of this class:'
  e
  ecomment ' --dir=TARGET # use this specific directory to search '\
          'for missing video files'
  e
  exit if shall_we_exit
end
target_dir?()
update( i = @work_on_this_directory )
update_filelisting( i = @work_on_this_directory )
video_files?() click to toggle source
#

video_files?

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 103
def video_files?
  @video_files
end
Also aliased as: filelisting?
which_dir?()
work_on_this_directory?() click to toggle source
#

work_on_this_directory?

#
# File lib/multimedia_paradise/video/missing_video_files/missing_video_files.rb, line 123
def work_on_this_directory?
  @work_on_this_directory
end
Also aliased as: target_dir?, which_dir?