pulse-downloader 0.1.22 → 0.1.23

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
  SHA256:
3
- metadata.gz: 00f53bf497e8c65d6211956814fa94613857b23bc0b1e3f35c24d69998645941
4
- data.tar.gz: 77447e1a3b1df593d5c836074c41e6caa57fef28f8926a5f7e1859fb1b58b39d
3
+ metadata.gz: e354feaf3ad68d91b2b58b1410ad297582ace9b6f3493b17cf8ae11d11c18d8d
4
+ data.tar.gz: 3e036681abb31307b958bba6038d1fda3a9634195d71c61af3e8896bd695b22a
5
5
  SHA512:
6
- metadata.gz: 627db0d3d117a199943ba7ade0c27af871f4934e6879bb788fcade5946b95bfa0378d237fb5eee0f68685cf211b042a3b35986441466b0d6811875fe7103304f
7
- data.tar.gz: 1f7c99a75487b6c615cb94bd8def2ed1f5316036339318244329648be8800dc5ab867a8022e956e1a46ac0e0cb58f4502030453c7efadd7131d7edbb69a5a538
6
+ metadata.gz: cf401b59b944a0bdca308998c19f4c8b996fadf60cc8118c06a909b5eaa1ca98d9f0f3d234af7050ce71611475d8f9a9c4a79503003649870a5d7f18dc62caa0
7
+ data.tar.gz: 98bd01ea727425dad6a932fd431c241b023d954134827ac781faab9b90559a3d05c75916eb4e0bf99d4f8f4c4244b2ce7b019df8ced9c474ad8efe18fa4e7e7d
@@ -1,5 +1,5 @@
1
1
  module Pulse
2
2
  module Downloader
3
- VERSION = "0.1.22"
3
+ VERSION = "0.1.23"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  module Pulse
2
2
  module Downloader
3
3
  module WebPageParser
4
- def fetch_file_paths
4
+ def fetch_file_paths(custom_path_root=nil)
5
5
  @start_time = get_micro_second_time
6
6
 
7
7
  response = HTTParty.get(url, verify: verify_ssl)
@@ -12,29 +12,30 @@ module Pulse
12
12
  print_time
13
13
  end
14
14
 
15
- extract_file_urls(response)
15
+ extract_file_urls(response, custom_path_root)
16
16
  end
17
17
 
18
18
  private
19
19
 
20
- def extract_file_urls(response)
20
+ def extract_file_urls(response, custom_path_root)
21
21
  return [] if response.body.nil? || response.body.empty?
22
22
  (
23
- extract_download_links(response) + extract_embedded_images(response)
23
+ extract_download_links(response, custom_path_root) +
24
+ extract_embedded_images(response, custom_path_root)
24
25
  ).uniq
25
26
  end
26
27
 
27
- def extract_download_links(response)
28
+ def extract_download_links(response, custom_path_root)
28
29
  parse_html(response.body)
29
30
  .css('a')
30
31
  .to_a
31
32
  .map { |link| link['href'] }
32
33
  .compact
33
- .select { |link| link.include? file_type }
34
+ .select { |link| (link.include? file_type || link.include?(custom_path_root)) }
34
35
  .map { |link| add_base_url(link) }
35
36
  end
36
37
 
37
- def extract_embedded_images(response)
38
+ def extract_embedded_images(response, custom_path_root)
38
39
  return [] unless scrape_images
39
40
 
40
41
  parse_html(response.body)
@@ -42,7 +43,7 @@ module Pulse
42
43
  .to_a
43
44
  .map { |e| e["src"] }
44
45
  .compact
45
- .select { |link| link.include? file_type }
46
+ .select { |link| (link.include? file_type || link.include?(custom_path_root)) }
46
47
  .map { |link| add_base_url(link) }
47
48
  end
48
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulse-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22