pulse-downloader 0.1.34 → 0.1.35
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/client.rb +3 -1
- data/lib/pulse/downloader/version.rb +1 -1
- data/lib/pulse/downloader/web_page_parser.rb +22 -1
- 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: df940062ab2c0dcdc96b256b76e8198683776d7bdb834198c0f75da85d5e63fb
|
4
|
+
data.tar.gz: 158f5746ceb0d820934e126cae7ca53dfca0a841ae8a588b2b955c85de5abc7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2494b72940a92e4b13fc44c8c9c81ff63e48a35940e9bcc6437235afdd4c1ca2fdc43098b71f976ce42d5fa65b53979aa3b055b511c91c1ca6b0ff64a0dd472c
|
7
|
+
data.tar.gz: 1c40920e57fdbb4184034cc91953f82c5babf1c09146027b9b887b1bac5d8b45f4e386b21133bd44625f8adb8843daac8b4652e35e94ebf25188738d02d8a36c
|
@@ -22,7 +22,8 @@ module Pulse
|
|
22
22
|
:end_time,
|
23
23
|
:progress_bar,
|
24
24
|
:base_url,
|
25
|
-
:file_paths
|
25
|
+
:file_paths,
|
26
|
+
:folder_urls
|
26
27
|
|
27
28
|
# Does not continue downloads-
|
28
29
|
# Will only save once the file has been downloaded in memory
|
@@ -60,6 +61,7 @@ module Pulse
|
|
60
61
|
@progress_bar = progress_bar
|
61
62
|
|
62
63
|
@base_url = get_base_url
|
64
|
+
@folder_urls = []
|
63
65
|
end
|
64
66
|
|
65
67
|
def call!
|
@@ -14,10 +14,23 @@ module Pulse
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def fetch_folders(base_url)
|
17
|
+
current_paths = extract_hrefs(get_response(folder_url), custom_path_root)
|
18
|
+
return unless current_paths.compact.size > 0
|
17
19
|
|
20
|
+
@folder_urls = folder_urls.union(current_paths).uniq.compact
|
21
|
+
|
22
|
+
current_paths.each do |path|
|
23
|
+
fetch_folders(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
folder_urls
|
18
27
|
end
|
19
28
|
|
20
29
|
def fetch_and_parse_response(folder_url, custom_path_root)
|
30
|
+
parse_response(get_response(folder_url), custom_path_root, file_type)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_response(folder_url)
|
21
34
|
@start_time = get_micro_second_time
|
22
35
|
|
23
36
|
response = HTTParty.get(folder_url, verify: verify_ssl, headers: headers)
|
@@ -28,7 +41,7 @@ module Pulse
|
|
28
41
|
print_time
|
29
42
|
end
|
30
43
|
|
31
|
-
|
44
|
+
response
|
32
45
|
end
|
33
46
|
|
34
47
|
def parse_response(response, custom_path_root, file_type)
|
@@ -51,6 +64,14 @@ module Pulse
|
|
51
64
|
).uniq
|
52
65
|
end
|
53
66
|
|
67
|
+
def extract_hrefs(response, custom_path_root)
|
68
|
+
parse_html(response.body)
|
69
|
+
.css('a')
|
70
|
+
.map { |link| link['href'] }
|
71
|
+
.reject { |link| link == "../" }
|
72
|
+
.map { |link| add_base_url(link, custom_path_root) }
|
73
|
+
end
|
74
|
+
|
54
75
|
def extract_all_urls(response, custom_path_root, type)
|
55
76
|
parse_html(response.body)
|
56
77
|
.to_s
|