Class: Dumper::Profiles::MangaEden

Inherits:
Profile
  • Object
show all
Defined in:
lib/dumper/profiles/mangaeden.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
47
48
49
# File 'lib/dumper/profiles/mangaeden.rb', line 24

def dump(url, path, from, to)
  from -= 1
  to   -= 1 if to >= -1
  
  Nokogiri::HTML(open(url)).xpath('//a[@class="chapterLink"]').reverse[from..to].each { |p|
    i = 1
    
    dir = File.join path, "#{p.children[1].text} - #{p.children[3].text.sanitize_filename}"
    Dir.mkdir(dir) unless File.directory? dir
    
    page = Nokogiri::HTML open("http://www.mangaeden.com#{p['href']}")

    Dumper.get dir, page.at_xpath('//img[@id="mainImg"]/@src'), { filename: '1.png' }
    i += 1
    
    page.xpath('//a[@class="ui-state-default"]').each { |q|
      next unless q.text.numeric?

      Nokogiri::HTML(open("http://www.mangaeden.com#{q['href']}")).xpath('//img[@id="mainImg"]/@src').each { |r|
        @pool.process {
          Dumper.get dir, r, { filename: "#{q.text.to_i}.png" }
        }
      }
    }
  }
end