Compare commits

...

2 Commits

Author SHA1 Message Date
NoDRM
e16748e854 Untested code for the Obok plugin to allow adding duplicate books.
See #148
2022-10-19 17:14:26 +02:00
NoDRM
06df18bea3 Strip whitespace from Kindle serials (#158) 2022-10-19 16:39:39 +02:00
4 changed files with 32 additions and 4 deletions

View File

@@ -82,3 +82,6 @@ List of changes since the fork of Apprentice Harper's repository:
- Fix a bug that would sometimes cause corrupted keys to be added when adding them through the config dialog (fixes #145, #134, #119, #116, #115, #109).
- 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.

View File

@@ -1326,7 +1326,7 @@ class AddSerialDialog(QDialog):
@property
def key_value(self):
return str(self.key_ledit.text()).replace(' ', '')
return str(self.key_ledit.text()).replace(' ', '').replace('\r', '').replace('\n', '').replace('\t', '')
def accept(self):
if len(self.key_name) == 0 or self.key_name.isspace():

View 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]:

View 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