Print full ocrmypdf output on failure; sanitize control characters in warnings.log

This commit is contained in:
Audiobook Producer
2026-10-18 02:00:38 -05:00
parent 568bf7749e
commit 50bfa3e239
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -108,5 +108,6 @@ def ocr_if_needed(cfg, book_dir, book):
src = os.path.join(book_dir, book["source_pdf"])
r = subprocess.run(["ocrmypdf", "--skip-text", "-l", cfg["ocr"]["language"], src, out], capture_output=True, text=True)
if r.returncode != 0:
print("ocrmypdf failed, exit %d. stdout: %r stderr: %r" % (r.returncode, r.stdout[-1500:], r.stderr[-3000:]))
return [("ocr-failed", where, "ocrmypdf exit %d: %s" % (r.returncode, (r.stderr.strip()[:700] + " ... " + r.stderr.strip()[-500:]) if len(r.stderr) > 1250 else r.stderr.strip()))]
return [("ocr", where, "OCR applied to a scratch copy; original untouched")]