pulse-downloader 0.1.23 → 0.1.24
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 +14 -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: 13ed97a9caedc58bca6c4247f2d56d7456aecafe0f2eecb65b6c25b5de404fd4
|
4
|
+
data.tar.gz: 0d450684690c49812a63a0aec81f9e9d77e6074898a6ac2be9b7143fe5989adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '001790c43ba48c68ad1222d70f1352e5b399384fb7be69c6951ac80fd629ed2009fcc4a1292e23ab712ddaa1a9f206a59b1abd7f965625486160224e4e7a77bb'
|
7
|
+
data.tar.gz: d49f98068eec42477b7069948f4a7c72b37b4e166c6f843b4e7e81763c27eb5e5561115f7b15800e48ed2cd86f5397e6a21f7d3eaf2816a91b017795399fbb9f
|
@@ -12,30 +12,36 @@ module Pulse
|
|
12
12
|
print_time
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
if file_type.is_a?(Array)
|
16
|
+
file_type.flat_map do |type|
|
17
|
+
extract_file_urls(response, custom_path_root, type)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
extract_file_urls(response, custom_path_root, file_type)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
private
|
19
25
|
|
20
|
-
def extract_file_urls(response, custom_path_root)
|
26
|
+
def extract_file_urls(response, custom_path_root, type)
|
21
27
|
return [] if response.body.nil? || response.body.empty?
|
22
28
|
(
|
23
|
-
extract_download_links(response, custom_path_root) +
|
24
|
-
extract_embedded_images(response, custom_path_root)
|
29
|
+
extract_download_links(response, custom_path_root, type) +
|
30
|
+
extract_embedded_images(response, custom_path_root, type)
|
25
31
|
).uniq
|
26
32
|
end
|
27
33
|
|
28
|
-
def extract_download_links(response, custom_path_root)
|
34
|
+
def extract_download_links(response, custom_path_root, type)
|
29
35
|
parse_html(response.body)
|
30
36
|
.css('a')
|
31
37
|
.to_a
|
32
38
|
.map { |link| link['href'] }
|
33
39
|
.compact
|
34
|
-
.select { |link| (link.include?
|
40
|
+
.select { |link| (link.include? type || link.include?(custom_path_root)) }
|
35
41
|
.map { |link| add_base_url(link) }
|
36
42
|
end
|
37
43
|
|
38
|
-
def extract_embedded_images(response, custom_path_root)
|
44
|
+
def extract_embedded_images(response, custom_path_root, type)
|
39
45
|
return [] unless scrape_images
|
40
46
|
|
41
47
|
parse_html(response.body)
|
@@ -43,7 +49,7 @@ module Pulse
|
|
43
49
|
.to_a
|
44
50
|
.map { |e| e["src"] }
|
45
51
|
.compact
|
46
|
-
.select { |link| (link.include?
|
52
|
+
.select { |link| (link.include? type || link.include?(custom_path_root)) }
|
47
53
|
.map { |link| add_base_url(link) }
|
48
54
|
end
|
49
55
|
|