diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py index 7c873e43..a2a7251c 100644 --- a/calibre-plugin/config.py +++ b/calibre-plugin/config.py @@ -249,6 +249,7 @@ class ConfigWidget(QWidget): #print("gc_site_settings[%s]:%s"%(site,gc_site_settings[site])) prefs['gc_site_settings'] = gc_site_settings prefs['allow_gc_from_ini'] = self.generatecover_tab.allow_gc_from_ini.isChecked() + prefs['gc_polish_cover'] = self.generatecover_tab.gc_polish_cover.isChecked() # Count Pages tab countpagesstats = [] @@ -753,6 +754,11 @@ class GenerateCoverTab(QWidget): self.allow_gc_from_ini.setChecked(prefs['allow_gc_from_ini']) self.l.addWidget(self.allow_gc_from_ini) + self.gc_polish_cover = QCheckBox(_("Use calibre's Polish feature to inject/update the cover"),self) + self.gc_polish_cover.setToolTip(_("Calibre's Polish feature will be used to inject or update the generated cover into the ebook, EPUB only.")) + self.gc_polish_cover.setChecked(prefs['gc_polish_cover']) + self.l.addWidget(self.gc_polish_cover) + class CountPagesTab(QWidget): def __init__(self, parent_dialog, plugin_action): diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 7a38a914..c8bba85e 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -1138,6 +1138,7 @@ class FanFictionDownLoaderPlugin(InterfaceAction): func, args=args, description=desc) + self.gui.jobs_pointer.start() self.gui.status_bar.show_message(_('Starting %d FanFictionDownLoads')%len(book_list),3000) def update_books_loop(self,book,db=None, @@ -1339,7 +1340,6 @@ class FanFictionDownLoaderPlugin(InterfaceAction): bad_list = sorted(bad_list,key=lambda x : x['listorder']) self.gui.status_bar.show_message(_('Merging %s books.')%total_good) - existingbook = None if 'mergebook' in options: @@ -1665,6 +1665,28 @@ class FanFictionDownLoaderPlugin(InterfaceAction): realmi = db.get_metadata(book_id, index_is_id=True) gc_plugin.generate_cover_for_book(realmi,saved_setting_name=setting_name) + if prefs['gc_polish_cover'] and \ + options['fileform'] == "epub" and calibre_version >= (0, 9, 39): + # set cover inside epub from calibre's polish feature + from calibre.ebooks.oeb.polish.main import polish, ALL_OPTS + from calibre.utils.logging import Log + from collections import namedtuple + + # Couldn't find a better way to get the cover path. + cover_path = os.path.join(db.library_path, db.path(book_id, index_is_id=True), 'cover.jpg') + data = {'cover':cover_path} + #print("cover_path:%s"%cover_path) + opts = ALL_OPTS.copy() + opts.update(data) + O = namedtuple('Options', ' '.join(ALL_OPTS.iterkeys())) + opts = O(**opts) + + log = Log(level=Log.DEBUG) + outfile = db.format_abspath(book_id, formmapping[options['fileform']], index_is_id=True) + #print("polish cover outfile:%s"%outfile) + polish({outfile:outfile}, opts, log, logger.info) + + def get_clean_reading_lists(self,lists): if lists == None or lists.strip() == "" : return [] diff --git a/calibre-plugin/prefs.py b/calibre-plugin/prefs.py index 4fe3efdf..3cfb3979 100644 --- a/calibre-plugin/prefs.py +++ b/calibre-plugin/prefs.py @@ -57,6 +57,7 @@ default_prefs['addtolistsonread'] = False default_prefs['gcnewonly'] = False default_prefs['gc_site_settings'] = {} default_prefs['allow_gc_from_ini'] = True +default_prefs['gc_polish_cover'] = False default_prefs['countpagesstats'] = []