feed_processor_utils 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -87,7 +87,7 @@ module FeedProcessorUtils
|
|
87
87
|
end.last
|
88
88
|
if largest_img
|
89
89
|
if is_news
|
90
|
-
image_urls << largest_img[:url]
|
90
|
+
image_urls << largest_img[:url] if largest_img[:dim] && have_minimum_size?(largest_img[:dim])
|
91
91
|
else
|
92
92
|
image_urls.unshift(largest_img[:url]) if largest_img[:dim] && dimensions_ok?(largest_img[:dim])
|
93
93
|
end
|
@@ -13,11 +13,13 @@ module FeedProcessorUtils
|
|
13
13
|
|
14
14
|
def parse_data(input)
|
15
15
|
input_doc = Nokogiri::HTML(input)
|
16
|
-
Hash[
|
16
|
+
parsed = Hash[
|
17
17
|
fields.map do |field_name, parsing_data|
|
18
18
|
[field_name, extract_field(input_doc, parsing_data)]
|
19
19
|
end
|
20
20
|
]
|
21
|
+
parse_lazy_images!(parsed[:lazy_image_tags]) if parsed[:lazy_image_tags]
|
22
|
+
parsed
|
21
23
|
end
|
22
24
|
|
23
25
|
def parse_url(url)
|
@@ -57,5 +59,15 @@ module FeedProcessorUtils
|
|
57
59
|
@config
|
58
60
|
end
|
59
61
|
|
62
|
+
def parse_lazy_images!(lazy_images)
|
63
|
+
# this gets rid of #{whatever} in sky sports articles
|
64
|
+
regex = /#\{(.+)\}/
|
65
|
+
lazy_images.map! do |lazy_image|
|
66
|
+
lazy_image.sub! regex do |full_match|
|
67
|
+
$1.to_s # this is the 'whatever' inside #{whatever}
|
68
|
+
end
|
69
|
+
end.compact!
|
70
|
+
end
|
71
|
+
|
60
72
|
end
|
61
73
|
end
|