lib/onebox/engine/amazon_onebox.rb in onebox-1.8.22 vs lib/onebox/engine/amazon_onebox.rb in onebox-1.8.23

- old
+ new

@@ -21,11 +21,14 @@ def tld @tld || @@matcher.match(@url)["tld"] end def http_params - {'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3'} + { + 'User-Agent' => + 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3' + } end private def match @@ -59,11 +62,10 @@ } result[:by_info] = raw.at("#by-line") result[:by_info] = Onebox::Helpers.clean(result[:by_info].inner_html) if result[:by_info] - # get item price (Amazon markup is inconsistent, deal with it) result[:price] = if raw.css("#priceblock_ourprice .restOfPrice")[0] && raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text "#{raw.css("#priceblock_ourprice .restOfPrice")[0].inner_text}#{raw.css("#priceblock_ourprice .buyingPrice")[0].inner_text}.#{raw.css("#priceblock_ourprice .restOfPrice")[1].inner_text}" elsif raw.css("#priceblock_dealprice") && (dealprice = raw.css("#priceblock_dealprice span")[0]) @@ -71,10 +73,10 @@ else raw.css("#priceblock_ourprice").inner_text end summary = raw.at("#productDescription") - result[:description] = og[:description] || summary.inner_text + result[:description] = og[:description] || (summary && summary.inner_text) result end end end end