From 4eabac4c7e1687c8a3af592a9a9b470aa221d0cb Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Thu, 9 Apr 2026 17:40:38 +0200 Subject: [PATCH] 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 --- nodes/epub_loader.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nodes/epub_loader.py b/nodes/epub_loader.py index 8e6ed8a..29d4571 100644 --- a/nodes/epub_loader.py +++ b/nodes/epub_loader.py @@ -90,8 +90,8 @@ class OmniVoiceEpubLoader: }, } - RETURN_TYPES = ("STRING", "STRING") - RETURN_NAMES = ("text", "chapter_list") + RETURN_TYPES = ("STRING", "STRING", "STRING") + RETURN_NAMES = ("text", "chapter_title", "chapter_list") FUNCTION = "load_epub" CATEGORY = "OmniVoice" @@ -100,7 +100,7 @@ class OmniVoiceEpubLoader: n = len(chapters) if n == 0: - return ("", "") + return ("", "", "") start = max(1, min(chapter_start, n)) end = max(start, min(chapter_end, n)) @@ -111,8 +111,12 @@ class OmniVoiceEpubLoader: 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 selected = chapters[start - 1 : end] text = "\n\n---\n\n".join(ch["text"] for ch in selected) - return (text, chapter_list) + return (text, chapter_title, chapter_list)