diff options
author | NoDRM <[email protected]> | 2022-10-19 17:14:26 +0200 |
---|---|---|
committer | NoDRM <[email protected]> | 2022-10-19 17:14:26 +0200 |
commit | e16748e85486f4e7aac0d73b380e272b6712ac01 (patch) | |
tree | f5f63ec391fb31d71873eaf82873b859dfd00ca0 /Obok_plugin | |
parent | 06df18bea331b6e26dd416e8c58dec17d538a942 (diff) |
Untested code for the Obok plugin to allow adding duplicate books.
See #148
Diffstat (limited to 'Obok_plugin')
-rw-r--r-- | Obok_plugin/action.py | 5 | ||||
-rw-r--r-- | Obok_plugin/config.py | 26 |
2 files changed, 28 insertions, 3 deletions
diff --git a/Obok_plugin/action.py b/Obok_plugin/action.py index fb8f26e..e4ef377 100644 --- a/Obok_plugin/action.py +++ b/Obok_plugin/action.py @@ -237,7 +237,10 @@ class InterfacePluginAction(InterfaceAction): :param books_to_add: List of calibre bookmaps (created in get_decrypted_kobo_books) ''' - added = self.db.add_books(books_to_add, add_duplicates=False, run_hooks=False) + + cfg_add_duplicates = (cfg['finding_homes_for_formats'] == 'Add new entry') + + added = self.db.add_books(books_to_add, add_duplicates=cfg_add_duplicates, run_hooks=False) if len(added[0]): # Record the id(s) that got added for id in added[0]: diff --git a/Obok_plugin/config.py b/Obok_plugin/config.py index a9363ad..fdfb424 100644 --- a/Obok_plugin/config.py +++ b/Obok_plugin/config.py @@ -39,8 +39,13 @@ class ConfigWidget(QWidget): self.find_homes = QComboBox() self.find_homes.setToolTip(_('<p>Default behavior when duplicates are detected. None of the choices will cause calibre ebooks to be overwritten')) layout.addWidget(self.find_homes) - self.find_homes.addItems([_('Ask'), _('Always'), _('Never')]) + + self.find_homes.addItems([_('Ask'), _('Always'), _('Never'), _('Add new entry')]) + index = self.find_homes.findText(plugin_prefs['finding_homes_for_formats']) + if index == -1: + index = self.find_homes.findText(_(plugin_prefs['finding_homes_for_formats'])) + self.find_homes.setCurrentIndex(index) self.serials_button = QtGui.QPushButton(self) @@ -69,7 +74,24 @@ class ConfigWidget(QWidget): def save_settings(self): - plugin_prefs['finding_homes_for_formats'] = self.find_homes.currentText() + + + # Make sure the config file string is *always* english. + find_homes = None + if self.find_homes.currentText() == _('Ask'): + find_homes = 'Ask' + elif self.find_homes.currentText() == _('Always'): + find_homes = 'Always' + elif self.find_homes.currentText() == _('Never'): + find_homes = 'Never' + elif self.find_homes.currentText() == _('Add new entry'): + find_homes = 'Add new entry' + + if find_homes is None: + # Fallback + find_homes = self.find_homes.currentText() + + plugin_prefs['finding_homes_for_formats'] = find_homes plugin_prefs['kobo_serials'] = self.tmpserials plugin_prefs['kobo_directory'] = self.kobodirectory |