Fix #1136 (py3: correctly print results from fetch-ebook-metadata)

This commit is contained in:
Kovid Goyal 2020-04-26 14:30:13 +05:30
parent aad417b5d3
commit 7eecf4ec94
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -81,7 +81,7 @@ def main(args=sys.argv):
allowed_plugins=allowed_plugins or None) allowed_plugins=allowed_plugins or None)
if not results: if not results:
print(log, file=sys.stderr) prints(buf.getvalue(), file=sys.stderr)
prints('No results found', file=sys.stderr) prints('No results found', file=sys.stderr)
raise SystemExit(1) raise SystemExit(1)
result = results[0] result = results[0]
@ -96,15 +96,14 @@ def main(args=sys.argv):
save_cover_data_to(cover[-1], opts.cover) save_cover_data_to(cover[-1], opts.cover)
result.cover = cf = opts.cover result.cover = cf = opts.cover
log = buf.getvalue()
result = (metadata_to_opf(result) if opts.opf else
unicode_type(result).encode('utf-8'))
if opts.verbose: if opts.verbose:
print(log, file=sys.stderr) prints(buf.getvalue(), file=sys.stderr)
print(result) if opts.opf:
getattr(sys.stdout, 'buffer', sys.stdout).write(metadata_to_opf(result))
print()
else:
prints(unicode_type(result))
if not opts.opf and opts.cover: if not opts.opf and opts.cover:
prints('Cover :', cf) prints('Cover :', cf)