diff --git a/src/calibre/ebooks/metadata/sources/cli.py b/src/calibre/ebooks/metadata/sources/cli.py index 8ad4eb916b..9e1e82c265 100644 --- a/src/calibre/ebooks/metadata/sources/cli.py +++ b/src/calibre/ebooks/metadata/sources/cli.py @@ -12,6 +12,7 @@ from io import BytesIO from threading import Event from calibre import prints +from calibre.customize.ui import all_metadata_plugins from calibre.utils.config import OptionParser from calibre.utils.img import save_cover_data_to from calibre.ebooks.metadata import string_to_authors @@ -40,6 +41,11 @@ of title, authors or ISBN. help=_('Specify a filename. The cover, if available, will be saved to it. Without this option, no cover will be downloaded.')) parser.add_option('-d', '--timeout', default='30', help=_('Timeout in seconds. Default is 30')) + parser.add_option('-p', '--allowed-plugin', action='append', default=[], + help=_('Specify the name of a metadata download plugin to use.' + ' By default, all metadata plugins will be used.' + ' Can be specified multiple times for multiple plugins.' + ' All plugin names: {}').format(', '.join(p.name for p in all_metadata_plugins()))) return parser @@ -61,8 +67,10 @@ def main(args=sys.argv): if opts.isbn: identifiers['isbn'] = opts.isbn + allowed_plugins = frozenset(opts.allowed_plugin) results = identify(log, abort, title=opts.title, authors=authors, - identifiers=identifiers, timeout=int(opts.timeout)) + identifiers=identifiers, timeout=int(opts.timeout), + allowed_plugins=allowed_plugins or None) if not results: print (log, file=sys.stderr) diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index af0000ea2a..9267b1db57 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -369,13 +369,15 @@ def merge_identify_results(result_map, log): def identify(log, abort, # {{{ - title=None, authors=None, identifiers={}, timeout=30): + title=None, authors=None, identifiers={}, timeout=30, allowed_plugins=None): if title == _('Unknown'): title = None if authors == [_('Unknown')]: authors = None start_time = time.time() - plugins = [p for p in metadata_plugins(['identify']) if p.is_configured()] + + plugins = [p for p in metadata_plugins(['identify']) + if p.is_configured() and (allowed_plugins is None or p.name in allowed_plugins)] kwargs = { 'title': title,