pulse-downloader 0.1.22 → 0.1.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pulse/downloader/version.rb +1 -1
- data/lib/pulse/downloader/web_page_parser.rb +9 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e354feaf3ad68d91b2b58b1410ad297582ace9b6f3493b17cf8ae11d11c18d8d
|
4
|
+
data.tar.gz: 3e036681abb31307b958bba6038d1fda3a9634195d71c61af3e8896bd695b22a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf401b59b944a0bdca308998c19f4c8b996fadf60cc8118c06a909b5eaa1ca98d9f0f3d234af7050ce71611475d8f9a9c4a79503003649870a5d7f18dc62caa0
|
7
|
+
data.tar.gz: 98bd01ea727425dad6a932fd431c241b023d954134827ac781faab9b90559a3d05c75916eb4e0bf99d4f8f4c4244b2ce7b019df8ced9c474ad8efe18fa4e7e7d
|
@@ -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) +
|
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
|
|