Class: Dumper::Profiles::MangaHere

Inherits:
Profile
  • Object
show all
Defined in:
lib/dumper/profiles/mangahere.rb

Instance Method Summary collapse

Instance Method Details

#dump(url, path, from, to) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dumper/profiles/mangahere.rb', line 24

def dump(url, path, from, to)
  from -=  1
  to   -=  1 if to >= -1

  [].tap { |urls|
    Nokogiri::HTML(open(url)).xpath('//div[@class="detail_list"]/ul/li').each { |u|
      urls << u unless u.at_xpath('.//span/a/@href').to_s.strip.empty?
    }
  }.reverse[from..to].each { |p|
    chapter = p.at_xpath('.//span/a/@href').to_s
    name    = p.at_xpath('.//span/a/text()').to_s.strip

    dir = File.join path, name.sanitize_filename
    Dir.mkdir(dir) unless File.directory? dir

    Nokogiri::HTML(open(chapter)).xpath('//select[@class="wid60"]/option').each { |q|
      @pool.process {
        scan = Nokogiri::HTML(open(q['value'])).xpath('//section[@id="viewer"]/a/img/@src')[0].to_s
        Dumper.get dir, scan, { filename: "#{q.text}.png" }
      }
    }
  }
end