lib/alexandria/book_providers/siciliano.rb in alexandria-book-collection-manager-0.7.4 vs lib/alexandria/book_providers/siciliano.rb in alexandria-book-collection-manager-0.7.5

- old
+ new

@@ -123,37 +123,35 @@ book_search_results = [] # each result will be a dict with keys :title, :author, :publisher, :url list_items = doc.search("div.pesquisa-item-lista-conteudo") list_items.each do |item| - begin - result = {} + result = {} - # author & publisher - author_publisher = "" - item.children.each do |node| - author_publisher += node.to_s if node.text? - author_publisher.strip! - break unless author_publisher.empty? - end - author, publisher = author_publisher.split("/") - result[:author] = author.strip if author - result[:publisher] = publisher.strip if publisher + # author & publisher + author_publisher = "" + item.children.each do |node| + author_publisher += node.to_s if node.text? + author_publisher.strip! + break unless author_publisher.empty? + end + author, publisher = author_publisher.split("/") + result[:author] = author.strip if author + result[:publisher] = publisher.strip if publisher - # title & url - link = item % "a" - result[:title] = link.inner_text.strip - link_to_description = link["href"] - slash = "" - slash = "/" unless %r{^/}.match?(link_to_description) - result[:url] = "#{SITE}#{slash}#{link_to_description}" + # title & url + link = item % "a" + result[:title] = link.inner_text.strip + link_to_description = link["href"] + slash = "" + slash = "/" unless %r{^/}.match?(link_to_description) + result[:url] = "#{SITE}#{slash}#{link_to_description}" - book_search_results << result - rescue StandardError => ex - trace = ex.backtrace.join("\n> ") - log.error { "Failed parsing Siciliano search page #{ex.message}\n#{trace}" } - end + book_search_results << result + rescue StandardError => ex + trace = ex.backtrace.join("\n> ") + log.error { "Failed parsing Siciliano search page #{ex.message}\n#{trace}" } end book_search_results end @@ -184,12 +182,11 @@ binding = details["Acabamento"] publisher = search_result[:publisher] # publish year publish_year = nil edition = details["Edio"] - if edition - publish_year = Regexp.last_match[1].to_i if edition =~ /([12][0-9]{3})/ # publication date - end + # publication date + publish_year = Regexp.last_match[1].to_i if edition && edition =~ /([12][0-9]{3})/ # cover # ImgSrc[1]="/imagem/imagem.dll?pro_id=1386929&PIM_Id=658849"; image_urls = [] (doc / "script").each do |script| next if script.children.nil?