This commit is contained in:
Kovid Goyal 2010-06-25 16:17:53 -06:00
parent f3cd150bb2
commit fcb7ce106d

View File

@ -14,11 +14,11 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup
OPENLIBRARY = 'http://covers.openlibrary.org/b/isbn/%s-L.jpg?default=false' OPENLIBRARY = 'http://covers.openlibrary.org/b/isbn/%s-L.jpg?default=false'
def check_for_cover(isbn): def check_for_cover(isbn, timeout=5.):
br = browser() br = browser()
br.set_handle_redirect(False) br.set_handle_redirect(False)
try: try:
br.open_novisit(OPENLIBRARY%isbn) br.open_novisit(OPENLIBRARY%isbn, timeout=timeout)
except Exception, e: except Exception, e:
if callable(getattr(e, 'getcode', None)) and e.getcode() == 302: if callable(getattr(e, 'getcode', None)) and e.getcode() == 302:
return True return True