feat: add chapter_title output to EPUB Loader for file naming

Returns the title of the first selected chapter as a STRING so it can
be wired directly into a Save Audio node's filename field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-09 17:40:38 +02:00
parent dd6d5061e4
commit 4eabac4c7e
+8 -4
View File
@@ -90,8 +90,8 @@ class OmniVoiceEpubLoader:
}, },
} }
RETURN_TYPES = ("STRING", "STRING") RETURN_TYPES = ("STRING", "STRING", "STRING")
RETURN_NAMES = ("text", "chapter_list") RETURN_NAMES = ("text", "chapter_title", "chapter_list")
FUNCTION = "load_epub" FUNCTION = "load_epub"
CATEGORY = "OmniVoice" CATEGORY = "OmniVoice"
@@ -100,7 +100,7 @@ class OmniVoiceEpubLoader:
n = len(chapters) n = len(chapters)
if n == 0: if n == 0:
return ("", "") return ("", "", "")
start = max(1, min(chapter_start, n)) start = max(1, min(chapter_start, n))
end = max(start, min(chapter_end, n)) end = max(start, min(chapter_end, n))
@@ -111,8 +111,12 @@ class OmniVoiceEpubLoader:
for i, ch in enumerate(chapters, 1) for i, ch in enumerate(chapters, 1)
) )
# chapter_title: title of the first selected chapter (useful for file naming)
first = chapters[start - 1]
chapter_title = first["title"] if first["title"] else f"Chapter {start}"
# text: selected range joined by delimiter # text: selected range joined by delimiter
selected = chapters[start - 1 : end] selected = chapters[start - 1 : end]
text = "\n\n---\n\n".join(ch["text"] for ch in selected) text = "\n\n---\n\n".join(ch["text"] for ch in selected)
return (text, chapter_list) return (text, chapter_title, chapter_list)