image-dumper 0.7.8 → 0.7.9
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.
- checksums.yaml +4 -4
- data/lib/dumper/dumper.rb +13 -8
- data/lib/dumper/logger.rb +5 -5
- data/lib/dumper/version.rb +1 -1
- data/spec/teca_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 540402d705c54203cf18d899ee74a5f9c4873920
|
|
4
|
+
data.tar.gz: 102783104ecaa46a5623fbf4d4af9e0a09ecd625
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e600b4a39246d6471e7a58b9082cdadc58122e92746b889565f6d409812d175afb7bb9dd73509dcc808d0dd136c26827efa860fc6e161855b04a079d6c2e6af1
|
|
7
|
+
data.tar.gz: 88679f502090a13679ee8884a3ef363a2b06fe8bac7eb2847ebb6d01e57459c8df6e59b7a01e73feef824f11835a24e7111ace88865418f62dcbd1ca8ce3b8d1
|
data/lib/dumper/dumper.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright(C)
|
|
2
|
+
# Copyright(C) 2015 Giovanni Capuano <webmaster@giovannicapuano.net>
|
|
3
3
|
#
|
|
4
4
|
# This file is part of Dumper.
|
|
5
5
|
#
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
#++
|
|
19
19
|
|
|
20
20
|
module Dumper
|
|
21
|
-
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.
|
|
21
|
+
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0'
|
|
22
22
|
|
|
23
23
|
def pool_size
|
|
24
24
|
{
|
|
@@ -94,21 +94,26 @@ module Dumper
|
|
|
94
94
|
notify_observers error: "File #{filename} already exists."
|
|
95
95
|
else
|
|
96
96
|
filename = File.join(path, rand(1000).to_s + '.jpg') unless filename[-4] == ?. || filename[-5] == ?.
|
|
97
|
-
notify_observers status: "Downloading #{url} as #{filename}..."
|
|
98
97
|
|
|
99
|
-
url.prepend('http:') if url.start_with?('//')
|
|
100
|
-
uri = URI(url)
|
|
101
98
|
http_options = {
|
|
102
99
|
'User-Agent' => options[:user_agent] || USER_AGENT,
|
|
103
100
|
'Referer' => options[:referer ] || url
|
|
104
101
|
}
|
|
105
102
|
|
|
106
|
-
http
|
|
103
|
+
url.prepend('http:') if url.start_with?('//')
|
|
104
|
+
uri = URI(url)
|
|
105
|
+
|
|
106
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
107
107
|
http.use_ssl = uri.scheme == 'https'
|
|
108
108
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
http.start do |h|
|
|
111
|
+
notify_observers status: "Downloading #{url} as #{filename}..."
|
|
112
|
+
response = h.request Net::HTTP::Get.new(uri.request_uri, http_options)
|
|
113
|
+
|
|
114
|
+
File.open(filename, 'wb') do |f|
|
|
115
|
+
f.write response.body
|
|
116
|
+
end
|
|
112
117
|
end
|
|
113
118
|
end
|
|
114
119
|
end
|
data/lib/dumper/logger.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#--
|
|
2
|
-
# Copyright(C)
|
|
2
|
+
# Copyright(C) 2015 Giovanni Capuano <webmaster@giovannicapuano.net>
|
|
3
3
|
#
|
|
4
4
|
# This file is part of Dumper.
|
|
5
5
|
#
|
|
@@ -27,11 +27,11 @@ module Dumper
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def log_on_file(file, data)
|
|
30
|
-
File.open(file, ?a)
|
|
31
|
-
data.each
|
|
30
|
+
File.open(file, ?a) do |file|
|
|
31
|
+
data.each do |status, message|
|
|
32
32
|
file.puts status == :critical_error_dump ? message.inspect : message
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def log_on_screen(data)
|
data/lib/dumper/version.rb
CHANGED
data/spec/teca_spec.rb
CHANGED
|
@@ -14,7 +14,7 @@ describe 'Dumper' do
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it 'dumps a page from teca' do
|
|
17
|
-
url = '
|
|
17
|
+
url = 'https://alfateam123.nwa.xyz/screens/anime_screens/sakura%20trick/index.html'
|
|
18
18
|
Dumper::Profiles.get_teca url, @dir, 1, 4
|
|
19
19
|
|
|
20
20
|
images = Dir["#{@dir}/*"]
|
|
@@ -25,4 +25,4 @@ describe 'Dumper' do
|
|
|
25
25
|
|
|
26
26
|
expect(image.first).to be 1280
|
|
27
27
|
end
|
|
28
|
-
end
|
|
28
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: image-dumper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Giovanni Capuano
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|