image-dumper 0.5.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dumper +47 -40
  3. data/lib/dumper.rb +38 -36
  4. data/lib/dumper/dumper.rb +114 -52
  5. data/lib/dumper/profiles/4chan.rb +49 -33
  6. data/lib/dumper/profiles/behoimi.rb +48 -38
  7. data/lib/dumper/profiles/booru.rb +54 -40
  8. data/lib/dumper/profiles/deviantart.rb +49 -33
  9. data/lib/dumper/profiles/fakku.rb +61 -51
  10. data/lib/dumper/profiles/fc2.rb +49 -33
  11. data/lib/dumper/profiles/gelbooru.rb +54 -40
  12. data/lib/dumper/profiles/imagebam.rb +55 -37
  13. data/lib/dumper/profiles/mangaeden.rb +69 -53
  14. data/lib/dumper/profiles/mangago.rb +53 -40
  15. data/lib/dumper/profiles/mangahere.rb +68 -49
  16. data/lib/dumper/profiles/multiplayer.rb +55 -41
  17. data/lib/dumper/profiles/redblow.rb +49 -36
  18. data/lib/dumper/profiles/sankakucomplex.rb +81 -58
  19. data/lib/dumper/profiles/teca.rb +54 -34
  20. data/lib/dumper/profiles/yande.rb +51 -42
  21. data/lib/dumper/utils.rb +40 -42
  22. data/lib/dumper/version.rb +23 -23
  23. data/spec/4chan_spec.rb +28 -0
  24. data/spec/behoimi_spec.rb +28 -0
  25. data/spec/booru_spec.rb +28 -0
  26. data/spec/deviantart_spec.rb +28 -0
  27. data/spec/fakku_spec.rb +28 -0
  28. data/spec/fc2_spec.rb +28 -0
  29. data/spec/gelbooru_spec.rb +28 -0
  30. data/spec/imagebam_spec.rb +28 -0
  31. data/spec/mangaeden_spec.rb +28 -0
  32. data/spec/mangago_spec.rb +28 -0
  33. data/spec/mangahere_spec.rb +28 -0
  34. data/spec/multiplayer_spec.rb +28 -0
  35. data/spec/redblow_spec.rb +28 -0
  36. data/spec/sankakucomplex_spec.rb +41 -0
  37. data/spec/teca_spec.rb +28 -0
  38. data/spec/yande_spec.rb +28 -0
  39. metadata +119 -6
  40. data/lib/dumper/profiles/i_doujin.rb +0 -38
  41. data/lib/dumper/profiles/mi9.rb +0 -44
  42. data/lib/dumper/profiles/wallpaperhere.rb +0 -43
@@ -1,41 +1,55 @@
1
- #--
2
- # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
- #
4
- # This file is part of Dumper.
5
- #
6
- # Dumper is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Dumper is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
- #++
19
-
20
- module Dumper
21
- module Profiles
22
-
23
- def self.get_gelbooru(url, path, from = 1, to = 1)
24
- page = 0
25
- from.upto(to) { |i|
26
- Nokogiri::HTML(open("#{url}&pid=#{page}")).xpath('//span[@class="thumb"]').each { |u|
27
- self.get path, u.child.child['src'].gsub(/thumbnails/, 'images').gsub(/thumbnail_/, '')
28
- }
29
-
30
- page += 63
31
- puts "--- Page #{page} now... ---" # there are so much pages sometimes...
32
- puts
33
- }
34
- end
35
-
36
- def self.info_gelbooru
37
- { :from => true, :to => true }
38
- end
39
-
40
- end
1
+ #--
2
+ # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # This file is part of Dumper.
5
+ #
6
+ # Dumper is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Dumper is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Dumper
21
+ module Profiles
22
+
23
+ class Gelbooru < Profile
24
+ def dump(url, path, from, to)
25
+ page = 0
26
+
27
+ from.upto(to) { |i|
28
+ puts "--- Page #{i} now ---" if Dumper::Profiles.verbose?
29
+
30
+ Nokogiri::HTML(open("#{url}&pid=#{page}")).xpath('//span[@class="thumb"]').each { |u|
31
+ @pool.process {
32
+ Dumper::Profiles.get path, u.child.child['src'].gsub(/thumbnails/, 'images').gsub(/thumbnail_/, '')
33
+ }
34
+ }
35
+
36
+ page += 63
37
+ }
38
+ end
39
+ end
40
+
41
+ class << self
42
+ def get_gelbooru(url, path, from = 1, to = 1)
43
+ Gelbooru.new { |p|
44
+ p.dump url, path, from, to
45
+ p.shutdown
46
+ }
47
+ end
48
+
49
+ def info_gelbooru
50
+ { from: :enabled, to: :enabled, type: :pages }
51
+ end
52
+ end
53
+
54
+ end
41
55
  end
@@ -1,38 +1,56 @@
1
- #--
2
- # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
- #
4
- # This file is part of Dumper.
5
- #
6
- # Dumper is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Dumper is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
- #++
19
-
20
- module Dumper
21
- module Profiles
22
-
23
- def self.get_imagebam(url, path, from = 1, to = 1)
24
- Nokogiri::HTML(open(url)).xpath('//a[@style="border:none; margin:2px;"]/@href').each { |p|
25
- next unless p.to_s.start_with? 'http://www.imagebam.com/image/'
26
-
27
- Nokogiri::HTML(open(p)).xpath('//img[@onclick="scale(this);"]/@src').each { |u|
28
- self.get path, u
29
- }
30
- }
31
- end
32
-
33
- def self.info_imagebam
34
- { :from => false, :to => false }
35
- end
36
-
37
- end
1
+ #--
2
+ # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # This file is part of Dumper.
5
+ #
6
+ # Dumper is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Dumper is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Dumper
21
+ module Profiles
22
+
23
+ class Imagebam < Profile
24
+ def dump(url, path, from, to)
25
+ from -= 1
26
+ to -= 1 if to >= 1
27
+
28
+ [].tap { |urls|
29
+ Nokogiri::HTML(open(url)).xpath('//a[@style="border:none; margin:2px;"]/@href').each { |u|
30
+ urls << u if u.to_s.start_with? 'http://www.imagebam.com/image/'
31
+ }
32
+ }[from..to].each { |p|
33
+ Nokogiri::HTML(open(p)).xpath('//img[@onclick="scale(this);"]/@src').each { |u|
34
+ @pool.process {
35
+ Dumper::Profiles.get path, u
36
+ }
37
+ }
38
+ }
39
+ end
40
+ end
41
+
42
+ class << self
43
+ def get_imagebam(url, path, from = 1, to = -1)
44
+ Imagebam.new { |p|
45
+ p.dump url, path, from, to
46
+ p.shutdown
47
+ }
48
+ end
49
+
50
+ def info_imagebam
51
+ { from: :enabled, to: :enabled, type: :images }
52
+ end
53
+ end
54
+
55
+ end
38
56
  end
@@ -1,54 +1,70 @@
1
- #--
2
- # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
- #
4
- # This file is part of Dumper.
5
- #
6
- # Dumper is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Dumper is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
- #++
19
-
20
- module Dumper
21
- module Profiles
22
-
23
- def self.get_mangaeden(url, path, from = 1, to = 1)
24
- Nokogiri::HTML(open(url)).xpath('//a[@class="chapterLink"]').each { |p|
25
- i = 1
26
-
27
- dir = File.join path, "#{p.children[1].text} - #{p.children[3].text.sanitize_filename}"
28
- Dir.mkdir(dir) unless File.directory? dir
29
-
30
- page = Nokogiri::HTML(open("http://www.mangaeden.com#{p['href']}"))
31
-
32
- page.xpath('//img[@id="mainImg"]/@src').each { |r|
33
- self.get dir, r, '', '', "1.png"
34
- i += 1
35
- }
36
-
37
- page.xpath('//a[@class="ui-state-default"]').each { |q|
38
- next unless q.text.numeric?
39
- q = q['href']
40
-
41
- Nokogiri::HTML(open("http://www.mangaeden.com#{q}")).xpath('//img[@id="mainImg"]/@src').each { |r|
42
- self.get dir, r, '', '', "#{i}.png"
43
- i += 1
44
- }
45
- }
46
- }
47
- end
48
-
49
- def self.info_mangaeden
50
- { :from => false, :to => false }
51
- end
52
-
53
- end
1
+ #--
2
+ # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # This file is part of Dumper.
5
+ #
6
+ # Dumper is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Dumper is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Dumper
21
+ module Profiles
22
+
23
+ class MangaEden < Profile
24
+ def dump(url, path, from, to)
25
+ from -= 1
26
+ to -= 1 if to >= -1
27
+
28
+ Nokogiri::HTML(open(url)).xpath('//a[@class="chapterLink"]').reverse[from..to].each { |p|
29
+ i = 1
30
+
31
+ dir = File.join path, "#{p.children[1].text} - #{p.children[3].text.sanitize_filename}"
32
+ Dir.mkdir(dir) unless File.directory? dir
33
+
34
+ page = Nokogiri::HTML open("http://www.mangaeden.com#{p['href']}")
35
+
36
+ page.xpath('//img[@id="mainImg"]/@src').each { |r|
37
+ Dumper::Profiles.get dir, r, { filename: '1.png' }
38
+ i += 1
39
+ }
40
+
41
+ page.xpath('//a[@class="ui-state-default"]').each { |q|
42
+ next unless q.text.numeric?
43
+ q = q['href']
44
+
45
+ Nokogiri::HTML(open("http://www.mangaeden.com#{q}")).xpath('//img[@id="mainImg"]/@src').each { |r|
46
+ @pool.process {
47
+ Dumper::Profiles.get dir, r, { filename: "#{i}.png" }
48
+ i += 1
49
+ }
50
+ }
51
+ }
52
+ }
53
+ end
54
+ end
55
+
56
+ class << self
57
+ def get_mangaeden(url, path, from = 1, to = -1)
58
+ MangaEden.new { |p|
59
+ p.dump url, path, from, to
60
+ p.shutdown
61
+ }
62
+ end
63
+
64
+ def info_mangaeden
65
+ { from: :enabled, to: :enabled, type: :chapters }
66
+ end
67
+ end
68
+
69
+ end
54
70
  end
@@ -1,41 +1,54 @@
1
- #--
2
- # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
- #
4
- # This file is part of Dumper.
5
- #
6
- # Dumper is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Dumper is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
- #++
19
-
20
- module Dumper
21
- module Profiles
22
-
23
- def self.get_mangago(url, path, from = 1, to = 1)
24
- n_pages = to > 1 ? to : Nokogiri::HTML(open(url)).at_xpath('//div[@class="page_select right"]/div[2]').text.scan(/\d+/).last.to_i
25
-
26
- from.upto(n_pages) { |i|
27
- page = Nokogiri::HTML(open(url))
28
-
29
- url = page.at_xpath('//a[@id="pic_container"]/@href').to_s
30
- scan = page.at_xpath('//img[@id="page1"]/@src').to_s[0..-3]
31
-
32
- self.get path, scan, 'mozilla', url, "#{i}.#{scan.split(?.).last}"
33
- }
34
- end
35
-
36
- def self.info_mangago
37
- { :from => true, :to => true }
38
- end
39
-
40
- end
1
+ #--
2
+ # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # This file is part of Dumper.
5
+ #
6
+ # Dumper is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Dumper is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Dumper
21
+ module Profiles
22
+
23
+ class MangaGo < Profile
24
+ def dump(url, path, from, to)
25
+ n_pages = to > 1 ? to : Nokogiri::HTML(open(url)).at_xpath('//div[@class="page_select right"]/div[2]').text.scan(/\d+/).last.to_i
26
+
27
+ from.upto(n_pages) { |i|
28
+ @pool.process {
29
+ page = Nokogiri::HTML open(url)
30
+
31
+ url = page.at_xpath('//a[@id="pic_container"]/@href').to_s
32
+ scan = page.at_xpath('//img[@id="page1"]/@src').to_s[0..-3]
33
+
34
+ Dumper::Profiles.get path, scan, { referer: url, filename: "#{i}.#{scan.split(?.).last}" }
35
+ }
36
+ }
37
+ end
38
+ end
39
+
40
+ class << self
41
+ def get_mangago(url, path, from = 1, to = 1)
42
+ MangaGo.new { |p|
43
+ p.dump url, path, from, to
44
+ p.shutdown
45
+ }
46
+ end
47
+
48
+ def info_mangago
49
+ { from: :enabled, to: :enabled, type: :images }
50
+ end
51
+ end
52
+
53
+ end
41
54
  end
@@ -1,50 +1,69 @@
1
- #--
2
- # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
- #
4
- # This file is part of Dumper.
5
- #
6
- # Dumper is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Dumper is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
- #++
19
-
20
- module Dumper
21
- module Profiles
22
-
23
- def self.get_mangahere(url, path, from = 1, to = 1)
24
- Nokogiri::HTML(open(url)).xpath('//div[@class="detail_list"]/ul/li').each { |p|
25
- chapter = p.at_xpath('.//span/a/@href').to_s
26
- name = p.at_xpath('.//span/a/text()').to_s.strip
27
- next if chapter.strip.empty?
28
-
29
- dir = File.join path, name.sanitize_filename
30
- Dir.mkdir(dir) unless File.directory? dir
31
-
32
- option = Nokogiri::HTML(open(chapter)).xpath('//select[@class="wid60"]/option')
33
- first = option.first.text.to_i
34
- last = option.last.text.to_i
35
-
36
- first.upto(last) { |i|
37
- url = chapter.gsub(/\/[0-9]+\.html/, '') + i.to_s + '.html'
38
-
39
- scan = Nokogiri::HTML(open(url)).xpath('//section[@id="viewer"]/a/img/@src')[0].to_s
40
- self.get dir, scan, '', '', "#{i}.png"
41
- }
42
- }
43
- end
44
-
45
- def self.info_mangahere
46
- { :from => false, :to => false }
47
- end
48
-
49
- end
1
+ #--
2
+ # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # This file is part of Dumper.
5
+ #
6
+ # Dumper is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Dumper is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Dumper. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Dumper
21
+ module Profiles
22
+
23
+ class MangaHere < Profile
24
+ def dump(url, path, from, to)
25
+ from -= 1
26
+ to -= 1 if to >= -1
27
+
28
+ [].tap { |urls|
29
+ Nokogiri::HTML(open(url)).xpath('//div[@class="detail_list"]/ul/li').each { |u|
30
+ urls << u unless u.at_xpath('.//span/a/@href').to_s.strip.empty?
31
+ }
32
+ }.reverse[from..to].each { |p|
33
+ chapter = p.at_xpath('.//span/a/@href').to_s
34
+ name = p.at_xpath('.//span/a/text()').to_s.strip
35
+
36
+ dir = File.join path, name.sanitize_filename
37
+ Dir.mkdir(dir) unless File.directory? dir
38
+
39
+ option = Nokogiri::HTML(open(chapter)).xpath '//select[@class="wid60"]/option'
40
+ first = option.first.text.to_i
41
+ last = option.last.text.to_i
42
+
43
+ first.upto(last) { |i|
44
+ @pool.process {
45
+ url = chapter.gsub(/\/[0-9]+\.html/, '') + i.to_s + '.html'
46
+
47
+ scan = Nokogiri::HTML(open(url)).xpath('//section[@id="viewer"]/a/img/@src')[0].to_s
48
+ Dumper::Profiles.get dir, scan, { filename: "#{i}.png" }
49
+ }
50
+ }
51
+ }
52
+ end
53
+ end
54
+
55
+ class << self
56
+ def get_mangahere(url, path, from = 1, to = -1)
57
+ MangaHere.new { |p|
58
+ p.dump url, path, from, to
59
+ p.shutdown
60
+ }
61
+ end
62
+
63
+ def info_mangahere
64
+ { from: :enabled, to: :enabled, type: :chapters }
65
+ end
66
+ end
67
+
68
+ end
50
69
  end