module AnimeDL

Methods to get links in 'anime_dl/#{anime_site}.rb'

Public Class Methods

download(path, episodes) click to toggle source

Download

# File lib/anime_dl.rb, line 57
def self.download(path, episodes)
  episodes.each do |episode|
    if ( File.exists?( File.join( path, "Episode #{episode.number}.mp4" )) )
      puts "Skipping Episode #{episode.number} (already exists)\n\n"
      next
    else 
      puts "Downloading Episode #{episode.number}"
    end

    status = episode.download_to(path)
    return  if status == -1
  end
end
range_handle(range, first, last) click to toggle source

Episode Range Handler

# File lib/anime_dl.rb, line 72
def self.range_handle(range, first, last)
  temp = []

  range.each do |arg|
    # Basic REGEX match
    unless (arg.match(/\A[0-9]+\Z|\A[0-9]+\-[0-9l]+\Z/))
      puts "'#{arg}' is an invalid input for 'Episodes'"
      next
    end

    if (arg.include?("-"))
      f, l = arg.split("-").collect(&:to_i)
      l = last  if (arg[-1] == "l")

      next  unless (f && l)
      next  if f > last
      l = last  if l > last

      (f..l).each do |n|
        temp << n  if ( (first..last).include? n )
      end

    else
      temp << arg.to_i  if ( (first..last).include? arg.to_i )

    end
  end

  return temp.uniq.sort
end