mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Open library decided to start blocking the default calibre user agent as well, sigh
This commit is contained in:
parent
aea809b61b
commit
1f9f03b096
@ -74,6 +74,8 @@ class HeadRequest(mechanize.Request):
|
|||||||
class OpenLibraryCovers(CoverDownload): # {{{
|
class OpenLibraryCovers(CoverDownload): # {{{
|
||||||
'Download covers from openlibrary.org'
|
'Download covers from openlibrary.org'
|
||||||
|
|
||||||
|
# See http://openlibrary.org/dev/docs/api/covers
|
||||||
|
|
||||||
OPENLIBRARY = 'http://covers.openlibrary.org/b/isbn/%s-L.jpg?default=false'
|
OPENLIBRARY = 'http://covers.openlibrary.org/b/isbn/%s-L.jpg?default=false'
|
||||||
name = 'openlibrary.org covers'
|
name = 'openlibrary.org covers'
|
||||||
description = _('Download covers from openlibrary.org')
|
description = _('Download covers from openlibrary.org')
|
||||||
@ -82,7 +84,8 @@ class OpenLibraryCovers(CoverDownload): # {{{
|
|||||||
def has_cover(self, mi, ans, timeout=5.):
|
def has_cover(self, mi, ans, timeout=5.):
|
||||||
if not mi.isbn:
|
if not mi.isbn:
|
||||||
return False
|
return False
|
||||||
br = browser()
|
from calibre.ebooks.metadata.library_thing import get_browser
|
||||||
|
br = get_browser()
|
||||||
br.set_handle_redirect(False)
|
br.set_handle_redirect(False)
|
||||||
try:
|
try:
|
||||||
br.open_novisit(HeadRequest(self.OPENLIBRARY%mi.isbn), timeout=timeout)
|
br.open_novisit(HeadRequest(self.OPENLIBRARY%mi.isbn), timeout=timeout)
|
||||||
@ -98,7 +101,8 @@ class OpenLibraryCovers(CoverDownload): # {{{
|
|||||||
def get_covers(self, mi, result_queue, abort, timeout=5.):
|
def get_covers(self, mi, result_queue, abort, timeout=5.):
|
||||||
if not mi.isbn:
|
if not mi.isbn:
|
||||||
return
|
return
|
||||||
br = browser()
|
from calibre.ebooks.metadata.library_thing import get_browser
|
||||||
|
br = get_browser()
|
||||||
try:
|
try:
|
||||||
ans = br.open(self.OPENLIBRARY%mi.isbn, timeout=timeout).read()
|
ans = br.open(self.OPENLIBRARY%mi.isbn, timeout=timeout).read()
|
||||||
result_queue.put((True, ans, 'jpg', self.name))
|
result_queue.put((True, ans, 'jpg', self.name))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user