mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Generate default cover if no existing cover found, other bug fixes
This commit is contained in:
parent
d4e236c218
commit
746c148997
@ -402,7 +402,6 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
self.exclude_genre.setText(default[1])
|
self.exclude_genre.setText(default[1])
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
class CheckableTableWidgetItem(QTableWidgetItem):
|
class CheckableTableWidgetItem(QTableWidgetItem):
|
||||||
'''
|
'''
|
||||||
Borrowed from kiwidude
|
Borrowed from kiwidude
|
||||||
@ -637,8 +636,9 @@ class GenericRulesTable(QTableWidget):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def resize_name(self, scale):
|
def resize_name(self, scale):
|
||||||
current_width = self.columnWidth(1)
|
#current_width = self.columnWidth(1)
|
||||||
self.setColumnWidth(1, min(225,int(current_width * scale)))
|
#self.setColumnWidth(1, min(225,int(current_width * scale)))
|
||||||
|
self.setColumnWidth(1, 225)
|
||||||
|
|
||||||
def rule_name_edited(self):
|
def rule_name_edited(self):
|
||||||
current_row = self.currentRow()
|
current_row = self.currentRow()
|
||||||
|
@ -13,6 +13,9 @@ from collections import namedtuple
|
|||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.customize import CatalogPlugin
|
from calibre.customize import CatalogPlugin
|
||||||
from calibre.customize.conversion import OptionRecommendation, DummyReporter
|
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')
|
Option = namedtuple('Option', 'option, default, dest, action, help')
|
||||||
|
|
||||||
@ -338,7 +341,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
OptionRecommendation.HIGH))
|
OptionRecommendation.HIGH))
|
||||||
recommendations.append(('comments', '', 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"))
|
#setattr(opts,'debug_pipeline',os.path.expanduser("~/Desktop/Catalog debug"))
|
||||||
|
|
||||||
dp = getattr(opts, 'debug_pipeline', None)
|
dp = getattr(opts, 'debug_pipeline', None)
|
||||||
@ -356,6 +359,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
|
|
||||||
# If cover exists, use it
|
# If cover exists, use it
|
||||||
cpath = None
|
cpath = None
|
||||||
|
generate_new_cover = False
|
||||||
try:
|
try:
|
||||||
search_text = 'title:"%s" author:%s' % (
|
search_text = 'title:"%s" author:%s' % (
|
||||||
opts.catalog_title.replace('"', '\\"'), 'calibre')
|
opts.catalog_title.replace('"', '\\"'), 'calibre')
|
||||||
@ -365,9 +369,26 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
if cpath and os.path.exists(cpath):
|
if cpath and os.path.exists(cpath):
|
||||||
recommendations.append(('cover', cpath,
|
recommendations.append(('cover', cpath,
|
||||||
OptionRecommendation.HIGH))
|
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:
|
except:
|
||||||
pass
|
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
|
# 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,
|
||||||
|
@ -1126,7 +1126,7 @@ Author '{0}':
|
|||||||
aTag = Tag(soup, "a")
|
aTag = Tag(soup, "a")
|
||||||
current_letter = self.letter_or_symbol(book['author_sort'][0].upper())
|
current_letter = self.letter_or_symbol(book['author_sort'][0].upper())
|
||||||
if current_letter == self.SYMBOLS:
|
if current_letter == self.SYMBOLS:
|
||||||
aTag['id'] = self.SYMBOLS
|
aTag['id'] = self.SYMBOLS + '_authors'
|
||||||
else:
|
else:
|
||||||
aTag['id'] = "%s_authors" % self.generateUnicodeName(current_letter)
|
aTag['id'] = "%s_authors" % self.generateUnicodeName(current_letter)
|
||||||
pIndexTag.insert(0,aTag)
|
pIndexTag.insert(0,aTag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user