From f0402832618a34d9fc1fbeb29aa8bee2fa2023f7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Feb 2020 21:24:55 +0530 Subject: [PATCH] Better error message for text less DJVU files --- src/calibre/ebooks/conversion/plugins/djvu_input.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/conversion/plugins/djvu_input.py b/src/calibre/ebooks/conversion/plugins/djvu_input.py index 8f25551af8..ed61ff04d3 100644 --- a/src/calibre/ebooks/conversion/plugins/djvu_input.py +++ b/src/calibre/ebooks/conversion/plugins/djvu_input.py @@ -28,8 +28,12 @@ class DJVUInput(InputFormatPlugin): from calibre.ebooks.djvu.djvu import DJVUFile x = DJVUFile(stream) x.get_text(stdout) + raw_text = stdout.getvalue() + if not raw_text: + raise ValueError('The DJVU file contains no text, only images, probably page scans.' + ' calibre only supports conversion of DJVU files with actual text in them.') - html = convert_basic(stdout.getvalue().replace(b"\n", b' ').replace( + html = convert_basic(raw_text.replace(b"\n", b' ').replace( b'\037', b'\n\n')) # Run the HTMLized text through the html processing plugin. from calibre.customize.ui import plugin_for_input_format