Catalog generation: Reuse cover from existing catalog, allows the use of a custom cover for catalogs

This commit is contained in:
Kovid Goyal 2011-03-05 14:52:19 -07:00
parent 28a43e15b7
commit 41c25e037b

View File

@ -5103,6 +5103,19 @@ Author '{0}':
recommendations.append(('book_producer',opts.output_profile, recommendations.append(('book_producer',opts.output_profile,
OptionRecommendation.HIGH)) 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 # Run ebook-convert
from calibre.ebooks.conversion.plumber import Plumber from calibre.ebooks.conversion.plumber import Plumber
plumber = Plumber(os.path.join(catalog.catalogPath, plumber = Plumber(os.path.join(catalog.catalogPath,