mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement #4728 (Adds checkboxes on config and single fetch metadata screens to control author/title overwrites during metadata fetch)
This commit is contained in:
commit
6e9f53e771
@ -89,6 +89,8 @@ def _config():
|
||||
help=_('Maximum number of waiting worker processes'))
|
||||
c.add_opt('get_social_metadata', default=True,
|
||||
help=_('Download social metadata (tags/rating/etc.)'))
|
||||
c.add_opt('overwrite_author_title_metadata', default=True,
|
||||
help=_('Overwrite author and title with new metadata'))
|
||||
c.add_opt('enforce_cpu_limit', default=True,
|
||||
help=_('Limit max simultaneous jobs to number of CPUs'))
|
||||
|
||||
|
@ -458,6 +458,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
self.connect(self.button_open_config_dir, SIGNAL('clicked()'),
|
||||
self.open_config_dir)
|
||||
self.opt_get_social_metadata.setChecked(config['get_social_metadata'])
|
||||
self.opt_overwrite_author_title_metadata.setChecked(config['overwrite_author_title_metadata'])
|
||||
self.opt_enforce_cpu_limit.setChecked(config['enforce_cpu_limit'])
|
||||
self.device_detection_button.clicked.connect(self.debug_device_detection)
|
||||
|
||||
@ -751,6 +752,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
|
||||
config['upload_news_to_device'] = self.sync_news.isChecked()
|
||||
config['search_as_you_type'] = self.search_as_you_type.isChecked()
|
||||
config['get_social_metadata'] = self.opt_get_social_metadata.isChecked()
|
||||
config['overwrite_author_title_metadata'] = self.opt_overwrite_author_title_metadata.isChecked()
|
||||
config['enforce_cpu_limit'] = bool(self.opt_enforce_cpu_limit.isChecked())
|
||||
fmts = []
|
||||
for i in range(self.viewer.count()):
|
||||
|
@ -171,6 +171,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="opt_overwrite_author_title_metadata">
|
||||
<property name="text">
|
||||
<string>Overwrite & author/title by default when fetching metadata</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
|
@ -119,6 +119,7 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
|
||||
self.matches.setMouseTracking(True)
|
||||
self.fetch_metadata()
|
||||
self.opt_get_social_metadata.setChecked(config['get_social_metadata'])
|
||||
self.opt_overwrite_author_title_metadata.setChecked(config['overwrite_author_title_metadata'])
|
||||
|
||||
|
||||
def show_summary(self, current, *args):
|
||||
@ -149,7 +150,8 @@ class FetchMetadata(QDialog, Ui_FetchMetadata):
|
||||
self.fetcher.start()
|
||||
self.pi.start(_('Finding metadata...'))
|
||||
self._hangcheck = QTimer(self)
|
||||
self.connect(self._hangcheck, SIGNAL('timeout()'), self.hangcheck)
|
||||
self.connect(self._hangcheck, SIGNAL('timeout()'), self.hangcheck,
|
||||
Qt.QueuedConnection)
|
||||
self.start_time = time.time()
|
||||
self._hangcheck.start(100)
|
||||
|
||||
|
@ -116,6 +116,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="opt_overwrite_author_title_metadata">
|
||||
<property name="text">
|
||||
<string>Overwrite &author/title with author/title of selected book</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
|
@ -574,9 +574,10 @@ class MetadataSingleDialog(ResizableDialog, Ui_MetadataSingleDialog):
|
||||
det_msg=det, show=True)
|
||||
else:
|
||||
book.tags = []
|
||||
self.title.setText(book.title)
|
||||
self.authors.setText(authors_to_string(book.authors))
|
||||
if book.author_sort: self.author_sort.setText(book.author_sort)
|
||||
if d.opt_overwrite_author_title_metadata.isChecked():
|
||||
self.title.setText(book.title)
|
||||
self.authors.setText(authors_to_string(book.authors))
|
||||
if book.author_sort: self.author_sort.setText(book.author_sort)
|
||||
if book.publisher: self.publisher.setEditText(book.publisher)
|
||||
if book.isbn: self.isbn.setText(book.isbn)
|
||||
if book.pubdate:
|
||||
|
@ -12,6 +12,7 @@ from Queue import Queue, Empty
|
||||
|
||||
|
||||
from calibre.ebooks.metadata.fetch import search, get_social_metadata
|
||||
from calibre.gui2 import config
|
||||
from calibre.ebooks.metadata.library_thing import cover_from_isbn
|
||||
from calibre.customize.ui import get_isbndb_key
|
||||
|
||||
@ -98,6 +99,10 @@ class DownloadMetadata(Thread):
|
||||
self.fetched_metadata[id] = fmi
|
||||
if fmi.isbn and self.get_covers:
|
||||
self.worker.jobs.put(fmi.isbn)
|
||||
if (not config['overwrite_author_title_metadata']):
|
||||
fmi.authors = mi.authors
|
||||
fmi.author_sort = mi.author_sort
|
||||
fmi.title = mi.title
|
||||
mi.smart_update(fmi)
|
||||
if mi.isbn and self.get_social_metadata:
|
||||
self.social_metadata_exceptions = get_social_metadata(mi)
|
||||
|
Loading…
x
Reference in New Issue
Block a user