directlink 0.0.8.2 → 0.0.8.3
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 +9 -2
- data/test.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9a00064d05aec6e194936e1a81293ae29073b41
|
4
|
+
data.tar.gz: 12d300df0d51e0e755825c8ce420d2908d88f05a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 596a735c0df1de3450efc323bd6a650c6f3540e3f4956a36c06c584ce5c7e3a53c156c30ae63b929f56247073da431acf0be782132592264ef4c6a6839b98bba
|
7
|
+
data.tar.gz: 1f0e9853ca750d9ef2f7713ee6f6586c6af5348f3253186fceaf46d2b360a0a8a1e5b9193c99f9b77e84eb293de6aa11574d89c80c8c3f131edd8250a4b98da3
|
data/directlink.gemspec
CHANGED
data/lib/directlink.rb
CHANGED
@@ -243,7 +243,11 @@ module DirectLink
|
|
243
243
|
|
244
244
|
def self.vk link
|
245
245
|
id, mtd, field, f = case link
|
246
|
-
when %r{\Ahttps://vk\.com/id(?<user_id>\d+)\?z=photo(?<id>\k<user_id>_\d+)(%
|
246
|
+
when %r{\Ahttps://vk\.com/id(?<user_id>\d+)\?z=photo(?<id>\k<user_id>_\d+)(%2F(album\k<user_id>_0|photos\k<user_id>))\z},
|
247
|
+
%r{\Ahttps://vk\.com/photo(?<_>)(?<id>-?\d+_\d+)(\?all=1)?\z},
|
248
|
+
%r{\Ahttps://vk\.com/feed\?section=likes&z=photo(?<_>)(?<id>-(?<user_id>\d+)_\d+)%2F(liked\d+|album\k<user_id>_0)\z},
|
249
|
+
%r{\Ahttps://vk\.com/[a-z]+\?z=photo(?<_>)(?<id>(?<user_id>-\d+)_\d+)%2F(wall\k<user_id>_\d+|album\k<user_id>_0)\z},
|
250
|
+
%r{\Ahttps://vk\.com/wall(?<user_id>-\d+)_\d+\?z=photo(?<id>\k<user_id>_\d+)%2F(wall\k<user_id>_\d+|album\k<user_id>_00%2Frev|917c43448c0780da71)\z}
|
247
251
|
[$2, :photos, :photos, lambda do |t|
|
248
252
|
raise ErrorAssert.new "our knowledge about VK API seems to be outdated" unless 1 == t.size
|
249
253
|
t.first
|
@@ -263,7 +267,10 @@ module DirectLink
|
|
263
267
|
f.call( JSON.load( NetHTTPUtils.request_data "https://api.vk.com/method/#{mtd}.getById",
|
264
268
|
:POST, form: { field => id, :access_token => ENV["VK_ACCESS_TOKEN"], :client_secret => ENV["VK_CLIENT_SECRET"], :v => "5.101" }
|
265
269
|
).fetch("response") ).fetch("sizes").map do |s|
|
266
|
-
s.values_at
|
270
|
+
s.values_at("width", "height", "url").tap do |whu|
|
271
|
+
w, h, u = whu
|
272
|
+
whu[0, 2] = FastImage.new(u, raise_on_failure: true).size if [w, h].include? 0
|
273
|
+
end
|
267
274
|
end.max_by{ |w, h, u| w * h }
|
268
275
|
end
|
269
276
|
|
data/test.rb
CHANGED
@@ -395,9 +395,15 @@ describe DirectLink do
|
|
395
395
|
["https://www.reddit.com/r/hangers/comments/97you5/tara_radovic/", [true, "https://i.imgur.com/rbLqgOu.jpg"]], # "crossport" from Imgur
|
396
396
|
] ],
|
397
397
|
[ :vk, [
|
398
|
-
["https://vk.com/id57030827?z=photo57030827_456241143", [1920, 1440, "https://sun9-66.userapi.com/c845322/v845322944/167836/bP9z41BybhI.jpg"]],
|
399
|
-
["https://vk.com/id57030827?z=photo57030827_456241143%2Falbum57030827_0", [1920, 1440, "https://sun9-66.userapi.com/c845322/v845322944/167836/bP9z41BybhI.jpg"]],
|
400
398
|
["https://vk.com/wall-105984091_7806", [960, 1280, "https://sun9-41.userapi.com/c855224/v855224900/a72f1/7OZ8ux9Wcwo.jpg"]],
|
399
|
+
["https://vk.com/id57030827?z=photo57030827_456241143%2Falbum57030827_0", [1920, 1440, "https://sun9-66.userapi.com/c845322/v845322944/167836/bP9z41BybhI.jpg"]],
|
400
|
+
["https://vk.com/wall-185182611_454?z=photo-185182611_457239340%2Fwall-185182611_454", [1280, 960, "https://sun9-46.userapi.com/c851028/v851028578/1a62f6/VB4SdR1O6Tg.jpg"]],
|
401
|
+
["https://vk.com/wall-105984091_7946?z=photo-105984091_457243312%2Falbum-105984091_00%2Frev", [1280, 875, "https://sun9-37.userapi.com/c852020/v852020134/1b6b36/0IsDFb-Hda4.jpg"]],
|
402
|
+
["https://vk.com/photo533531776_456239427?all=1", [750, 938, "https://sun9-25.userapi.com/c849416/v849416600/14b949/V01Ch1gYjhc.jpg"]],
|
403
|
+
["https://vk.com/photo-155488973_456242404", [1486, 1000, "https://sun9-7.userapi.com/c852132/v852132877/8578e/m6AJWiskiKE.jpg"]],
|
404
|
+
["https://vk.com/id2272074?z=photo2272074_264578776%2Fphotos2272074", [604, 484, "https://sun9-10.userapi.com/c10472/u2272074/-7/x_407b2ba2.jpg"]],
|
405
|
+
["https://vk.com/feed?section=likes&z=photo-117564754_456261460%2Fliked3902406", [1024, 1335, "https://sun9-72.userapi.com/c854028/v854028353/895b6/izQJresLdf0.jpg"]],
|
406
|
+
["https://vk.com/likizimy?z=photo-42543351_456239941%2Fwall-42543351_1908", [1179, 1731, "https://sun9-47.userapi.com/c855036/v855036571/60f7b/ryCPJIMyMkI.jpg"]],
|
401
407
|
] ],
|
402
408
|
].each do |method, tests|
|
403
409
|
describe method do
|
@@ -452,7 +458,6 @@ describe DirectLink do
|
|
452
458
|
],
|
453
459
|
vk: [
|
454
460
|
"https://vk.com/id57030827?z=photo57030827_456241143",
|
455
|
-
"https://vk.com/wall-105984091_7806",
|
456
461
|
],
|
457
462
|
}.each do |method, tests|
|
458
463
|
describe "DirectLink() calls #{method}" do
|