lib/alexandria/book_providers/proxis.rb in alexandria-book-collection-manager-0.6.9 vs lib/alexandria/book_providers/proxis.rb in alexandria-book-collection-manager-0.7.0
- old
+ new
@@ -1,7 +1,7 @@
# Copyright (C) 2009 Cathal Mc Ginley
-# Copyright (C) 2014,2015 Matijs van Zuijlen
+# Copyright (C) 2014-2016 Matijs van Zuijlen
#
# Alexandria is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
@@ -32,27 +32,23 @@
# Proxis essentially has three book databases, NL, FR and EN.
# Currently, this provider only searches the NL database, since
# it adds most to Alexandria (Amazon already has French and
# English titles).
- SITE = 'http://www.proxis.nl'
+ SITE = 'http://www.proxis.nl'.freeze
BASE_SEARCH_URL = "#{SITE}/NLNL/Search/IndexGSA.aspx?search=%s" \
- '&shop=100001NL&SelRubricLevel1Id=100001NL'
+ '&shop=100001NL&SelRubricLevel1Id=100001NL'.freeze
ISBN_REDIRECT_BASE_URL = "#{SITE}/NLNL/Search/Index.aspx?search=%s" \
- '&shop=100001NL&SelRubricLevel1Id=100001NL'
+ '&shop=100001NL&SelRubricLevel1Id=100001NL'.freeze
def initialize
super('Proxis', 'Proxis (Belgium)')
# prefs.add("lang", _("Language"), "fr",
# LANGUAGES.keys)
prefs.read
end
- ## criterion = criterion.convert("windows-1252", "UTF-8")
- ## is the above still needed??
- ## current pages are returned in UTF-8, so I think probably not!
-
def search(criterion, type)
req = create_search_uri(type, criterion)
puts req if $DEBUG
html_data = transport.get_response(URI.parse(req))
@@ -73,16 +69,16 @@
end
end
def get_book_from_search_result(result)
log.debug { "Fetching book from #{result[:lookup_url]}" }
- html_data = transport.get_response(URI.parse(result[:lookup_url]))
+ html_data = transport.get_response(URI.parse(result[:lookup_url]))
parse_result_data(html_data.body)
end
def url(book)
- if book.isbn.nil? or book.isbn.empty?
+ if book.isbn.nil? || book.isbn.empty?
ISBN_REDIRECT_BASE_URL % Library.canonicalise_ean(book.isbn)
end
end
## from Palatina
@@ -105,11 +101,11 @@
end
def parse_search_result_data(html)
doc = html_to_doc(html)
book_search_results = []
- items = (doc.search('table.searchResult tr'))
+ items = doc.search('table.searchResult tr')
items.each do |item|
result = {}
title_link = item % 'h5 a'
if title_link
result[:title] = text_of(title_link)
@@ -127,13 +123,11 @@
end
def data_for_header(th)
tr = th.parent
td = tr.at('td')
- if td
- text_of(td)
- end
+ text_of(td) if td
end
def parse_result_data(html)
doc = html_to_doc(html)
book_data = {}
@@ -179,17 +173,15 @@
end
end
image_url = nil
if (cover_img = doc.at("img[@id$='imgProduct']"))
- if cover_img['src'] =~ /^http/
- image_url = cover_img['src']
- else
- image_url = "#{SITE}/#{cover_img['src']}" # TODO use html <base>
- end
- if image_url =~ /ProductNoCover/
- image_url = nil
- end
+ image_url = if cover_img['src'] =~ /^http/
+ cover_img['src']
+ else
+ "#{SITE}/#{cover_img['src']}" # TODO: use html <base>
+ end
+ image_url = nil if image_url =~ /ProductNoCover/
end
book = Book.new(book_data[:title], book_data[:authors],
book_data[:isbn], book_data[:publisher],
book_data[:publish_year], book_data[:binding])