From 4f7dd77af000c39f1231e99189218a762b64bdb9 Mon Sep 17 00:00:00 2001 From: Mamoru Tasaka Date: Aug 27 2009 02:48:14 +0000 Subject: - Add sanity check for invalid search result, now using upstream patch - Fix DeaStore provider where search result contains no Author --- diff --git a/alexandria-0.6.5-deastore-author-missing.patch b/alexandria-0.6.5-deastore-author-missing.patch new file mode 100644 index 0000000..e662185 --- /dev/null +++ b/alexandria-0.6.5-deastore-author-missing.patch @@ -0,0 +1,115 @@ +Index: lib/alexandria/book_providers/deastore.rb +=================================================================== +--- lib/alexandria/book_providers/deastore.rb (revision 1086) ++++ lib/alexandria/book_providers/deastore.rb (revision 1087) +@@ -49,12 +49,18 @@ + def get_book_from_search_result(result) + log.debug { "Fetching book from #{result[:url]}" } + html_data = agent.get(result[:url]) ++ #File.open("rsltflarn#{Time.now().usec()}.html", 'wb') do |f| ++ # f.write(html_data.body) ++ #end + parse_result_data(html_data.body) + end + + def search(criterion, type) + criterion = criterion.convert("ISO-8859-1", "UTF-8") # still needed?? + html_data = agent.get(create_search_uri(type, criterion)) ++ #File.open("flarn#{Time.now().usec()}.html", 'wb') do |f| ++ # f.write(html_data.body) ++ #end + results = parse_search_result_data(html_data.body) + raise NoResultsError if results.empty? + +@@ -89,7 +95,9 @@ + search_term_encoded = CGI.escape(search_term) + end + +- BASE_SEARCH_URL % [search_type_code, search_term_encoded] ++ uri = BASE_SEARCH_URL % [search_type_code, search_term_encoded] ++ log.debug { uri } ++ uri + end + + def parse_search_result_data(html) +@@ -109,13 +117,21 @@ + # p Data di pubblicazione: \n 2009 + # p.prezzo (price) + +- cover_url = '' +- cover_images = div/'a/img' +- unless cover_images.empty? +- img = cover_images.first +- image_url = img['src'] +- cover_url = "#{SITE}#{image_url}" +- end ++# cover_url = '' ++# cover_images = div/'a/img' ++# unless cover_images.empty? ++# img = cover_images.first ++# image_url = img['src'] ++# if image_url =~ /^http/ ++# cover_url = '' # image_url ++# elsif image_url[0..0] != '/' ++# cover_url = "#{SITE}/#{image_url}" ++# else ++# cover_url = "#{SITE}#{image_url}" ++# end ++# log.debug { "Search Cover Image URL #{cover_url}" } ++ ++# end + + content = div/'div.scheda_content' + title_link = (content/:a).first +@@ -167,12 +183,17 @@ + end + + # author(s) ++ authors = [] + author_span = data%'span.int_scheda[text()*=Autore]' +- author_links = author_span/'a.info' +- authors = [] +- author_links.each do |link| +- authors << normalize(link.inner_text) ++ unless author_span ++ author_span = data%'span.int_scheda[text()*=cura]' # editor + end ++ if author_span ++ author_links = author_span/'a.info' ++ author_links.each do |link| ++ authors << normalize(link.inner_text) ++ end ++ end + + # publisher + publisher_par = data%'span.int_scheda[text()*=Editore]/..' +@@ -231,7 +252,19 @@ + #cover + image_url = nil + if cover_link +- image_url = "#{SITE}#{cover_link}" ++ if cover_link =~ /^http/ ++ # e.g. http://images.btol.com/ContentCafe/Jacket.aspx?\ ++ # Return=1&Type=M&Value=9788873641803&password=\ ++ # CC70580&userID=DEA40305 ++ # seems not to work, or to be blank anyway, so set to nil ++ image_url = nil ++ elsif cover_link[0..0] != '/' ++ image_url = "#{SITE}/#{cover_link}" ++ else ++ image_url = "#{SITE}#{cover_link}" ++ end ++ ++ log.debug { "Cover Image URL:: #{image_url}" } + end + + book = Book.new(title, authors, isbn, publisher, publish_year, binding) +@@ -239,7 +272,7 @@ + return [book, image_url] + rescue Exception => ex + trace = ex.backtrace.join("\n> ") +- log.error { "Failed parsing Siciliano product page #{ex.message}\n#{trace}" } ++ log.error { "Failed parsing DeaStore product page #{ex.message}\n#{trace}" } + return nil + end + end diff --git a/alexandria.spec b/alexandria.spec index 1aa393d..5d2325d 100644 --- a/alexandria.spec +++ b/alexandria.spec @@ -5,7 +5,7 @@ %define majorver 0.6.5 %undefine minorver -%define fedorarel 4 +%define fedorarel 5 %define rel %{?minorver:0.}%{fedorarel}%{?minorver:.%minorver} @@ -26,8 +26,12 @@ Patch2: alexandria-0.6.4.1-hang-importing-invalid-isdn.patch # ref: alexandria-Bugs-26968 Patch3: alexandria-0.6.5-glib_convert-syntax.patch # Add some sanity check for search results -# Currently discussed on alexandria-Bugs-27000 +# ref: alexandria-Bugs-27000 Patch4: alexandria-0.6.5-search-result-sanity-check.patch +# Fix for DeaStore search engine where search result does not +# contain Author item +# ref: alexandria-Bugs-27000 +Patch5: alexandria-0.6.5-deastore-author-missing.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch @@ -80,6 +84,7 @@ Alexandria is a GNOME application to help you manage your book collection. %patch2 -p0 -b .up25348 %patch3 -p0 -b .glib %patch4 -p0 -b .sanity +%patch5 -p0 -b .deastore # Embed Fedora EVR %{__sed} -i.evr \ @@ -206,8 +211,9 @@ exit 0 %{_datadir}/icons/hicolor/*/apps/%{name}.* %changelog -* Thu Aug 27 2009 Mamoru Tasaka - 0.6.5-4 -- Add trial sanity check again +* Thu Aug 27 2009 Mamoru Tasaka - 0.6.5-5 +- Add sanity check for invalid search result, now using upstream patch +- Fix DeaStore provider where search result contains no Author * Fri Aug 21 2009 Mamoru Tasaka - 0.6.5-3 - Clarify GLib.convert usage in utils.rb (does not change the