Implement #4728 (Adds checkboxes on config and single fetch metadata screens to control author/title overwrites during metadata fetch)

This commit is contained in:
Kovid Goyal 2010-01-29 14:18:45 -07:00
commit 6e9f53e771
7 changed files with 30 additions and 4 deletions

View File

@ -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'))

View File

@ -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()):

View File

@ -171,6 +171,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_overwrite_author_title_metadata">
<property name="text">
<string>Overwrite &amp; author/title by default when fetching metadata</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">

View File

@ -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)

View File

@ -116,6 +116,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="opt_overwrite_author_title_metadata">
<property name="text">
<string>Overwrite &amp;author/title with author/title of selected book</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">

View File

@ -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:

View File

@ -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)