diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py index d9144fdf34..f322fcdb56 100644 --- a/src/calibre/ebooks/metadata/sources/base.py +++ b/src/calibre/ebooks/metadata/sources/base.py @@ -24,6 +24,7 @@ msprefs.defaults['ignore_fields'] = [] msprefs.defaults['max_tags'] = 20 msprefs.defaults['wait_after_first_identify_result'] = 30 # seconds msprefs.defaults['wait_after_first_cover_result'] = 60 # seconds +msprefs.defaults['swap_author_names'] = False # Google covers are often poor quality (scans/errors) but they have high # resolution, so they trump covers from better sources. So make sure they diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index 170ceb6c7a..87c1e9a644 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -365,6 +365,18 @@ def identify(log, abort, # {{{ for r in results: r.tags = r.tags[:max_tags] + if msprefs['swap_author_names']: + for r in results: + def swap_to_ln_fn(a): + if ',' in a: + return a + parts = a.split(None) + if len(parts) <= 1: + return a + surname = parts[-1] + return '%s, %s' % (surname, ' '.join(parts[:-1])) + r.authors = [swap_to_ln_fn(a) for a in r.authors] + return results # }}} diff --git a/src/calibre/gui2/preferences/metadata_sources.py b/src/calibre/gui2/preferences/metadata_sources.py index 17a70bcc33..9f2c441054 100644 --- a/src/calibre/gui2/preferences/metadata_sources.py +++ b/src/calibre/gui2/preferences/metadata_sources.py @@ -258,6 +258,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): r('max_tags', msprefs) r('wait_after_first_identify_result', msprefs) r('wait_after_first_cover_result', msprefs) + r('swap_author_names', msprefs) self.configure_plugin_button.clicked.connect(self.configure_plugin) self.sources_model = SourcesModel(self) diff --git a/src/calibre/gui2/preferences/metadata_sources.ui b/src/calibre/gui2/preferences/metadata_sources.ui index b515f13ba1..37797eda5a 100644 --- a/src/calibre/gui2/preferences/metadata_sources.ui +++ b/src/calibre/gui2/preferences/metadata_sources.ui @@ -21,7 +21,7 @@ - + Metadata sources @@ -98,7 +98,14 @@ - + + + + Swap author names from FN LN to LN, FN + + + + Max. number of &tags to download: @@ -108,10 +115,10 @@ - + - + Max. &time to wait after first match is found: @@ -121,14 +128,14 @@ - + secs - + Max. time to wait after first &cover is found: @@ -138,7 +145,7 @@ - + secs