directlink 0.0.8.4 → 0.0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/directlink.gemspec +1 -1
- data/lib/directlink.rb +10 -7
- 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: e62e48e14056c1b1ab1c34049bc1e4137ca77239
|
4
|
+
data.tar.gz: 405b2ee26671bf02bcc118dd4ae985ba99d545db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b171d73b0edd1ad7b7e7cab84bf78c82916044858c9fdbd0c8dabfd6cba6a00d6b03db9ef6ac84a001e82f769cbd8df4142f30295aab1670dcfe22700cca812
|
7
|
+
data.tar.gz: ffddae00c3c62fa43ea4ce3050def2347d1010e908f1da28a886d72e39ce3c62f4202f5343180f4869523023f832e5be7f40231344baf30fc6510da03c427a50
|
data/directlink.gemspec
CHANGED
data/lib/directlink.rb
CHANGED
@@ -275,7 +275,7 @@ end
|
|
275
275
|
|
276
276
|
require "fastimage"
|
277
277
|
|
278
|
-
def DirectLink link,
|
278
|
+
def DirectLink link, timeout = nil, giveup: false, ignore_meta: false
|
279
279
|
ArgumentError.new("link should be a <String>, not <#{link.class}>") unless link.is_a? String
|
280
280
|
begin
|
281
281
|
URI link
|
@@ -313,10 +313,10 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil, giveup: false, ig
|
|
313
313
|
**( %w{ reddit com } == URI(link).host.split(?.).last(2) ||
|
314
314
|
%w{ redd it } == URI(link).host.split(?.) ? {Cookie: "over18=1"} : {} ),
|
315
315
|
}
|
316
|
-
head = NetHTTPUtils.request_data link, :head, header: header, **(
|
317
|
-
timeout:
|
318
|
-
max_start_http_retry_delay:
|
319
|
-
max_read_retry_delay:
|
316
|
+
head = NetHTTPUtils.request_data link, :head, header: header, **(timeout ? {
|
317
|
+
timeout: timeout,
|
318
|
+
max_start_http_retry_delay: timeout,
|
319
|
+
max_read_retry_delay: timeout
|
320
320
|
} : {})
|
321
321
|
rescue Net::ReadTimeout
|
322
322
|
rescue NetHTTPUtils::Error => e
|
@@ -370,7 +370,7 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil, giveup: false, ig
|
|
370
370
|
f = ->_{ _.type == :a ? _.attr["href"] : _.children.flat_map(&f) }
|
371
371
|
require "kramdown"
|
372
372
|
return f[Kramdown::Document.new(u).root].map do |sublink|
|
373
|
-
DirectLink URI.join(link, sublink).to_s,
|
373
|
+
DirectLink URI.join(link, sublink).to_s, timeout, giveup: giveup
|
374
374
|
end
|
375
375
|
end
|
376
376
|
return struct.new *u.values_at(*%w{ fallback_url width height }), "video" if u.is_a? Hash
|
@@ -391,7 +391,10 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil, giveup: false, ig
|
|
391
391
|
rescue FastImage::UnknownImageType
|
392
392
|
raise if giveup
|
393
393
|
require "nokogiri"
|
394
|
-
head = NetHTTPUtils.request_data link, :head, header: {"User-Agent" => "Mozilla"}
|
394
|
+
head = NetHTTPUtils.request_data link, :head, header: {"User-Agent" => "Mozilla"},
|
395
|
+
max_start_http_retry_delay: timeout,
|
396
|
+
timeout: timeout, # NetHTTPUtild passes this as read_timeout to Net::HTTP.start
|
397
|
+
max_read_retry_delay: timeout # and then compares accumulated delay to this
|
395
398
|
# if we use :get here we will download megabytes of files just to giveup on content_type we can't process
|
396
399
|
case head.instance_variable_get(:@last_response).content_type
|
397
400
|
when "text/html" ; nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: directlink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.8.
|
4
|
+
version: 0.0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov aka Nakilon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastimage
|