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,39 +1,49 @@
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_behoimi(url, path, from = 1, to = 1)
24
- ua = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0'
25
- ref = url
26
-
27
- from.upto(to) { |i|
28
- Nokogiri::HTML(open("#{url}&page=#{i}", 'User-Agent' => ua, 'Referer' => ref)).xpath('//img[@class="preview "]/@src').each { |p|
29
- self.get path, p.to_s.gsub('preview/', ''), ua, ref
30
- }
31
- }
32
- end
33
-
34
- def self.info_behoimi
35
- { :from => true, :to => true }
36
- end
37
-
38
- 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 Behoimi < Profile
24
+ def dump(url, path, from, to)
25
+ from.upto(to) { |i|
26
+ Nokogiri::HTML(open("#{url}&page=#{i}", 'User-Agent' => Dumper::Profiles::USER_AGENT, 'Referer' => url)).xpath('//img[@class="preview "]/@src').each { |p|
27
+ @pool.process {
28
+ Dumper::Profiles.get path, p.to_s.gsub('preview/', ''), { referer: url }
29
+ }
30
+ }
31
+ }
32
+ end
33
+ end
34
+
35
+ class << self
36
+ def get_behoimi(url, path, from = 1, to = 1)
37
+ Behoimi.new { |p|
38
+ p.dump url, path, from, to
39
+ p.shutdown
40
+ }
41
+ end
42
+
43
+ def info_behoimi
44
+ { from: :enabled, to: :enabled, type: :images }
45
+ end
46
+ end
47
+
48
+ end
39
49
  end
@@ -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_booru(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(/thumbs/, 'img').gsub(/thumbnails\//, 'images/').gsub(/thumbnail_/, '')
28
- }
29
-
30
- page += 20
31
- puts "--- Page #{page} now... ---" # there are so much pages sometimes...
32
- puts
33
- }
34
- end
35
-
36
- def self.info_booru
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 Booru < Profile
24
+ def dump(url, path, from, to)
25
+ page = 0
26
+
27
+ from.upto(to) { |i|
28
+ puts "--- Page #{i} ---" 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(/thumbs/, 'img').gsub(/thumbnails\//, 'images/').gsub(/thumbnail_/, '')
33
+ }
34
+ }
35
+
36
+ page += 40
37
+ }
38
+ end
39
+ end
40
+
41
+ class << self
42
+ def get_booru(url, path, from = 1, to = 1)
43
+ Booru.new { |p|
44
+ p.dump url, path, from, to
45
+ p.shutdown
46
+ }
47
+ end
48
+
49
+ def info_booru
50
+ { from: :enabled, to: :enabled, type: :pages }
51
+ end
52
+ end
53
+
54
+ end
41
55
  end
@@ -1,34 +1,50 @@
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_deviantart(url, path, from = 1, to = 1)
24
- Nokogiri::HTML(open(url)).xpath('//a[@class="thumb"]').each { |u|
25
- self.get path, u['data-super-img']
26
- }
27
- end
28
-
29
- def self.info_deviantart
30
- { :from => false, :to => false }
31
- end
32
-
33
- 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 DeviantArt < 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="thumb"]')[from..to].each { |u|
29
+ @pool.process {
30
+ Dumper::Profiles.get path, u['data-super-img']
31
+ }
32
+ }
33
+ end
34
+ end
35
+
36
+ class << self
37
+ def get_deviantart(url, path, from = 1, to = -1)
38
+ DeviantArt.new { |p|
39
+ p.dump url, path, from, to
40
+ p.shutdown
41
+ }
42
+ end
43
+
44
+ def info_deviantart
45
+ { from: :enabled, to: :enabled, type: :images }
46
+ end
47
+ end
48
+
49
+ end
34
50
  end
@@ -1,52 +1,62 @@
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_fakku(url, path, from = 1, to = 999)
24
- url += '/read' unless url.end_with? '/read'
25
- errors = 0
26
-
27
- cdn = open(url).read.split('window.params.thumbs')[1].split('\/thumbs\/')[0].gsub(/\\\//m, ?/)[5..-1] + '/images/'
28
-
29
- ua = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0'
30
- ref = url
31
-
32
- from.upto(to) { |i|
33
- return if errors == 10
34
-
35
- file = "%03d.jpg" % i
36
- filename = "#{cdn}#{file}"
37
-
38
- unless self.get path, URI.parse(URI.encode(filename, '[]')), ua, ref
39
- errors += 1
40
-
41
- file = File.join(path, file).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
42
- File.delete(file) if File.exists? file
43
- end
44
- }
45
- end
46
-
47
- def self.info_fakku
48
- { :from => true, :to => true }
49
- end
50
-
51
- 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 Fakku < Profile
24
+ def dump(url, path, from, to)
25
+ url += '/read' unless url.end_with? '/read'
26
+ errors = 0
27
+
28
+ cdn = open(url).read.split('window.params.thumbs')[1].split('\/thumbs\/')[0].gsub(/\\\//m, ?/)[5..-1] + '/images/'
29
+
30
+ from.upto(to) { |i|
31
+ return if errors == 10
32
+
33
+ file = "%03d.jpg" % i
34
+ filename = "#{cdn}#{file}"
35
+
36
+ @pool.process {
37
+ unless Dumper::Profiles.get path, URI.parse(URI.encode(filename, '[]')), { referer: url }
38
+ errors += 1
39
+
40
+ file = File.join(path, file).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
41
+ File.delete(file) if File.exists? file
42
+ end
43
+ }
44
+ }
45
+ end
46
+ end
47
+
48
+ class << self
49
+ def get_fakku(url, path, from = 1, to = 999)
50
+ Fakku.new { |p|
51
+ p.dump url, path, from, to
52
+ p.shutdown
53
+ }
54
+ end
55
+
56
+ def info_fakku
57
+ { from: :enabled, to: :enabled, type: :images }
58
+ end
59
+ end
60
+
61
+ end
52
62
  end
@@ -1,34 +1,50 @@
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_fc2(url, path, from = 1, to = 1)
24
- Nokogiri::HTML(open(url)).xpath('//a[@target="_blank"]/@href').each { |p|
25
- self.get(path, p) if p.to_s.end_with?('jpg') || p.to_s.end_with?('png')
26
- }
27
- end
28
-
29
- def self.info_fc2
30
- { :from => false, :to => false }
31
- end
32
-
33
- 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 Fc2 < 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[@target="_blank"]/@href')[from..to].each { |p|
29
+ @pool.process {
30
+ Dumper::Profiles.get(path, p) if p.to_s.end_with?('jpg') || p.to_s.end_with?('png')
31
+ }
32
+ }
33
+ end
34
+ end
35
+
36
+ class << self
37
+ def get_fc2(url, path, from = 1, to = -1)
38
+ Fc2.new { |p|
39
+ p.dump url, path, from, to
40
+ p.shutdown
41
+ }
42
+ end
43
+
44
+ def info_fc2
45
+ { from: :enabled, to: :enabled, type: :images }
46
+ end
47
+ end
48
+
49
+ end
34
50
  end