mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
Improved chapter filename generation
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# v1.0.9 (pre-release)
|
# v1.0.9 (pre-release)
|
||||||
- Added chunking/segmenting system that fixes memory outage issues when processing large audio files.
|
- Added chunking/segmenting system that fixes memory outage issues when processing large audio files.
|
||||||
|
- Improved chapter filename generation with smart word-boundary truncation at 80 characters, preventing mid-word cuts in filenames.
|
||||||
- `Composer` and `Genre` metadata fields for M4B files are now editable from the text editor.
|
- `Composer` and `Genre` metadata fields for M4B files are now editable from the text editor.
|
||||||
|
|
||||||
# v1.0.8
|
# v1.0.8
|
||||||
|
|||||||
+13
-6
@@ -652,12 +652,19 @@ class ConversionThread(QThread):
|
|||||||
and chapters_out_dir
|
and chapters_out_dir
|
||||||
and chapter_audio_segments
|
and chapter_audio_segments
|
||||||
):
|
):
|
||||||
# Sanitize chapter name for use in filenames
|
|
||||||
sanitized_chapter_name = re.sub(r"[^\w\-\. ]", "_", chapter_name)
|
# strip any non‐alphanumeric or space/dash
|
||||||
sanitized_chapter_name = re.sub(
|
sanitized = re.sub(r"[^\w\s\-]", "", chapter_name)
|
||||||
r"_+", "_", sanitized_chapter_name
|
# collapse spaces or dashes to single underscore
|
||||||
) # Replace multiple underscores with one
|
sanitized = re.sub(r"[\s\-]+", "_", sanitized).strip("_")
|
||||||
chapter_filename = f"{chapter_idx:02d}_{sanitized_chapter_name}"
|
# enforce max length
|
||||||
|
MAX_LEN = 80
|
||||||
|
if len(sanitized) > MAX_LEN:
|
||||||
|
# Find last word boundary before limit
|
||||||
|
pos = sanitized[:MAX_LEN].rfind("_")
|
||||||
|
# Use word boundary if found, otherwise use hard limit
|
||||||
|
sanitized = sanitized[:pos if pos > 0 else MAX_LEN].rstrip("_")
|
||||||
|
chapter_filename = f"{chapter_idx:02d}_{sanitized}"
|
||||||
|
|
||||||
# Use separate_chapters_format
|
# Use separate_chapters_format
|
||||||
separate_format = getattr(self, 'separate_chapters_format', 'wav')
|
separate_format = getattr(self, 'separate_chapters_format', 'wav')
|
||||||
|
|||||||
Reference in New Issue
Block a user