diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 474617c911..a1cc0b5c64 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -757,9 +757,9 @@ from calibre.ebooks.metadata.sources.isbndb import ISBNDB from calibre.ebooks.metadata.sources.overdrive import OverDrive from calibre.ebooks.metadata.sources.douban import Douban from calibre.ebooks.metadata.sources.ozon import Ozon -# from calibre.ebooks.metadata.sources.google_images import GoogleImages +from calibre.ebooks.metadata.sources.google_images import GoogleImages -plugins += [GoogleBooks, Amazon, Edelweiss, OpenLibrary, ISBNDB, OverDrive, Douban, Ozon] +plugins += [GoogleBooks, GoogleImages, Amazon, Edelweiss, OpenLibrary, ISBNDB, OverDrive, Douban, Ozon] # }}} diff --git a/src/calibre/ebooks/metadata/sources/covers.py b/src/calibre/ebooks/metadata/sources/covers.py index 0fe963e3f7..2df716253b 100644 --- a/src/calibre/ebooks/metadata/sources/covers.py +++ b/src/calibre/ebooks/metadata/sources/covers.py @@ -18,12 +18,13 @@ from calibre.utils.magick.draw import Image, save_cover_data_to class Worker(Thread): - def __init__(self, plugin, abort, title, authors, identifiers, timeout, rq): + def __init__(self, plugin, abort, title, authors, identifiers, timeout, rq, get_best_cover=False): Thread.__init__(self) self.daemon = True self.plugin = plugin self.abort = abort + self.get_best_cover = get_best_cover self.buf = BytesIO() self.log = create_log(self.buf) self.title, self.authors, self.identifiers = (title, authors, @@ -37,7 +38,7 @@ class Worker(Thread): try: if self.plugin.can_get_multiple_covers: self.plugin.download_cover(self.log, self.rq, self.abort, - title=self.title, authors=self.authors, get_best_cover=True, + title=self.title, authors=self.authors, get_best_cover=self.get_best_cover, identifiers=self.identifiers, timeout=self.timeout) else: self.plugin.download_cover(self.log, self.rq, self.abort, @@ -72,7 +73,7 @@ def process_result(log, result): return (plugin, width, height, fmt, data) def run_download(log, results, abort, - title=None, authors=None, identifiers={}, timeout=30): + title=None, authors=None, identifiers={}, timeout=30, get_best_cover=False): ''' Run the cover download, putting results into the queue :param:`results`. @@ -89,7 +90,7 @@ def run_download(log, results, abort, plugins = [p for p in metadata_plugins(['cover']) if p.is_configured()] rq = Queue() - workers = [Worker(p, abort, title, authors, identifiers, timeout, rq) for p + workers = [Worker(p, abort, title, authors, identifiers, timeout, rq, get_best_cover=get_best_cover) for p in plugins] for w in workers: w.start() @@ -163,7 +164,7 @@ def download_cover(log, abort = Event() run_download(log, rq, abort, title=title, authors=authors, - identifiers=identifiers, timeout=timeout) + identifiers=identifiers, timeout=timeout, get_best_cover=True) results = [] diff --git a/src/calibre/ebooks/metadata/sources/google_images.py b/src/calibre/ebooks/metadata/sources/google_images.py index c755fea192..36fe2750ee 100644 --- a/src/calibre/ebooks/metadata/sources/google_images.py +++ b/src/calibre/ebooks/metadata/sources/google_images.py @@ -51,6 +51,7 @@ class GoogleImages(Source): urls = urls[:self.prefs['max_covers']] if get_best_cover: urls = urls[:1] + log('Downloading %d covers'%len(urls)) workers = [Thread(target=self.download_image, args=(url, timeout, log, result_queue)) for url in urls] for w in workers: w.daemon = True