ero_getter 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/ero_getter.gemspec +8 -2
- data/lib/downloader/gazou_sokuhou.rb +21 -0
- data/lib/downloader/wakuteka_sokuhou.rb +17 -0
- data/lib/ero_getter/base.rb +23 -9
- data/spec/downloader/gazou_sokuhou_spec.rb +18 -0
- data/spec/downloader/wakuteka_sokuhou_spec.rb +16 -0
- data/spec/ero_getter/base_spec.rb +14 -0
- data/spec/samples/gazou_sokuhou/sample.html +1732 -0
- data/spec/samples/wakuteka_sokuhou/sample.html +1647 -0
- metadata +9 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
data/ero_getter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ero_getter"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["masarakki"]
|
12
|
-
s.date = "2012-06-
|
12
|
+
s.date = "2012-06-02"
|
13
13
|
s.description = "ero getter"
|
14
14
|
s.email = "masaki@hisme.net"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,21 +28,27 @@ Gem::Specification.new do |s|
|
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
30
|
"ero_getter.gemspec",
|
31
|
+
"lib/downloader/gazou_sokuhou.rb",
|
31
32
|
"lib/downloader/nijigazou_sokuhou.rb",
|
32
33
|
"lib/downloader/pm_style.rb",
|
34
|
+
"lib/downloader/wakuteka_sokuhou.rb",
|
33
35
|
"lib/ero_getter.rb",
|
34
36
|
"lib/ero_getter/base.rb",
|
35
37
|
"lib/ero_getter/utils.rb",
|
38
|
+
"spec/downloader/gazou_sokuhou_spec.rb",
|
36
39
|
"spec/downloader/nijigazou_sokuhou_spec.rb",
|
37
40
|
"spec/downloader/pm_style_spec.rb",
|
41
|
+
"spec/downloader/wakuteka_sokuhou_spec.rb",
|
38
42
|
"spec/ero_getter/base_spec.rb",
|
39
43
|
"spec/ero_getter_spec.rb",
|
44
|
+
"spec/samples/gazou_sokuhou/sample.html",
|
40
45
|
"spec/samples/nijigazou_sokuhou/first.html",
|
41
46
|
"spec/samples/nijigazou_sokuhou/global_last.html",
|
42
47
|
"spec/samples/nijigazou_sokuhou/last.html",
|
43
48
|
"spec/samples/nijigazou_sokuhou/middle.html",
|
44
49
|
"spec/samples/pm_style/test.html",
|
45
50
|
"spec/samples/sample.html",
|
51
|
+
"spec/samples/wakuteka_sokuhou/sample.html",
|
46
52
|
"spec/spec_helper.rb"
|
47
53
|
]
|
48
54
|
s.homepage = "http://github.com/masarakki/ero_getter"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class GazouSokuhou < EroGetter::Base
|
3
|
+
|
4
|
+
name 'がぞー速報'
|
5
|
+
url %r{http://stalker.livedoor.biz/archives/\d+.html}
|
6
|
+
|
7
|
+
target "img.pict" do |path|
|
8
|
+
if path.parent.name == "a" && path.parent[:href] =~ /jpe?g|gif|png$/
|
9
|
+
path.parent[:href]
|
10
|
+
else
|
11
|
+
path[:src]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
sub_directory do
|
16
|
+
url.match(/(\d+).html/)[1]
|
17
|
+
end
|
18
|
+
|
19
|
+
filename { |attr| "%04d%s" % [attr[:index], attr[:ext]] }
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class WakutekaSokuhou < EroGetter::Base
|
3
|
+
|
4
|
+
name 'わくてか速報'
|
5
|
+
url %r{http://blog.livedoor.jp/wakusoku/archives/(\d+).html}
|
6
|
+
|
7
|
+
target ".article-body-inner a > img" do |path|
|
8
|
+
path.parent[:href] if path.parent[:href] =~ /jpe?g|gif|png$/
|
9
|
+
end
|
10
|
+
|
11
|
+
sub_directory do
|
12
|
+
url.match(/(\d+)\.html/)[1]
|
13
|
+
end
|
14
|
+
|
15
|
+
filename {|attr| "%04d%s" % [attr[:index], attr[:ext]] }
|
16
|
+
|
17
|
+
end
|
data/lib/ero_getter/base.rb
CHANGED
@@ -44,11 +44,11 @@ class EroGetter::Base
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def run
|
47
|
-
targets.
|
47
|
+
targets.each_with_index do |target_url, index|
|
48
48
|
if target_url =~ /.*\.zip$/
|
49
|
-
save_zip(target_url)
|
49
|
+
save_zip(target_url, index)
|
50
50
|
else
|
51
|
-
save_image(target_url)
|
51
|
+
save_image(target_url, index)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
self.class.new(self.prev, :prev).run if run_prev?
|
@@ -61,16 +61,16 @@ class EroGetter::Base
|
|
61
61
|
response
|
62
62
|
end
|
63
63
|
|
64
|
-
def save_image(target_url)
|
65
|
-
|
64
|
+
def save_image(target_url, index)
|
65
|
+
_filename = filename(File.basename(target_url), index)
|
66
66
|
response = get_target(target_url)
|
67
|
-
File.open(File.join(directory,
|
67
|
+
File.open(File.join(directory, _filename), "wb") {|f| f.write response.body }
|
68
68
|
end
|
69
69
|
|
70
|
-
def save_zip(target_url)
|
70
|
+
def save_zip(target_url, index)
|
71
71
|
response = get_target(target_url)
|
72
|
-
unzip(response.body).each do |
|
73
|
-
File.open(File.join(directory,
|
72
|
+
unzip(response.body).each do |_filename, data|
|
73
|
+
File.open(File.join(directory, _filename), "wb") {|f| f.write data }
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
@@ -135,6 +135,12 @@ class EroGetter::Base
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
138
|
+
|
139
|
+
def filename(&block)
|
140
|
+
define_method(:_filename) do |attr|
|
141
|
+
yield(attr)
|
142
|
+
end
|
143
|
+
end
|
138
144
|
end
|
139
145
|
|
140
146
|
private
|
@@ -145,4 +151,12 @@ class EroGetter::Base
|
|
145
151
|
def run_prev?
|
146
152
|
direction != :next && respond_to?(:prev) && self.prev != nil
|
147
153
|
end
|
154
|
+
|
155
|
+
def filename(basename, index)
|
156
|
+
if respond_to?(:_filename)
|
157
|
+
_filename(index: index, basename: basename, ext: File.extname(basename))
|
158
|
+
else
|
159
|
+
basename
|
160
|
+
end
|
161
|
+
end
|
148
162
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe GazouSokuhou do
|
5
|
+
let(:url) { 'http://stalker.livedoor.biz/archives/51977311.html' }
|
6
|
+
subject { @dl }
|
7
|
+
|
8
|
+
before do
|
9
|
+
EroGetter.stub(:mkdir)
|
10
|
+
@dl = GazouSokuhou.new(url)
|
11
|
+
fake(:get, url, 'gazou_sokuhou/sample.html')
|
12
|
+
end
|
13
|
+
its(:name) { should == 'がぞー速報' }
|
14
|
+
its(:title) { should == '6月になったし2次水着画像どんどん貼ってくよー - がぞ~速報' }
|
15
|
+
its(:base_dir) { should == 'gazou_sokuhou' }
|
16
|
+
its(:sub_directory) { should == '51977311' }
|
17
|
+
its("targets.count") { should == 31 }
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe WakutekaSokuhou do
|
5
|
+
let(:url) { 'http://blog.livedoor.jp/wakusoku/archives/1461175.html' }
|
6
|
+
subject { @dl }
|
7
|
+
before do
|
8
|
+
EroGetter.stub(:mkdir)
|
9
|
+
@dl = WakutekaSokuhou.new(url)
|
10
|
+
fake(:get, url, 'wakuteka_sokuhou/sample.html')
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:title) { should == 'わくてか速報 : 【エロ画像】抜かずにはいられない虹エロ画像パート1194【詳細付き】 - livedoor Blog(ブログ)' }
|
14
|
+
its(:sub_directory) { should == '1461175' }
|
15
|
+
its("targets.count") { should == 37 }
|
16
|
+
end
|
@@ -48,6 +48,7 @@ describe EroGetter::Base do
|
|
48
48
|
'https://github.com/masarakki/ero_getter_chrome_extension'] }
|
49
49
|
its(:sub_directory) { should == 'ero_getter_server/ero_getter_chrome_extension' }
|
50
50
|
its(:directory) { should == '/tmp/test_class/ero_getter_server/ero_getter_chrome_extension' }
|
51
|
+
it { subject.send(:filename, "hogehoge.jpg", 1).should == 'hogehoge.jpg' }
|
51
52
|
|
52
53
|
describe :after_run do
|
53
54
|
context :not_set_after do
|
@@ -152,4 +153,17 @@ describe EroGetter::Base do
|
|
152
153
|
its(:next) { should == 'unko' }
|
153
154
|
end
|
154
155
|
end
|
156
|
+
context :with_filename do
|
157
|
+
before do
|
158
|
+
_regex = regex
|
159
|
+
klazz = Class.new(EroGetter::Base) do
|
160
|
+
url _regex
|
161
|
+
filename do |attr|
|
162
|
+
"%04d%s" % [attr[:index], attr[:ext]]
|
163
|
+
end
|
164
|
+
end
|
165
|
+
@dl = klazz.new(url)
|
166
|
+
end
|
167
|
+
it { @dl.send(:filename, 'hogehoge.jpg', 0).should == '0000.jpg' }
|
168
|
+
end
|
155
169
|
end
|