class MultimediaParadise::Multimedia::VideoDownloader

Constants

NAMESPACE
#

NAMESPACE

#

Public Class Methods

new( this_file = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/multimedia_paradise/multimedia/video_downloader/video_downloader.rb, line 29
def initialize(
    this_file   = ARGV,
    run_already = true
  )
  reset
  set_this_file(this_file)
  run if run_already
end

Public Instance Methods

do_download_the_remote_video( i = which_file?, special_key_to_use_for_a_hash = 'url' ) click to toggle source
#

do_download_the_remote_video

#
# File lib/multimedia_paradise/multimedia/video_downloader/video_downloader.rb, line 85
def do_download_the_remote_video(
    i = which_file?,
    special_key_to_use_for_a_hash = 'url'
  )
  if i and File.exist?(i)
    if i.end_with?('.yml') # Handle YAML files differently here.
      dataset = load_yaml(i)
      _ = []
      if dataset.is_a? Hash
        dataset.each_pair {|key, inner_hash|
          if inner_hash.has_key? special_key_to_use_for_a_hash
            remote_URL = inner_hash[special_key_to_use_for_a_hash]
            _ << remote_URL
          end
        }
      end
      dataset = _ unless _.empty?
    else
      dataset = File.readlines(i)
    end
    ensure_that_the_output_directory_exists
    cd log_directory?
    mkdir('downloaded_videos/') if return_pwd.include? log_dir?
    cd 'downloaded_videos/'
    opnn; e 'Proceeding to batch-download the videos next, from '\
            'the'
    opnn; e 'local directory `'+sdir(return_pwd)+'`.'
    e
    array_results = []
    dataset.each {|this_remote_URL|
      opnn; e 'Working on '+steelblue(this_remote_URL)+' next ...'
      opnn; e '(This may take a while.)'
      cmd_to_use = "youtube-dl #{this_remote_URL}"
      result = `#{cmd_to_use}`
      array_results << result
    }
    opnn; e 'Results were:'
    pp array_results
    if is_on_roebe? and return_pwd.include?(log_dir?)
      opnn; e 'Trying to remove all " " characters from files next.'
      require 'roebe/classes/replace_space_with_underscore/replace_space_with_underscore.rb'
      Roebe.replace_space_with_underscore('--everything')
    end
  else
  end
end
file?() click to toggle source
#

file?

#
# File lib/multimedia_paradise/multimedia/video_downloader/video_downloader.rb, line 78
def file?
  @this_file
end
Also aliased as: which_file?
reset() click to toggle source
#

reset

#
Calls superclass method MultimediaParadise::Base#reset
# File lib/multimedia_paradise/multimedia/video_downloader/video_downloader.rb, line 41
def reset
  super()
  # ======================================================================= #
  # === @namespace
  # ======================================================================= #
  @namespace = NAMESPACE
end
run() click to toggle source
#

run

#
# File lib/multimedia_paradise/multimedia/video_downloader/video_downloader.rb, line 135
def run
  do_download_the_remote_video
end
set_this_file(i) click to toggle source
#

set_this_file

#
# File lib/multimedia_paradise/multimedia/video_downloader/video_downloader.rb, line 52
def set_this_file(i)
  i = i.first if i.is_a? Array
  # ======================================================================= #
  # Note that Symbols are handled in a special way by this method.
  # ======================================================================= #
  case i # case tag
  # ======================================================================= #
  # === :ruck_zuck
  # ======================================================================= #
  when :ruck_zuck
    i = yaml_directory?+
        'game_shows/ruck_zuck/ruck_zuck.yml'
  # ======================================================================= #
  # === :tales_from_the_crypt
  # ======================================================================= #
  when :tales_from_the_crypt,
       :tales
    i = yaml_directory?+
        'tales_from_the_crypt/tales_from_the_crypt.yml'
  end
  @this_file = i
end
which_file?()
Alias for: file?