fetch-ebook-metadata: add option to use only a single metadata plugin

This commit is contained in:
Nedyalko Andreev 2017-04-23 14:40:00 +03:00
parent f62b832d1b
commit a81bca9096
2 changed files with 8 additions and 3 deletions

View File

@ -40,6 +40,8 @@ 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', '--plugin',
help=_('Specify a metadata plugin. By default, all enabled metadata plugins will be used.'))
return parser
@ -62,7 +64,8 @@ def main(args=sys.argv):
identifiers['isbn'] = opts.isbn
results = identify(log, abort, title=opts.title, authors=authors,
identifiers=identifiers, timeout=int(opts.timeout))
identifiers=identifiers, timeout=int(opts.timeout),
plugin=opts.plugin)
if not results:
print (log, file=sys.stderr)

View File

@ -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, plugin=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 (plugin == None or p.name == plugin)]
kwargs = {
'title': title,