From 41c25e037bca7095d926a773de884ab10af0c151 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 5 Mar 2011 14:52:19 -0700 Subject: [PATCH] Catalog generation: Reuse cover from existing catalog, allows the use of a custom cover for catalogs --- src/calibre/library/catalog.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index f3640af4f0..ffa08eaed2 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -5103,6 +5103,19 @@ Author '{0}': recommendations.append(('book_producer',opts.output_profile, OptionRecommendation.HIGH)) + # If cover exists, use it + try: + search_text = 'title:"%s" author:%s' % ( + opts.catalog_title.replace('"', '\\"'), 'calibre') + matches = db.search(search_text, return_matches=True) + if matches: + cpath = db.cover(matches[0], index_is_id=True, as_path=True) + if cpath and os.path.exists(cpath): + recommendations.append(('cover', cpath, + OptionRecommendation.HIGH)) + except: + pass + # Run ebook-convert from calibre.ebooks.conversion.plumber import Plumber plumber = Plumber(os.path.join(catalog.catalogPath,