Workflow: sparse partial checkout (code and _incoming only), book lookup before processing, safe rebase retry; revert cancel-in-progress

This commit is contained in:
Audiobook Producer
2026-10-18 01:48:48 -05:00
parent 517e76c533
commit 153153010e
6 changed files with 77 additions and 18 deletions
+26 -9
View File
@@ -112,6 +112,26 @@ def step(name):
print("\n=== %s ===" % name, flush=True)
def resolve_meta(pdf, title=None, author=None):
"""(title, author, note). Order: explicit arguments, the .json next to the PDF, the PDF itself, the file name.
Raises Failed, telling the operator what to add, if none of them works."""
meta = sidecar(pdf)
title, author = title or meta.get("title"), author or meta.get("author")
try:
title, author = ingest.detect(pdf, title, author)
except Exception as e:
raise Failed("could not read the PDF: %s" % e)
note = None
if not (title and author):
t, a = guess_from_filename(pdf)
title, author = title or t, author or a
note = "title/author not found in the PDF; taking them from the file name: '%s' by '%s'" % (title, author)
if not (title and author):
raise Failed("ingest: could not find title and author in the PDF or its file name. Put a file with the same name and "
'.json next to the PDF: {"title": "...", "author": "..."}')
return title, author, note
def check_ocr(cfg, book_dir):
"""Pages with no text layer must have been OCRed. Fails the run if they were not (setting ocr.required)."""
book = bookio.read_book(book_dir)
@@ -140,19 +160,16 @@ def check_ocr(cfg, book_dir):
def run_text_stages(cfg, pdf, title, author):
"""Ingest through license for every chapter. Returns (book_dir, book)."""
import cli
meta = sidecar(pdf)
title, author = title or meta.get("title"), author or meta.get("author")
title, author, note = resolve_meta(pdf, title, author)
step("ingest")
if note:
print(note)
try:
book_dir = ingest.run(cfg, pdf, title, author)
except SystemExit as e:
t, a = guess_from_filename(pdf)
if not (t and a):
raise Failed("ingest: %s. Put a file with the same name and .json next to the PDF: "
'{"title": "...", "author": "..."}' % e)
print("ingest: title/author not found in the PDF; taking them from the file name: '%s' by '%s'" % (t, a))
book_dir = ingest.run(cfg, pdf, title or t, author or a)
bookio.write_warnings(book_dir, "ingest-metadata", [("metadata-from-filename", os.path.basename(pdf), "title '%s', author '%s'" % (t, a))])
raise Failed("ingest: %s" % e)
if note:
bookio.write_warnings(book_dir, "ingest-metadata", [("metadata-from-filename", os.path.basename(pdf), "title '%s', author '%s'" % (title, author))])
print("ingest done ->", book_dir)
check_ocr(cfg, book_dir)
for name in ("structure",):