directlink 0.0.2.1 → 0.0.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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/bin/directlink +4 -3
- data/directlink.gemspec +2 -2
- data/lib/directlink.rb +23 -23
- data/test.rb +31 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94e6a10d9952f205bc489eaa42d1436ffe056301
|
4
|
+
data.tar.gz: a73b6dfcb083d9859d282fadaa33546555eff83f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb1f018abc6baf2801661cc7bce3fc3f9576e1a2dba1a0ade29a87385e5cfab88c55788764eb48f7c391b1ebfbe642a5dc43569d9677c28aafe1d421ca11b5e6
|
7
|
+
data.tar.gz: f1c0e87195f88c41db05c19eb339e8f4d89f5d7561009a32ff9140f87fabbade85efb952033d5f4316f96296602508afb60130105753313b1fa5c1a5f818a17d
|
data/README.md
CHANGED
@@ -114,9 +114,9 @@ To silent the logger that `DirectLink.imgur` uses:
|
|
114
114
|
```ruby
|
115
115
|
DirectLink.silent = true
|
116
116
|
```
|
117
|
-
You also may look into [`bin/directlink`](bin/directlink) for usage example.
|
117
|
+
You also may look into [`bin/directlink`](bin/directlink) for usage example and the list of all possible exceptions.
|
118
118
|
|
119
|
-
#### about
|
119
|
+
#### about long retries
|
120
120
|
|
121
121
|
Some network exceptions like `SocketError` may be not permanent (local network issues) so `NetHTTPUtils` (that resolves redirect at the beginning of `DirectLink()` call) by default retries exponentially increasing retry delay until it gets to 3600sec, but such exceptions can have permanent reasons like a canceled web domain. To see it:
|
122
122
|
```ruby
|
@@ -139,3 +139,4 @@ SocketError: Failed to open TCP connection to minus.com:80 (getaddrinfo: nodenam
|
|
139
139
|
* the `DirectLink::ErrorAssert` should never happen and you might report it if it does
|
140
140
|
* style: `@@` and lambdas are used to keep things private
|
141
141
|
* this gem is a 2 or 3 libraries merged so don't expect tests to be full and consistent
|
142
|
+
* since 500px.com closed their API in June 2018 the gem uses potentially unreliable undocumented methods
|
data/bin/directlink
CHANGED
@@ -57,13 +57,13 @@ begin
|
|
57
57
|
if json
|
58
58
|
require "json"
|
59
59
|
t = ARGV.map do |link|
|
60
|
-
t = DirectLink link
|
60
|
+
t = DirectLink link, 30
|
61
61
|
t.is_a?(Array) ? t.map(&:to_h) : t.to_h
|
62
62
|
end
|
63
63
|
puts JSON.pretty_generate t.size == 1 ? t.first : t
|
64
64
|
else
|
65
65
|
ARGV.each do |link|
|
66
|
-
t = DirectLink link
|
66
|
+
t = DirectLink link, 30
|
67
67
|
puts "<= #{link}"
|
68
68
|
(t.is_a?(Array) ? t : [t]).each{ |s| puts "=> #{s.url}\n #{s.type} #{s.width}x#{s.height}" }
|
69
69
|
end
|
@@ -77,6 +77,7 @@ rescue NetHTTPUtils::Error,
|
|
77
77
|
DirectLink::ErrorNotFound,
|
78
78
|
DirectLink::ErrorBadLink => e
|
79
79
|
puts e.backtrace if debug
|
80
|
+
cause = e.cause if e.cause if e.respond_to? :cause
|
80
81
|
c = e.class.to_s
|
81
|
-
abort c
|
82
|
+
abort "#{c}#{": #{e}" if c != e.to_s}#{": #{cause}" if cause && c != cause.to_s}"
|
82
83
|
end
|
data/directlink.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "directlink"
|
3
|
-
spec.version = "0.0.
|
3
|
+
spec.version = "0.0.3.0"
|
4
4
|
spec.summary = "converts any kind of image hyperlink to direct link, type of image and its resolution"
|
5
5
|
|
6
6
|
spec.author = "Victor Maslov aka Nakilon"
|
@@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.files = `git ls-files -z`.split(?\0) - spec.test_files
|
21
21
|
|
22
22
|
spec.requirements << "you may need to create apps and provide their API tokens:"
|
23
|
-
spec.requirements << "IMGUR_CLIENT_ID, FLICKR_API_KEY
|
23
|
+
spec.requirements << "IMGUR_CLIENT_ID, FLICKR_API_KEY"
|
24
24
|
end
|
data/lib/directlink.rb
CHANGED
@@ -36,32 +36,33 @@ module DirectLink
|
|
36
36
|
case src
|
37
37
|
# Google Plus post image
|
38
38
|
when /\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[n-r][a-zA-Z0-9_-]{8}I\/AAAAAAAA[bA-V][a-zA-Z0-9]{2}\/[a-zA-Z0-9_-]{32}[gwAQ]CJoC\/)w[1-4]\d\d-h(318|353|727)-n(\/[^\/]+)\z/,
|
39
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_]{11}\/W[a-zA-Z0-9_]{9}I\/AAAAAAAA[a-zA-
|
40
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/
|
39
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_]{11}\/W[a-zA-Z0-9_]{9}I\/AAAAAAAA[a-zA-Z0-9_]{3}\/[a-zA-Z0-9_]{32}[AgwQ]CJoC\/)w239-h318-n(\/[^\/]+)\z/,
|
40
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/W[a-zA-Z0-9_]{9}I\/AAAAAAAAA20\/[a-zA-Z0-9]{32}[Qw]CJoC\/)w212-h318-n(\/[^\/]+)\z/,
|
41
41
|
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAAA_A\/[a-zA-Z0-9_]{32}wCJoC\/)w296-h318-n(\/[^\/]+)\z/,
|
42
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-
|
42
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAAA[ABI][a-z0-9A-Z][a-zA-Z0-9_-]\/[a-zA-Z0-9_-]{32}[gwAQ]CJoC\/)w265-h353-n(\/[^\/]+)\z/,
|
43
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAA[A-Z]{3}\/[a-zA-Z0-9_]{32}wCJoC\/)w346-h195-n-k-no(\/[^\/.]+\.gif)\z/,
|
44
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9-]{11}\/W[a-zA-Z0-9-]{9}I\/AAAAAAAAA_A\/[a-zA-Z0-9]{32}[Qw]CJoC\/)w3\d\d-h318-n(\/[^\/]+)\z/,
|
43
45
|
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9-]{11}\/Wv[a-zA-Z_]{7}AI\/AAAAAAAACkQ\/[a-zA-Z0-9]{32}gCJoC\/)w318-h318-n(\/[^\/]+)\z/,
|
44
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9
|
45
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-
|
46
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAAA[a-zA-Z0-9_]{3}\/[a-zA-Z0-9_-]{32}[gwAQ]CJoC\/)w424-h318-n(\/[^\/]+)\z/,
|
47
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9-]{11}\/Wv[a-zA-Z0-9]{7}PI\/AAAAAAAAC60\/[a-zA-Z0-9-]{32}QCJoC\/)w408-h318-n(\/[^\/]+)\z/,
|
46
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/Wu[a-zA-Z]{7}HI\/AAAAAAAABAI\/[a-zA-Z0-9]{32}QCJoC\/)w398-h318-n(\/[^\/]+)\z/,
|
47
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAAA[a-zA-Z0-9_]{3}\/[a-zA-Z0-9_-]{32}[gwAQ]CJoC\/)w4\d\d-h318-n(\/[^\/]+)\z/,
|
48
48
|
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAA[a-zA-Z0-9_-]{4}\/[a-zA-Z0-9_-]{33}(?:CJoC|CL0B(?:GAs)?)\/)w530(?:-d)?-h[1-9]\d\d-n(\/[^\/]+)\z/,
|
49
49
|
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAA[a-zA-Z]{3}\/[a-zA-Z0-9-]{32}QCJoC\/)w530-h175-n(\/[^\/]+)\z/,
|
50
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_
|
51
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-
|
52
|
-
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAA[A-Z0-9]{3}\/[a-zA-Z0-9_]{32}gCJoC\/)w486-h864-n(\/[^\/]+)\z/
|
50
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAA[A-Z0-9]{3}\/[a-zA-Z0-9_]{32}gCJoC\/)w486-h864-n(\/[^\/]+)\z/,
|
51
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z-]{11}\/W[a-zA-Z-]{9}I\/AAAAAAAA[a-zA-Z]{3}\/[a-zA-Z0-9_-]{32}ACJoC\/)w179-h318-n(\/[^\/]+)\z/
|
53
52
|
"#{$1}s#{width}#{$2}"
|
54
|
-
when /\A(\/\/lh3\.googleusercontent\.com\/proxy\/[a-zA-Z0-9_-]{66,523}=)(?:w(?:464|504|530)-h
|
53
|
+
when /\A(\/\/lh3\.googleusercontent\.com\/proxy\/[a-zA-Z0-9_-]{66,523}=)(?:w(?:464|504|530)-h\d\d\d-[np]|s530-p|s110-p-k)\z/
|
55
54
|
"https:#{$1}s#{width}"
|
56
55
|
when /\A(\/\/lh3\.googleusercontent\.com\/cOh2Nsv7EGo0QbuoKxoKZVZO_NcBzufuvPtzirMJfPmAzCzMtnEncfA7zGIDTJfkc1YZFX2MhgKnjA=)w530-h398-p\z/
|
57
56
|
"https:#{$1}s#{width}"
|
58
|
-
when /\A(\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAA[AC][a-zA-Z0-9]{3}\/[a-zA-Z0-9_-]{32}[
|
59
|
-
/\A(\/\/[
|
57
|
+
when /\A(\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAA[AC][a-zA-Z0-9]{3}\/[a-zA-Z0-9_-]{32}[gwAQ]CJoC\/)w530-h3\d\d-p(\/[^\/]+)\z/,
|
58
|
+
/\A(\/\/[124]\.bp\.blogspot\.com\/-[a-zA-Z0-9_-]{11}\/W[npw][a-zA-Z0-9_-]{8}I\/AAAAAAAA[KDE][a-zA-Z0-9_-]{2}\/[a-zA-Z0-9_-]{33}C(?:Lc|Kg)BGAs\/)w530-h[23]\d\d-p(\/[^\/]+)\z/
|
60
59
|
"https:#{$1}s#{width}#{$2}"
|
61
60
|
when /\A(https:\/\/lh3\.googleusercontent\.com\/-dUQsDY2vWuE\/AAAAAAAAAAI\/AAAAAAAAAAQ\/wVFZagieszU\/)w530-h176-n(\/photo\.jpg)\z/
|
62
61
|
"#{$1}s#{width}#{$2}"
|
63
62
|
# high res Google Plus post image
|
64
|
-
when /\Ahttps:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAA[ABC][a-zA-Z0-9]{3}\/[a-zA-Z0-9_-]{33}CJoC\/s0\/[^\/]+\z
|
63
|
+
when /\Ahttps:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[a-zA-Z0-9_-]{9}I\/AAAAAAA[ABC][a-zA-Z0-9]{3}\/[a-zA-Z0-9_-]{33}CJoC\/s0\/[^\/]+\z/,
|
64
|
+
/\Ahttps:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAA[a-zA-Z_]{3}\/[a-zA-Z0-9]{32}gCJoC\/s0\/[^\/]+\z/,
|
65
|
+
/\Ahttps:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/[a-zA-Z0-9]{10}I\/AAAAAAA[a-zA-Z]{4}\/[a-zA-Z0-9]{32}wCJoC\/s0\/[^\/]+\z/
|
65
66
|
src
|
66
67
|
# Google Plus userpic
|
67
68
|
when /\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9-]{11}\/AAAAAAAAAAI\/AAAAAAAA[a-zA-Z0-9]{3}\/[a-zA-Z0-9_-]{11}\/)s\d\d-p(?:-k)?-rw-no(\/photo\.jpg)\z/
|
@@ -72,6 +73,9 @@ module DirectLink
|
|
72
73
|
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/AAAAAAAAAAI\/AAAAAAAAAAA\/[a-zA-Z0-9]{34}\/)s64-c-mo(\/photo\.jpg)\z/,
|
73
74
|
/\A(https:\/\/lh6\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/AAAAAAAAAAI\/AAAAAAAAAAA\/[a-zA-Z0-9_]{34}\/)s46-c-k-no-mo(\/photo\.jpg)\z/
|
74
75
|
"#{$1}s#{width}#{$2}"
|
76
|
+
# mp4
|
77
|
+
when /\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAAODw\/[a-zA-Z0-9]{32}QCJoC\/)w530-h883-n-k-no(\/[^\/]+\.mp4)\z/
|
78
|
+
"#{$1}s#{width}#{$2}"
|
75
79
|
else
|
76
80
|
raise ErrorBadLink.new src
|
77
81
|
end
|
@@ -150,12 +154,9 @@ module DirectLink
|
|
150
154
|
|
151
155
|
def self._500px link
|
152
156
|
raise ErrorBadLink.new link unless %r{\Ahttps://500px\.com/photo/(?<id>[^/]+)/[^/]+\z} =~ link
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
image_size: 2048,
|
157
|
-
consumer_key: ENV["_500PX_CONSUMER_KEY"],
|
158
|
-
} )["photo"].values_at "width", "height", "image_url", "image_format" # could also get "camera" and "taken_at"
|
157
|
+
w, h = JSON.load(NetHTTPUtils.request_data "https://api.500px.com/v1/photos", form: {ids: id})["photos"].values.first.values_at("width", "height")
|
158
|
+
u, f = JSON.load(NetHTTPUtils.request_data "https://api.500px.com/v1/photos", form: {"image_size[]" => w, "ids" => id})["photos"].values.first["images"].first.values_at("url", "format")
|
159
|
+
[w, h, u, f]
|
159
160
|
end
|
160
161
|
|
161
162
|
def self.flickr link
|
@@ -226,7 +227,7 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil
|
|
226
227
|
# > NetHTTPUtils.logger.level = Logger::DEBUG
|
227
228
|
# > NetHTTPUtils.request_data "http://www.aeronautica.difesa.it/organizzazione/REPARTI/divolo/PublishingImages/6%C2%B0%20Stormo/2013-decollo%20al%20tramonto%20REX%201280.jpg",
|
228
229
|
# max_read_retry_delay: 5, timeout: 5
|
229
|
-
r = NetHTTPUtils.get_response link, header: {"User-Agent" => "Mozilla"}, **(max_redirect_resolving_retry_delay ? {
|
230
|
+
r = NetHTTPUtils.get_response link, header: {"User-Agent" => "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"}, **(max_redirect_resolving_retry_delay ? {
|
230
231
|
max_timeout_retry_delay: max_redirect_resolving_retry_delay,
|
231
232
|
max_sslerror_retry_delay: max_redirect_resolving_retry_delay,
|
232
233
|
max_read_retry_delay: max_redirect_resolving_retry_delay,
|
@@ -266,8 +267,7 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil
|
|
266
267
|
return struct.new u, w, h, f.type
|
267
268
|
end
|
268
269
|
|
269
|
-
f = FastImage.new(link, raise_on_failure: true, http_header: {"User-Agent" => "Mozilla"})
|
270
|
+
f = FastImage.new(link, raise_on_failure: true, http_header: {"User-Agent" => "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"})
|
270
271
|
w, h = f.size
|
271
272
|
struct.new link, w, h, f.type
|
272
|
-
|
273
273
|
end
|
data/test.rb
CHANGED
@@ -82,6 +82,22 @@ describe DirectLink do
|
|
82
82
|
assert DirectLink.google link
|
83
83
|
end
|
84
84
|
end
|
85
|
+
%w{
|
86
|
+
https://lh3.googleusercontent.com/-4pJI5zXoL_k/WvMUBQ6TXMI/AAAAAAAAC60/XRgJlEr5hbgKzYzOQkM8b4_fq2Yp5vNbACJoC/w239-h318-n/%25D0%25B7%25D0%25B0%25D1%2581.jpg
|
87
|
+
https://lh3.googleusercontent.com/-NNYx8cZYF4Y/Wvl8HH7crSI/AAAAAAAAA20/0vaXtOyqDL0DLx841Gj45ePol01OCOAewCJoC/w212-h318-n/DPP_0007.JPG
|
88
|
+
https://lh3.googleusercontent.com/-Y9zbAQDAoH8/WyCS3fapzjI/AAAAAAAAB5M/hKzS0cR0MEgnM-YJENsL7dX8Tbch5Z04wCJoC/w265-h353-n/DSC03805.JPG
|
89
|
+
https://lh3.googleusercontent.com/-cQ1lothweSI/WvMUBS4uAJI/AAAAAAAAC60/tE7aakvztZgTqvRMcrk2FbrauU8LLhGPgCJoC/w239-h318-n/11.jpg
|
90
|
+
https://lh3.googleusercontent.com/-Aiij3wT_v6g/WyCS3VJ-hVI/AAAAAAAAB5M/qeUFKiNXnwkJ-q2q2VoM2f9ukTqPOGhAACJoC/w265-h353-n/DSC03807.JPG
|
91
|
+
//2.bp.blogspot.com/-hBOcNikbjOk/WwlXLbeiF9I/AAAAAAAAKKE/zT7sAlaNYIc7lTxZMY1tyND0u3UH5DuKACLcBGAs/w530-h398-p/EdnjF3yEMM8.jpg
|
92
|
+
https://lh3.googleusercontent.com/-1_J-FT0LhUE/Wx9lWOEXUjI/AAAAAAAAB34/183rqDWZipkaSWyV6qF_Fm7_XQrtYiwdACJoC/w265-h353-n/DSC03800.JPG
|
93
|
+
https://lh3.googleusercontent.com/-I72-Vlk3Ym4/Wx9lWLfINqI/AAAAAAAAB34/EIOySV-4ny8xMECMSC4TvHV43qUn0HLLwCJoC/w265-h353-n/DSC03797.JPG
|
94
|
+
https://lh3.googleusercontent.com/-L-RnjWuqyuI/WxZnv-NRXWI/AAAAAAAARVw/Z3yVnOEDU7kDZ-WbRoLbEh8Tao1_DtQbACJoC/w179-h318-n/20160305_134926.jpg
|
95
|
+
//lh3.googleusercontent.com/-7iXdrlHFM6E/WtRMPtqimXI/AAAAAAAACIo/txJyaoEvnEQu7r2-35SgwFYCWHGmXDQ3QCJoC/w530-h353-p/IMG_3695.jpg
|
96
|
+
}.each_with_index do |link, i| # May contenstants
|
97
|
+
it "another (May) Google Plus community post image ##{i + 1}" do
|
98
|
+
assert DirectLink.google link
|
99
|
+
end
|
100
|
+
end
|
85
101
|
%w{
|
86
102
|
https://lh3.googleusercontent.com/-f37xWyiyP8U/WvmxOxCd-0I/AAAAAAAACpw/3A2tRj02oY40MzJqZBJyWGImoSer0lwMgCJoC/s0/140809%2B029.jpg
|
87
103
|
https://lh3.googleusercontent.com/-1s_eiQB4x2k/WvXQEx59z2I/AAAAAAAAcI0/DvKYzWw3g6UNelqAQdOwrdtYdSEqKgkxwCJoC/s0/001
|
@@ -89,12 +105,22 @@ describe DirectLink do
|
|
89
105
|
https://lh3.googleusercontent.com/-VXUjuSl-dZY/WvK340_E9uI/AAAAAAAAVlg/HqKf1LgUcPUJNrLxHebCMuHhpDRq36_bQCJoC/s0/gplus248254159.jpg
|
90
106
|
https://lh3.googleusercontent.com/-NlZRwcX_Lj8/WvQTijeAfJI/AAAAAAABNyo/jgoDgbZdTvsnLOGmmYlXMr2jL66ieZV4QCJoC/s0/67u8iii.png
|
91
107
|
https://lh3.googleusercontent.com/-8baBz80pf8Y/Wu8KG5lyGhI/AAAAAAACSyU/s3hasZzObK0VlntA1EBj-WBrTRagzRnLQCJoC/s0/%25D0%2592%25D0%25B5%25D1%2581%25D0%25B5%25D0%25BD%25D0%25BD%25D0%25B8%25D0%25B5%2B%25D0%25BA%25D1%2580%25D0%25B0%25D1%2581%25D0%25B0%25D0%25B2%25D1%2586%25D1%258B.JPG
|
92
|
-
|
93
|
-
}.each_with_index do |link, i| # gpluscomm_105636351696833883213_86400
|
108
|
+
}.each_with_index do |link, i|
|
94
109
|
it "already high res image ##{i + 1}" do
|
95
110
|
assert DirectLink.google link
|
96
111
|
end
|
97
112
|
end
|
113
|
+
%w{
|
114
|
+
https://lh3.googleusercontent.com/-5USmSTZHWWI/WMi3q1GdgiI/AAAAAAAAQIA/lu9FTcUL6xMw4wdoW_I148Vm1BtF5mImwCJoC/w346-h195-n-k-no/Good%2BJob.gif
|
115
|
+
https://lh3.googleusercontent.com/-G8eSL3Xx2Kc/WxWt9M6LptI/AAAAAAAAB_c/KNF9RBxjL04Reb3fBtwYLI2AlnLwJ9w7gCJoC/s0/20180602212016_IMG_0244.JPG
|
116
|
+
https://lh3.googleusercontent.com/-aUVoiLNsmAg/WzcsUU2xfNI/AAAAAAAAODw/DOBual6E1rkVLHh3SKZSzbpNQzdEoZPOQCJoC/w530-h883-n-k-no/gplus-1797734754.mp4
|
117
|
+
//lh3.googleusercontent.com/proxy/hOIoIpMEmoVDSP40VRzM92Zw2AeLvEEhxfyKHCOxiNVPyiGvZik5rMvl3jYISLgDJla6mhZuk8pFEYJhX5BU2wy_dw=w530-h822-p
|
118
|
+
https://lh3.googleusercontent.com/-GP3BA3zGR5A/W0IwuVXlfmI/AAAAAAADROs/SH8rRlBDYTsHZiHpM45S3zpEipu5hJ2PwCJoC/s0/%25D1%2582%25D0%25B0%25D0%25B4%25D0%25B6%25D0%25B8%25D0%25BA%25D1%2581%25D0%25BA%25D0%25BE%25D0%25B5%2B%25D1%2580%25D0%25B0%25D0%25B7%25D0%25BD%25D0%25BE%25D1%2582%25D1%2580%25D0%25B0%25D0%25B2%25D1%258C%25D0%25B5.png
|
119
|
+
}.each_with_index do |link, i|
|
120
|
+
it "gpluscomm_105636351696833883213_86400 ##{i + 1}" do
|
121
|
+
assert DirectLink.google link
|
122
|
+
end
|
123
|
+
end
|
98
124
|
%w{
|
99
125
|
//lh3.googleusercontent.com/proxy/S-Z1P92Dd_u0DjYrz5Tb7j0mbZsGjPVffx9lHPQZCqqCFr6vAigCPOG0fEYKU6d-wIvwYr2WriAfh97KjBr9Bq1RKgyHzHq2fpAotTnJYOLd3x_tF2chsGBVuAewE7qp2QDtCYyomyn3dGjZ6cKUnYIC8w=s110-p-k
|
100
126
|
}.each_with_index do |link, i|
|
@@ -242,7 +268,7 @@ describe DirectLink do
|
|
242
268
|
|
243
269
|
[
|
244
270
|
[ :_500px, [
|
245
|
-
["https://500px.com/photo/
|
271
|
+
["https://500px.com/photo/264092015/morning-rider-by-tiger-seo", [1200, 800, "https://drscdn.500px.org/photo/264092015/m%3D1200/v2?webp=true&sig=49c6f8346ba8453ccb17208d4653b9e11bc3e1bb8c21c161047e2842716f3649", "jpeg"]],
|
246
272
|
] ],
|
247
273
|
[ :flickr, [
|
248
274
|
["https://www.flickr.com/photos/tomas-/17220613278/", DirectLink::ErrorNotFound],
|
@@ -426,12 +452,13 @@ describe DirectLink do
|
|
426
452
|
|
427
453
|
describe "fails" do
|
428
454
|
[
|
429
|
-
[1, "http://example.com/", "FastImage::UnknownImageType"],
|
455
|
+
[1, "http://example.com/", "FastImage::UnknownImageType"],
|
430
456
|
[1, "http://example.com/404", "NetHTTPUtils::Error: HTTP error #404 "],
|
431
457
|
[1, "http://imgur.com/HQHBBBD", "DirectLink::ErrorMissingEnvVar: define IMGUR_CLIENT_ID env var", " && unset IMGUR_CLIENT_ID"], # TODO: make similar test for ./lib
|
432
458
|
# by design it should be impossible to write a test for DirectLink::ErrorAssert
|
433
459
|
[1, "https://flic.kr/p/DirectLinkErrorNotFound", "NetHTTPUtils::Error: HTTP error #404 "],
|
434
460
|
[1, "https://imgur.com/a/badlinkpattern", "NetHTTPUtils::Error: HTTP error #404 "],
|
461
|
+
# TODO: a test that it appends the `exception.cause`
|
435
462
|
].each_with_index do |(expected_exit_code, link, expected_output, unset), i|
|
436
463
|
it "##{i + 1}" do
|
437
464
|
string, status = Open3.capture2e "export #{File.read("api_tokens_for_travis.sh").gsub(/\n?export/, ?\s).strip}#{unset} && bundle exec ruby bin/directlink #{link}"
|
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.
|
4
|
+
version: 0.0.3.0
|
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: 2018-
|
11
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nethttputils
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements:
|
94
94
|
- 'you may need to create apps and provide their API tokens:'
|
95
|
-
- IMGUR_CLIENT_ID, FLICKR_API_KEY
|
95
|
+
- IMGUR_CLIENT_ID, FLICKR_API_KEY
|
96
96
|
rubyforge_project:
|
97
97
|
rubygems_version: 2.5.2
|
98
98
|
signing_key:
|