directlink 0.0.4.12 → 0.0.4.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bc1a52faf9ff54f576c21584edbc5d42c8405fd
4
- data.tar.gz: abc2e62a2db58972cc717989b6d05cf75cda938b
3
+ metadata.gz: 14f2adc0cf8da9dfce19145a8f06ed28c8393555
4
+ data.tar.gz: c952263512c3d1c467c287fa7e30245b9a88e844
5
5
  SHA512:
6
- metadata.gz: '0340192fbfc460f8c649df463fb8a78058ea9cb75696fc9c46cac807dcef7f739f9f60b3b5c91a2ee2e5ff4efeb7132480dfd961ff8481cd863ba4823a23c8d9'
7
- data.tar.gz: e3d6520baf1b1c89c9afec9e88553fa3d4eeeb8f8bdd7d9e6ebaeb614b9b5e72030f1ece436374dc561f30888076b5a351a305a7784825e098f2019535c60f4e
6
+ metadata.gz: 1e1ebcd757a4baed3ce59de52ba1c23a9c8546f849991e75b513971546b4a41ec08869e95907aaece5dc98f8308c2ed8b2941d71e778257e21d590cdecd83a62
7
+ data.tar.gz: bdff382c7ea916ec43b3f7d8a03804b11d33d43963a218c706de43011e2e1f5923aa2a88bb2d0f7f919c1945518564d5e6d87a7840468a78604e991813d59164
data/.travis.yml CHANGED
@@ -17,10 +17,21 @@ rvm:
17
17
  - jruby-head
18
18
  matrix:
19
19
  allow_failures:
20
+
20
21
  # NetHTTPUtils does not pass query params or smth
21
22
  - rvm: jruby-head
22
23
  os: osx
23
- # the "Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m" output at jruby start ruins binstub tests
24
+
25
+ # the 'Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m' output at jruby start ruins binstub tests
24
26
  # TODO: -W0 does not help but probably there is another option or I should patch tests for jruby
25
27
  - rvm: jruby-head
26
28
  os: linux
29
+
30
+ # the 'The command "bundle install --jobs=3 --retry=3" failed and exited with 1 during .'
31
+ # I guess Travis is deprecating old Rubies and so will I
32
+ - rvm: 2.0
33
+ os: linux
34
+ - rvm: 2.1
35
+ os: linux
36
+ - rvm: 2.2
37
+ os: linux
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.4.12"
3
+ spec.version = "0.0.4.13"
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"
data/lib/directlink.rb CHANGED
@@ -195,7 +195,7 @@ module DirectLink
195
195
  attr_accessor :reddit_bot
196
196
  end
197
197
  def self.reddit link, timeout = 1000
198
- unless id = URI(link).path[/\A(?:\/r\/[0-9a-zA-Z_]+)?(?:\/comments)?\/([0-9a-z]{5,6})(?:\/|\z)/, 1]
198
+ unless id = URI(link).path[/\A(?:\/r\/[0-9a-zA-Z_]+)?(?:\/comments|\/duplicates)?\/([0-9a-z]{5,6})(?:\/|\z)/, 1]
199
199
  raise DirectLink::ErrorBadLink.new link unless URI(link).host &&
200
200
  URI(link).host.split(?.) == %w{ i redd it } &&
201
201
  URI(link).path[/\A\/[a-z0-9]{12,13}\.(gif|jpg)\z/]
@@ -337,7 +337,7 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil, giveup = false
337
337
  end
338
338
  end
339
339
  return struct.new *u.values_at(*%w{ fallback_url width height }), "video" if u.is_a? Hash
340
- link = u
340
+ return DirectLink u
341
341
  rescue DirectLink::ErrorMissingEnvVar
342
342
  end if %w{ reddit com } == URI(link).host.split(?.).last(2) ||
343
343
  %w{ redd it } == URI(link).host.split(?.)
@@ -348,6 +348,7 @@ def DirectLink link, max_redirect_resolving_retry_delay = nil, giveup = false
348
348
  raise if giveup
349
349
  require "nokogiri"
350
350
  head = NetHTTPUtils.request_data link, :head, header: {"User-Agent" => "Mozilla"}
351
+ # if we use :get here we will download megabytes of files just to giveup on content_type we can't process
351
352
  case head.instance_variable_get(:@last_response).content_type
352
353
  when "text/html" ; nil
353
354
  else ; raise
data/test.rb CHANGED
@@ -376,6 +376,7 @@ describe DirectLink do
376
376
  ["https://reddit.com/123456", [true, "https://i.ytimg.com/vi/b9upM4RbIeU/hqdefault.jpg"]],
377
377
  ["https://www.reddit.com/r/travel/988889", [true, "https://i.redd.it/3h5xls6ehrg11.jpg"]],
378
378
  ["http://redd.it/988889", [true, "https://i.redd.it/3h5xls6ehrg11.jpg"]],
379
+ ["https://www.reddit.com/r/CatsStandingUp/duplicates/abn0ua/cat/", [true, "https://v.redd.it/s9b86afb6w721/DASH_2_4_M?source=fallback"]],
379
380
  ] ],
380
381
  ].each do |method, tests|
381
382
  describe method do
@@ -470,6 +471,7 @@ describe DirectLink do
470
471
  assert_equal 3, tries
471
472
  end
472
473
  it "Reddit correctly parses out id when no token provided" do
474
+ # this URL isn't supposed to not throw exception -- FastImage does not handle this media type (see the next test)
473
475
  t = ENV.delete "REDDIT_SECRETS"
474
476
  FastImage.stub :new, lambda{ |link, *|
475
477
  assert_equal "https://v.redd.it/2tyovczka8m11/DASH_4_8_M?source=fallback", 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.12
4
+ version: 0.0.4.13
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-02-02 00:00:00.000000000 Z
11
+ date: 2019-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastimage