diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py index 4b981a46..d524afc1 100644 --- a/calibre-plugin/config.py +++ b/calibre-plugin/config.py @@ -292,6 +292,7 @@ class ConfigWidget(QWidget): countpagesstats.append('GunningFog') prefs['countpagesstats'] = countpagesstats + prefs['wordcountmissing'] = self.countpages_tab.wordcount.isChecked() and self.countpages_tab.wordcountmissing.isChecked() # Standard Columns tab colsnewonly = {} @@ -826,11 +827,23 @@ class CountPagesTab(QWidget): self.pagecount.setToolTip(tooltip) self.pagecount.setChecked('PageCount' in prefs['countpagesstats']) self.l.addWidget(self.pagecount) - + + horz = QHBoxLayout() + self.wordcount = QCheckBox('Word Count',self) self.wordcount.setToolTip(tooltip+"\n"+_('Will overwrite word count from FFDL metadata if set to update the same custom column.')) self.wordcount.setChecked('WordCount' in prefs['countpagesstats']) - self.l.addWidget(self.wordcount) + horz.addWidget(self.wordcount) + + self.wordcountmissing = QCheckBox('Only if Word Count is Missing in FFDL Metadata',self) + self.wordcountmissing.setToolTip(_("Only run Count Page's Word Count if checked and FFDL metadata doesn't already have a word count. If this is used with one of the other Page Counts, the Page Count plugin will be called twice.")) + self.wordcountmissing.setChecked(prefs['wordcountmissing']) + self.wordcountmissing.setEnabled(self.wordcount.isChecked()) + horz.addWidget(self.wordcountmissing) + + self.wordcount.stateChanged.connect(lambda x : self.wordcountmissing.setEnabled(self.wordcount.isChecked())) + + self.l.addLayout(horz) self.fleschreading = QCheckBox('Flesch Reading Ease',self) self.fleschreading.setToolTip(tooltip) diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 4575a7f3..aa4539a8 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -1281,7 +1281,22 @@ class FanFictionDownLoaderPlugin(InterfaceAction): if 'Count Pages' in self.gui.iactions and len(prefs['countpagesstats']) and len(all_ids): cp_plugin = self.gui.iactions['Count Pages'] - cp_plugin.count_statistics(all_ids,prefs['countpagesstats']) + countpagesstats = list(prefs['countpagesstats']) # copy because we're changing it. + + ## If only some of the books need word counting, they'll + ## have to be launched separately. + if prefs['wordcountmissing']: + wc_ids = [ y['calibre_id'] for y in filter( + lambda x : '' == x['all_metadata'].get('numWords',''), add_list + update_list ) ] + ## not all need word count + if wc_ids and len(all_ids) != len(wc_ids): + cp_plugin.count_statistics(wc_ids,['WordCount']) + ## don't do WordCount below. + while 'WordCount' in countpagesstats: countpagesstats.remove('WordCount') + + ## check that there's stuff to do in case wordcount was it. + if countpagesstats: + cp_plugin.count_statistics(all_ids,countpagesstats) if prefs['autoconvert'] and options['collision'] != CALIBREONLY: self.gui.status_bar.show_message(_('Starting auto conversion of %d books.')%(len(all_ids)), 3000) diff --git a/calibre-plugin/prefs.py b/calibre-plugin/prefs.py index 083768da..f7df5e63 100644 --- a/calibre-plugin/prefs.py +++ b/calibre-plugin/prefs.py @@ -62,6 +62,7 @@ default_prefs['allow_gc_from_ini'] = True default_prefs['gc_polish_cover'] = False default_prefs['countpagesstats'] = [] +default_prefs['wordcountmissing'] = False default_prefs['errorcol'] = '' default_prefs['custom_cols'] = {} diff --git a/fanficdownloader/adapters/adapter_test1.py b/fanficdownloader/adapters/adapter_test1.py index 4bf8525a..615eaedf 100644 --- a/fanficdownloader/adapters/adapter_test1.py +++ b/fanficdownloader/adapters/adapter_test1.py @@ -116,7 +116,9 @@ Some more longer description. "I suck at summaries!" "Better than it sounds!" self.story.setMetadata('dateUpdated',datetime.datetime.now()) else: self.story.setMetadata('dateUpdated',makeDate("1975-04-15","%Y-%m-%d")) - self.story.setMetadata('numWords','123456') + + if idstr != '674': + self.story.setMetadata('numWords','123456') if idnum % 2 == 1: self.story.setMetadata('status','In-Progress') @@ -322,6 +324,7 @@ Some more longer description. "I suck at summaries!" "Better than it sounds!"
http://test1.com?sid=671 - Succeeds, but sleeps 2sec metadata only
http://test1.com?sid=672 - Succeeds, quick meta, sleeps 2sec chapters only
http://test1.com?sid=673 - Succeeds, multiple authors, extra categories, genres
+http://test1.com?sid=673 - Succeeds, no numWords set
http://test1.com?sid=0 - Succeeds, generates some text specifically for testing hyphenation problems with Nook STR/STRwG
Odd sid's will be In-Progress, evens complete. sid<10 will be assigned one of four languages and included in a series.