feat: Simplify EPUB chapter href normalization and enhance spine href logging

This commit is contained in:
JB
2025-10-13 17:20:33 -07:00
parent 62d4acc4d6
commit f7541388e6
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -362,7 +362,7 @@ def _extract_epub_chapters(epub_path: Path) -> List[Dict[str, str]]:
nav_titles = _parse_ncx_document(nav_bytes, nav_base) nav_titles = _parse_ncx_document(nav_bytes, nav_base)
for index, href in enumerate(spine_hrefs, start=1): for index, href in enumerate(spine_hrefs, start=1):
normalized = _normalize_epub_path("", href) normalized = href
if not normalized: if not normalized:
continue continue
title = ( title = (
@@ -375,7 +375,7 @@ def _extract_epub_chapters(epub_path: Path) -> List[Dict[str, str]]:
if not chapters and nav_titles: if not chapters and nav_titles:
for index, (href, title) in enumerate(nav_titles.items(), start=1): for index, (href, title) in enumerate(nav_titles.items(), start=1):
normalized = _normalize_epub_path("", href) normalized = href
if not normalized: if not normalized:
continue continue
label = title or posixpath.basename(normalized) or f"Chapter {index}" label = title or posixpath.basename(normalized) or f"Chapter {index}"
+6
View File
@@ -1021,6 +1021,12 @@
try { try {
await book.ready; await book.ready;
console.info('[reader] Book ready resolved'); console.info('[reader] Book ready resolved');
try {
const spineEntries = (book.spine?.items || []).map((item) => item?.href || '(unknown)');
console.info('[reader] Spine hrefs', spineEntries);
} catch (spineError) {
console.warn('[reader] Unable to log spine hrefs', spineError);
}
} catch (error) { } catch (error) {
console.error('Book failed to initialize', error); console.error('Book failed to initialize', error);
if (error && error.message) { if (error && error.message) {