process: show the OCR failure reason in the error

This commit is contained in:
Audiobook Producer
2026-10-18 01:50:39 -05:00
parent 9cba035adc
commit a8ea105b4c
+2 -1
View File
@@ -142,7 +142,8 @@ def check_ocr(cfg, book_dir):
ocr_pdf = os.path.join(settings.resolve(cfg, "work_dir"), os.path.basename(book_dir), "ocr.pdf")
pages = ",".join(map(str, missing))
if not os.path.exists(ocr_pdf):
msg = "pdf pages %s have no text layer and OCR did not produce a text copy (is ocrmypdf installed? see warnings.log)" % pages
why = " | ".join(ln for ln in read_if(os.path.join(book_dir, bookio.WARN_NAME)).splitlines() if ln.startswith("ingest |"))
msg = "pdf pages %s have no text layer and OCR did not produce a text copy. Reason logged: %s" % (pages, why or "none (is ocrmypdf installed?)")
if cfg["ocr"].get("required", True):
raise Failed("ingest: " + msg)
print("WARNING:", msg)