class AnimeDL::AnimeHeaven

Public Class Methods

new() click to toggle source
# File lib/anime_dl.rb, line 8
def initialize
  @agent = Mechanize.new
  @agent.user_agent_alias = 'Windows Chrome'
  @anime_page = nil
end

Public Instance Methods

getTotal(option = nil) click to toggle source

Returns the total number of episodes

# File lib/anime_dl.rb, line 21
def getTotal(option = nil)
  @anime_page = @agent.get(option.attributes['href'].value)  unless (@anime_page)
  episodes = @anime_page.search(".infoepbox").search("a")

  # New Episodes have a different class
  begin
    first = episodes.last.search(".infoept2")[0].content.to_i
  rescue
    first = episodes.last.search(".infoept2r")[0].content.to_i
  end
  begin
    last = episodes.first.search(".infoept2")[0].content.to_i
  rescue
    last = episodes.first.search(".infoept2r")[0].content.to_i
  end

  return first, last
end
limit_exceeded(quiet) click to toggle source
# File lib/anime_dl.rb, line 47
def limit_exceeded(quiet)
  return  "Unfortunately \"animeheaven.eu\" only allows a certain number of page views per day (>170, <350).\n" +
          "It seems you have exceeded that limit :(.\n" +
          "Please change networks or try again tomorrow."   if (!quiet)

  return  "(Limit exceeded)"
end
parseURL(url) click to toggle source

UTILITY

# File lib/anime_dl.rb, line 42
def parseURL(url)
  url = url.to_s[/luu1=rrl\(".*?"\)/][10...-2]
  return url.tr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm")
end