mangdown 0.14.1 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 087f4e2f6ce88163a9edb3f661b8cfaacdab3056
4
- data.tar.gz: bb4f4ac0cd6c9b8197c99d982b7df0daf8826875
3
+ metadata.gz: 8f61dfdfea20214539cb4f4ef676aca5dadbbf02
4
+ data.tar.gz: 4bad97970c5889d3e0f6be782efbc93387d6af00
5
5
  SHA512:
6
- metadata.gz: f8e9352f01b656133205c0e3ae98f4f9f1cbe04313c2a8b4131d2bdf20016f495d90d6472e895c8e7e67f095f68cc88e35f4d34e291af6265861c914891fc331
7
- data.tar.gz: 717a840d6823ae74e27be19c0eb95e916d572fdc248d25c19b5565c6e95bf34c60e55b316a88264025e24a6b906f3fa69e4ff74fc40dfdab0d8699ffca5c7c56
6
+ metadata.gz: c29430c607fd9de1f654ef11631e5cf7ae6cbe21f3a4f34b36d59a074b5955aa1f0f2fa153b4dfadf7e2dc4f64cedc90e0f0805c019f0784a3b686b7e8e7fe5a
7
+ data.tar.gz: 8d0bfe6dd9dbbe1cafe1297430f9e4f11e263bdf3dd1eede206bdf83139ea0da7edae7224a5af59df2f1c04e0dc82ebaa76c5c9de8182e4a4ae24bb03f512915
@@ -23,6 +23,10 @@ module Mangdown
23
23
  self.class.site
24
24
  end
25
25
 
26
+ def hydra_opts
27
+ {}
28
+ end
29
+
26
30
  # Overwrite if you want to check the uri if it belongs to a manga list
27
31
  def is_manga_list?(uri = @uri)
28
32
  raise NotImplementedError
@@ -56,7 +56,7 @@ module Mangdown
56
56
  setup_download_dir!(dir)
57
57
  end
58
58
 
59
- Tools.hydra_streaming(pages) do |stage, page, data = nil|
59
+ Tools.hydra_streaming(pages, adapter.hydra_opts) do |stage, page, data = nil|
60
60
  case stage
61
61
  when :failed
62
62
  failed << page
@@ -93,7 +93,7 @@ module Mangdown
93
93
  def fetch_each_page
94
94
  pages = build_page_hashes
95
95
  page_data = Hash.new { |h, k| h[k] = "" }
96
- Tools.hydra_streaming(pages) do |status, page, data=nil|
96
+ Tools.hydra_streaming(pages, adapter.hydra_opts) do |status, page, data=nil|
97
97
  case status
98
98
  when :before
99
99
  true
@@ -1,6 +1,8 @@
1
1
  require 'pathname'
2
2
  require 'typhoeus'
3
3
 
4
+ Typhoeus::Config.verbose = $DEBUG
5
+
4
6
  module Mangdown
5
7
  module Tools
6
8
  class << self
@@ -39,13 +41,13 @@ module Mangdown
39
41
  mime_to_extension(mime)
40
42
  end
41
43
 
42
- def hydra_streaming(objects)
43
- hydra = Typhoeus::Hydra.hydra
44
+ def hydra_streaming(objects, hydra_opts = {})
45
+ hydra = Typhoeus::Hydra.new(hydra_opts)
44
46
 
45
47
  requests = objects.map { |obj|
46
48
  next unless yield(:before, obj)
47
49
 
48
- request = Typhoeus::Request.new(obj.uri)
50
+ request = typhoeus(obj.uri)
49
51
  request.on_headers do |response|
50
52
  status = response.success? ? :succeeded : :failed
51
53
  yield(status, obj)
@@ -65,6 +67,16 @@ module Mangdown
65
67
  requests
66
68
  end
67
69
 
70
+ def typhoeus(uri)
71
+ Typhoeus::Request.new(uri, typhoeus_options)
72
+ end
73
+
74
+ def typhoeus_options
75
+ {
76
+ headers: { "User-Agent" => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36' }
77
+ }
78
+ end
79
+
68
80
  private
69
81
 
70
82
  def mime_to_extension(mime)
@@ -1,3 +1,3 @@
1
1
  module Mangdown
2
- VERSION = "0.14.1"
2
+ VERSION = "0.15.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jphager2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-05 00:00:00.000000000 Z
11
+ date: 2017-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.5.1
167
+ rubygems_version: 2.6.13
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Download Manga