]> xmof Git - DeDRM.git/commitdiff
Untested code for the Obok plugin to allow adding duplicate books.
authorNoDRM <no_drm123@protonmail.com>
Wed, 19 Oct 2022 15:14:26 +0000 (17:14 +0200)
committerNoDRM <no_drm123@protonmail.com>
Wed, 19 Oct 2022 15:14:26 +0000 (17:14 +0200)
See #148

CHANGELOG.md
Obok_plugin/action.py
Obok_plugin/config.py

index 26c27fab4da65b6f8267deabc2713b12225861a3..3d610943017467e0c9a99c78f8a635b38902e1e0 100644 (file)
@@ -83,3 +83,5 @@ List of changes since the fork of Apprentice Harper's repository:
 - Update the README (fixes #136) to indicate that Apprentice Harper's version is no longer being updated.
 - Fix a bug where PDFs with empty arrays (`<>`) in a PDF object failed to decrypt, fixes #183.
 - Automatically strip whitespace from entered Amazon Kindle serial numbers, should fix #158.
+- Obok: Add new setting option "Add new entry" for duplicate books to always add them to the Calibre database as a new book. Untested. Should fix #148.
+- Obok: Fix where changing the Calibre UI language to some languages would cause the "duplicate book" setting to reset. Untested.
index fb8f26efd3127a24c7dcd67b40640ea972229f4e..e4ef377d53f6e1e0f91d840ec63954f9a357a332 100644 (file)
@@ -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]:
index a9363ad4e830b276a8c76be0e600d277fa917921..fdfb424b577ec8c1fe79a1bc5ce4cd269420793a 100644 (file)
@@ -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