directlink 0.0.1.3 → 0.0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bashrc +2 -0
- data/README.md +5 -7
- data/directlink.gemspec +1 -1
- data/lib/directlink.rb +19 -3
- data/test.rb +39 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8258c6815f7a12da63eeaff0285360e0c6b1ab1a
|
4
|
+
data.tar.gz: 1b019e7af135c1a565d8624a9bc51434ab3eb727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3862cd9c7083cfa54056257966e6a3c2152665b9c0eeee9633efcdf7f485580b6f6caeb128bd983dfe50738b27c16312f27e4b4200b99831f8f033586158e848
|
7
|
+
data.tar.gz: d0a9bd786a60e334908d17bcbdbbc40bbaca78e448921d24dc9fa4bb9cb0f396d9f812f8bea82dbbc3304dfed15e9a0900faee6ced4ec7edf1a1a04386326f65
|
data/.bashrc
ADDED
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# gem directlink
|
5
5
|
|
6
|
-
This tool
|
6
|
+
This tool converts any sort of image hyperlink (a thumbnail URL, a link to an album, etc.) to a high resolution one. Also it tells the resulting resolution and the image type (format). I wanted such automation often so I made a gem with a binary.
|
7
7
|
|
8
8
|
## Usage
|
9
9
|
|
@@ -16,8 +16,7 @@ $ gem install directlink
|
|
16
16
|
$ directlink
|
17
17
|
usage: directlink [--debug] [--json] [--github] <link1> <link2> <link3> ...
|
18
18
|
```
|
19
|
-
Converts `<img src=` attribute value from any (current regexes are very strict and
|
20
|
-
) Google web service to its high resolution version:
|
19
|
+
Converts `<img src=` attribute value from any Google web service (current Google regexes are very strict and may often fail -- it is a [defensive programming](https://en.wikipedia.org/wiki/Defensive_programming) practice -- report me your links!) to the largest available:
|
21
20
|
```
|
22
21
|
$ directlink //4.bp.blogspot.com/-5kP8ndL0kuM/Wpt82UCqvmI/AAAAAAAAEjI/ZbbZWs0-kgwRXEJ9JEGioR0bm6U8MOkvQCKgBGAs/w530-h278-p/IMG_20171223_093922.jpg
|
23
22
|
<= //4.bp.blogspot.com/-5kP8ndL0kuM/Wpt82UCqvmI/AAAAAAAAEjI/ZbbZWs0-kgwRXEJ9JEGioR0bm6U8MOkvQCKgBGAs/w530-h278-p/IMG_20171223_093922.jpg
|
@@ -82,7 +81,7 @@ Downloads master:HEAD version of `lib/directlink.rb` from GitHub and uses it onc
|
|
82
81
|
```
|
83
82
|
$ directlink --github https://imgur.com/a/oacI3gl
|
84
83
|
```
|
85
|
-
When
|
84
|
+
When an image hosting with known API is recognized, the API will be used and you'll have to create app there and provide env vars:
|
86
85
|
```
|
87
86
|
$ export IMGUR_CLIENT_ID=0f99cd781...
|
88
87
|
$ export FLICKR_API_KEY=dc2bfd348b...
|
@@ -107,7 +106,7 @@ irb> pp DirectLink "https://imgur.com/a/oacI3gl"
|
|
107
106
|
height=100,
|
108
107
|
type="image/png">]
|
109
108
|
```
|
110
|
-
Google can serve image in arbitrary resolution so `DirectLink.google` has optional argument to specify the desired width:
|
109
|
+
Google can serve image in arbitrary resolution so `DirectLink.google` has an optional argument to specify the desired width:
|
111
110
|
```
|
112
111
|
irb> DirectLink.google "//4.bp.blogspot.com/-5kP8ndL0kuM/Wpt82UCqvmI/AAAAAAAAEjI/ZbbZWs0-kgwRXEJ9JEGioR0bm6U8MOkvQCKgBGAs/w530-h278-p/IMG_20171223_093922.jpg", 100
|
113
112
|
=> "https://4.bp.blogspot.com/-5kP8ndL0kuM/Wpt82UCqvmI/AAAAAAAAEjI/ZbbZWs0-kgwRXEJ9JEGioR0bm6U8MOkvQCKgBGAs/s100/IMG_20171223_093922.jpg"
|
@@ -138,7 +137,6 @@ SocketError: Failed to open TCP connection to minus.com:80 (getaddrinfo: nodenam
|
|
138
137
|
|
139
138
|
* `module DirectLink` public methods return different sets of properties -- `DirectLink()` unites them
|
140
139
|
* the `DirectLink::ErrorAssert` should never happen and you might report it if it does
|
141
|
-
* style: all exceptions should be classified as `DirectLink::Error*` or `FastImage::*`
|
142
140
|
* style: `@@` and lambdas are used to keep things private
|
143
|
-
* resolution of 500px.com photo is that you get via Pro membership, not that
|
141
|
+
* resolution of 500px.com photo is that you get via Pro membership, not that URL really provides
|
144
142
|
* this gem is a 2 or 3 libraries merged so don't expect tests to be full and consistent
|
data/directlink.gemspec
CHANGED
data/lib/directlink.rb
CHANGED
@@ -36,13 +36,29 @@ 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-
|
39
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z]{11}\/W[a-zA-Z0-9]{8}II\/AAAAAAAACkQ\/[a-zA-Z0-9_]{28}AXNkwCJoC\/)w239-h318-n(\/[^\/]+)\z/,
|
40
|
+
/\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[2-9]\d\d-n(\/[^\/]+)\z/,
|
41
|
+
/\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/,
|
42
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9_-]{11}\/W[a-zA-Z0-9]{9}I\/AAAAAAAA[ABI][a-zA-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-Z]{8}[DMV_]I\/AAAAAAAA[a-zA-Z]{3}\/[a-zA-Z0-9_]{32}[wQ]CJoC\/)w239-h318-n(\/[^\/]+)\z/,
|
44
|
+
/\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/,
|
45
|
+
/\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}\/Wv[a-zA-Z0-9]{7}_I\/AAAAAAAAA20\/[a-zA-Z0-9]{32}QCJoC\/)w212-h318-n(\/[^\/]+)\z/,
|
47
|
+
/\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/,
|
48
|
+
/\A(https:\/\/lh3\.googleusercontent\.com\/-[a-zA-Z0-9]{11}\/Wt[a-zA-Z]{7}mI\/AAAAAAAAmBQ\/[a-zA-Z0-9]{32}QCJoC\/)w530-h150-n(\/[^\/]+)\z/
|
40
49
|
"#{$1}s#{width}#{$2}"
|
41
|
-
when /\A(\/\/lh3\.googleusercontent\.com\/proxy\/[a-zA-Z0-9_-]{66,523}=)(?:w(?:464|504|530)-h[2-7]\d\d-[np]|s530-p)\z/
|
50
|
+
when /\A(\/\/lh3\.googleusercontent\.com\/proxy\/[a-zA-Z0-9_-]{66,523}=)(?:w(?:464|504|530)-h[2-7]\d\d-[np]|s530-p|s110-p-k)\z/
|
42
51
|
"https:#{$1}s#{width}"
|
43
|
-
when /\A(\/\/lh3\.googleusercontent\.com
|
52
|
+
when /\A(\/\/lh3\.googleusercontent\.com\/cOh2Nsv7EGo0QbuoKxoKZVZO_NcBzufuvPtzirMJfPmAzCzMtnEncfA7zGIDTJfkc1YZFX2MhgKnjA=)w530-h398-p\z/
|
53
|
+
"https:#{$1}s#{width}"
|
54
|
+
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}[gwA]CJoC\/)w530-h3\d\d-p(\/[^\/]+)\z/,
|
44
55
|
/\A(\/\/[14]\.bp\.blogspot\.com\/-[a-zA-Z0-9_-]{11}\/W[np][a-zA-Z0-9_-]{8}I\/AAAAAAAA[DE][a-zA-Z0-9_-]{2}\/[a-zA-Z0-9_-]{33}C(?:Lc|Kg)BGAs\/)w530-h278-p(\/[^\/]+)\z/
|
45
56
|
"https:#{$1}s#{width}#{$2}"
|
57
|
+
when /\A(https:\/\/lh3\.googleusercontent\.com\/-dUQsDY2vWuE\/AAAAAAAAAAI\/AAAAAAAAAAQ\/wVFZagieszU\/)w530-h176-n(\/photo\.jpg)\z/
|
58
|
+
"#{$1}s#{width}#{$2}"
|
59
|
+
# high res Google Plus post image
|
60
|
+
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/
|
61
|
+
src
|
46
62
|
# Google Plus userpic
|
47
63
|
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/
|
48
64
|
"#{$1}s#{width}#{$2}"
|
data/test.rb
CHANGED
@@ -43,8 +43,45 @@ describe DirectLink do
|
|
43
43
|
783 https://lh3.googleusercontent.com/-SqAvt_F__bg/Wq0huHcX2NI/AAAAAAAAVj0/XfnwCU7JwhUh0Knw8rcXA-bhpKYkI4hdwCJoC/w358-h318-n/IMG_20180317_120218-01-01.jpeg
|
44
44
|
830 https://lh3.googleusercontent.com/-VB3YlLVL_tQ/Wo21yTbKl_I/AAAAAAAAApU/3DURmsYBklcv0kif2ZRjhoLG4mTHYf8OwCJoC/w254-h318-n/180218_00001.jpg
|
45
45
|
1002 https://lh3.googleusercontent.com/-d8FkfLWq-_4/WpQXzEfFgBI/AAAAAAAADww/J32xKSAYUkgIc3pyrZnNmRec6kjdnJBHgCJoC/w239-h318-n/gplus-485739203.jpg
|
46
|
-
".scan(/(\S+) (\S+)/).each do |i, link|
|
47
|
-
it "Google Plus post image ##{i}" do
|
46
|
+
".scan(/(\S+) (\S+)/).each do |i, link| # some pre-May-2018 urls dump from a community
|
47
|
+
it "Google Plus community post image ##{i}" do
|
48
|
+
DirectLink.google link
|
49
|
+
end
|
50
|
+
end
|
51
|
+
%w{
|
52
|
+
https://lh3.googleusercontent.com/-dUQsDY2vWuE/AAAAAAAAAAI/AAAAAAAAAAQ/wVFZagieszU/w530-h176-n/photo.jpg
|
53
|
+
//lh3.googleusercontent.com/cOh2Nsv7EGo0QbuoKxoKZVZO_NcBzufuvPtzirMJfPmAzCzMtnEncfA7zGIDTJfkc1YZFX2MhgKnjA=w530-h398-p
|
54
|
+
//lh3.googleusercontent.com/-0Vt5HFpPTVQ/Wnh02Jb4SFI/AAAAAAAAbCU/MtusII6-FcgxuHQWofAaWF01IBUVykMyACJoC/w530-h351-p/DSC_3804%2B-%2B%25D0%25BA%25D0%25BE%25D0%25BF%25D0%25B8%25D1%258F.JPG
|
55
|
+
https://lh3.googleusercontent.com/-u3yxaS-b85c/WvOtHJn-DxI/AAAAAAAAAKg/A_PoO64o0VkX1erPKebiO7Xcs5Iy3idbACJoC/w424-h318-n/IMG_20180510_082023.jpg
|
56
|
+
https://lh3.googleusercontent.com/-K2XODEFntJY/Wvl8HLwfF_I/AAAAAAAAA20/mqOtMCFuBkkvtv7jdpVkJv2XSXlOLoXVQCJoC/w212-h318-n/DPP_0006.JPG
|
57
|
+
https://lh3.googleusercontent.com/-702a8U4EIiw/WuxqzXHQCHI/AAAAAAAABAI/rA0R2UsbxoswvH6nSePnwa5VHG2f5kNOQCJoC/w398-h318-n/Fox-Desktop-1024x1280.jpg
|
58
|
+
https://lh3.googleusercontent.com/-YQFXT62-1OA/WvMUBWXI0PI/AAAAAAAAC60/gdtkQz9YI0knYkFB8VjC2CpKOD6-Zs6hQCJoC/w408-h318-n/%25D0%25BF%25D0%25BE%25D1%2581.jpg
|
59
|
+
https://lh3.googleusercontent.com/--P4MRZpGk-A/WveQe_YKbAI/AAAAAAAACkQ/eTz2maXvw7A0iKoPjfuwEgfTiZS3a3HSgCJoC/w318-h318-n/gplus1165736192.jpg
|
60
|
+
https://lh3.googleusercontent.com/-CH2N9uhwMOg/WtOxVJ1DNxI/AAAAAAAAMGs/pJf8awKJcyMFlx2g89p9_QjqlyQDmYMmACJoC/w424-h318-n/DSC03178.JPG
|
61
|
+
https://lh3.googleusercontent.com/-NGME5H7fY1o/WtaUJCaDGmI/AAAAAAAAmBQ/jZhatiBmHPEiAAABcY2DoJ6KuzVBvqGxQCJoC/w530-h150-n/%25D0%25A1%25D0%25BD%25D0%25B8%25D0%25BC%25D0%25BE%25D0%25BA%2B%25D1%258D%25D0%25BA%25D1%2580%25D0%25B0%25D0%25BD%25D0%25B0%2B2018-04-18%2B%25D0%25B2%2B3.32.42.png
|
62
|
+
https://lh3.googleusercontent.com/-40QwR_c58sw/WsLyS3a8uhI/AAAAAAAAAas/ojaQoF1-ZFIboOS6c5kLs7bOl_TAOU6oACJoC/w424-h318-n/271091.jpg
|
63
|
+
https://lh3.googleusercontent.com/-XhWuVCyNBjY/WvOtHOyaj_I/AAAAAAAAAKo/gOAn__a75NwYSgaBaEBGeCTAFI9MyjqlwCJoC/w239-h318-n/IMG_20180510_081956.jpg
|
64
|
+
}.each_with_index do |link, i| # March contenstants
|
65
|
+
it "another Google Plus community post image ##{i + 1}" do
|
66
|
+
DirectLink.google link
|
67
|
+
end
|
68
|
+
end
|
69
|
+
%w{
|
70
|
+
https://lh3.googleusercontent.com/-f37xWyiyP8U/WvmxOxCd-0I/AAAAAAAACpw/3A2tRj02oY40MzJqZBJyWGImoSer0lwMgCJoC/s0/140809%2B029.jpg
|
71
|
+
https://lh3.googleusercontent.com/-1s_eiQB4x2k/WvXQEx59z2I/AAAAAAAAcI0/DvKYzWw3g6UNelqAQdOwrdtYdSEqKgkxwCJoC/s0/001
|
72
|
+
https://lh3.googleusercontent.com/-1Rcbffs4iRI/WvaSsRCrxJI/AAAAAAAAcJs/e-N9tmjaTCIxEBE_jXwFjiYPyZXFwh4owCJoC/s0/001
|
73
|
+
https://lh3.googleusercontent.com/-VXUjuSl-dZY/WvK340_E9uI/AAAAAAAAVlg/HqKf1LgUcPUJNrLxHebCMuHhpDRq36_bQCJoC/s0/gplus248254159.jpg
|
74
|
+
https://lh3.googleusercontent.com/-NlZRwcX_Lj8/WvQTijeAfJI/AAAAAAABNyo/jgoDgbZdTvsnLOGmmYlXMr2jL66ieZV4QCJoC/s0/67u8iii.png
|
75
|
+
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
|
76
|
+
}.each_with_index do |link, i| # gpluscomm_105636351696833883213_86400
|
77
|
+
it "already high res image ##{i + 1}" do
|
78
|
+
DirectLink.google link
|
79
|
+
end
|
80
|
+
end
|
81
|
+
%w{
|
82
|
+
//lh3.googleusercontent.com/proxy/S-Z1P92Dd_u0DjYrz5Tb7j0mbZsGjPVffx9lHPQZCqqCFr6vAigCPOG0fEYKU6d-wIvwYr2WriAfh97KjBr9Bq1RKgyHzHq2fpAotTnJYOLd3x_tF2chsGBVuAewE7qp2QDtCYyomyn3dGjZ6cKUnYIC8w=s110-p-k
|
83
|
+
}.each_with_index do |link, i|
|
84
|
+
it "posted_website_preview_##{i + 1}" do
|
48
85
|
DirectLink.google link
|
49
86
|
end
|
50
87
|
end
|
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.1.
|
4
|
+
version: 0.0.1.4
|
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-05-
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nethttputils
|
@@ -59,6 +59,7 @@ executables:
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".bashrc"
|
62
63
|
- ".travis.yml"
|
63
64
|
- Gemfile
|
64
65
|
- LICENSE
|