diff --git a/calibre-plugin/__init__.py b/calibre-plugin/__init__.py index cde5afc..7cabe48 100644 --- a/calibre-plugin/__init__.py +++ b/calibre-plugin/__init__.py @@ -25,7 +25,7 @@ class InterfacePluginDemo(InterfaceActionBase): description = 'UI plugin to download FanFiction stories from various sites.' supported_platforms = ['windows', 'osx', 'linux'] author = 'Jim Miller' - version = (1, 0, 2) + version = (1, 0, 3) minimum_calibre_version = (0, 8, 30) # action_menu_clone_qaction = True diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py index bf34380..6b78640 100644 --- a/calibre-plugin/config.py +++ b/calibre-plugin/config.py @@ -34,6 +34,7 @@ prefs.defaults['urlsfromselected'] = True prefs.defaults['urlsfrompriority'] = SELECTED prefs.defaults['fileform'] = 'epub' prefs.defaults['collision'] = OVERWRITE +prefs.defaults['deleteotherforms'] = False class ConfigWidget(QWidget): @@ -105,6 +106,11 @@ class ConfigWidget(QWidget): horz.addWidget(self.urlsfrompriority) self.l.addLayout(horz) + self.deleteotherforms = QCheckBox('Delete other existing formats?',self) + self.deleteotherforms.setToolTip('Check this to automatically delete all other ebook formats when updating an existing book.\nHandy if you have both a Nook(epub) and Kindle(mobi), for example.') + self.deleteotherforms.setChecked(prefs['deleteotherforms']) + self.l.addWidget(self.deleteotherforms) + self.label = QLabel('personal.ini:') self.l.addWidget(self.label) @@ -121,6 +127,7 @@ class ConfigWidget(QWidget): prefs['urlsfromclip'] = self.urlsfromclip.isChecked() prefs['urlsfromselected'] = self.urlsfromselected.isChecked() prefs['onlyoverwriteifnewer'] = self.onlyoverwriteifnewer.isChecked() + prefs['deleteotherforms'] = self.deleteotherforms.isChecked() ini = unicode(self.ini.toPlainText()) if ini: diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 9f29bd3..2570764 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -437,22 +437,12 @@ class FanFictionDownLoaderPlugin(InterfaceAction): db.add_format_with_hooks(book_id, fileform, tmp, index_is_id=True) # get all formats. - # fmts = set([x.lower() for x in db.formats(book_id, index_is_id=True).split(',')]) - # for fmt in fmts: - # if fmt != fileform: - # print("f:"+fmt) - # ## calling convert doesn't work here because we're in a BG thread. - # # (jobs,changed,bad)=convert_single_ebook(self.gui, - # # db, - # # [book_id], - # # auto_conversion=True, - # # out_format=fmt) - # # print("jobs:%s changed:%s bad:%s"%(jobs,changed,bad)) - # db.remove_format(book_id, fmt,index_is_id=True)#, notify=False - - # for a in self.gui.iactions: # ['Convert Books'] - # print("a:%s"%a) - + if prefs['deleteotherforms']: + fmts = set([x.lower() for x in db.formats(book_id, index_is_id=True).split(',')]) + for fmt in fmts: + if fmt != fileform: + print("remove f:"+fmt) + db.remove_format(book_id, fmt,index_is_id=True)#, notify=False if updatemeta or collision == CALIBREONLY: db.set_metadata(book_id,mi)