mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1801 (Error when fetching cover.)
This commit is contained in:
parent
526bdc6049
commit
2a474382d0
@ -37,9 +37,14 @@ def cover_from_isbn(isbn, timeout=5.):
|
||||
if browser is None:
|
||||
browser = _browser()
|
||||
_timeout = socket.getdefaulttimeout()
|
||||
socket.setdefaulttimeout(timeout)
|
||||
socket.setdefaulttimeout(timeout)
|
||||
src = None
|
||||
try:
|
||||
src = browser.open('http://www.librarything.com/isbn/'+isbn).read().decode('utf-8', 'replace')
|
||||
except Exception, err:
|
||||
if isinstance(getattr(err, 'args', [None])[0], socket.timeout):
|
||||
raise LibraryThingError(_('LibraryThing.com timed out. Try again later.'))
|
||||
raise
|
||||
s = BeautifulSoup(src)
|
||||
url = s.find('td', attrs={'class':'left'})
|
||||
if url is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user