Generate default cover if no existing cover found, other bug fixes

This commit is contained in:
GRiker 2012-08-07 07:01:38 -06:00
parent d4e236c218
commit 746c148997
3 changed files with 26 additions and 5 deletions

View File

@ -402,7 +402,6 @@ class PluginWidget(QWidget,Ui_Form):
self.exclude_genre.setText(default[1])
break
class CheckableTableWidgetItem(QTableWidgetItem):
'''
Borrowed from kiwidude
@ -637,8 +636,9 @@ class GenericRulesTable(QTableWidget):
pass
def resize_name(self, scale):
current_width = self.columnWidth(1)
self.setColumnWidth(1, min(225,int(current_width * scale)))
#current_width = self.columnWidth(1)
#self.setColumnWidth(1, min(225,int(current_width * scale)))
self.setColumnWidth(1, 225)
def rule_name_edited(self):
current_row = self.currentRow()

View File

@ -13,6 +13,9 @@ from collections import namedtuple
from calibre import strftime
from calibre.customize import CatalogPlugin
from calibre.customize.conversion import OptionRecommendation, DummyReporter
from calibre.ebooks import calibre_cover
from calibre.ptempfile import PersistentTemporaryFile
from calibre.utils.magick.draw import save_cover_data_to
Option = namedtuple('Option', 'option, default, dest, action, help')
@ -338,7 +341,7 @@ class EPUB_MOBI(CatalogPlugin):
OptionRecommendation.HIGH))
recommendations.append(('comments', '', OptionRecommendation.HIGH))
# Use to debug generated catalog code before conversion
# >>> Use to debug generated catalog code before conversion <<<
#setattr(opts,'debug_pipeline',os.path.expanduser("~/Desktop/Catalog debug"))
dp = getattr(opts, 'debug_pipeline', None)
@ -356,6 +359,7 @@ class EPUB_MOBI(CatalogPlugin):
# If cover exists, use it
cpath = None
generate_new_cover = False
try:
search_text = 'title:"%s" author:%s' % (
opts.catalog_title.replace('"', '\\"'), 'calibre')
@ -365,9 +369,26 @@ class EPUB_MOBI(CatalogPlugin):
if cpath and os.path.exists(cpath):
recommendations.append(('cover', cpath,
OptionRecommendation.HIGH))
log.info("using existing cover")
else:
log.info("no existing cover, generating new cover")
generate_new_cover = True
else:
log.info("no existing cover, generating new cover")
generate_new_cover = True
except:
pass
if generate_new_cover:
new_cover_path = PersistentTemporaryFile(suffix='.jpg')
new_cover_path.close()
new_cover = calibre_cover(opts.catalog_title.replace('"', '\\"'), 'calibre')
save_cover_data_to(new_cover,new_cover_path.name)
recommendations.append(('cover', new_cover_path.name, OptionRecommendation.HIGH))
if opts.verbose:
log.info("Invoking Plumber with recommendations:\n %s" % recommendations)
# Run ebook-convert
from calibre.ebooks.conversion.plumber import Plumber
plumber = Plumber(os.path.join(catalog.catalogPath,

View File

@ -1126,7 +1126,7 @@ Author '{0}':
aTag = Tag(soup, "a")
current_letter = self.letter_or_symbol(book['author_sort'][0].upper())
if current_letter == self.SYMBOLS:
aTag['id'] = self.SYMBOLS
aTag['id'] = self.SYMBOLS + '_authors'
else:
aTag['id'] = "%s_authors" % self.generateUnicodeName(current_letter)
pIndexTag.insert(0,aTag)