diff --git a/CHANGELOG.md b/CHANGELOG.md index 911b121..909dc14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # v1.0.9 (pre-release) - Changed audio processing pipeline back to converting temporary WAV files instead of directly creating OPUS and M4B files. This resolves memory outage issues with long books that caused crashes, unresponsive behavior, or corrupted audio output. **This approach will be slower, but it is more stable and reliable.** +- "Composer" and "Genre" metadata fields for M4B files are now editable from the text editor. # v1.0.8 - Added support for AMD GPUs in Linux (Special thanks to @hg000125 for his contribution in #23) diff --git a/README.md b/README.md index 024da0f..49f29e1 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,17 @@ When you process the text file, Abogen will detect these markers automatically a ![Abogen Chapter Marker](https://raw.githubusercontent.com/denizsafak/abogen/refs/heads/main/demo/chapter_marker.png) +## `About Metadata Tags` +Similar to chapter markers, it is possible to add metadata tags to `M4B` files. This is useful for audiobook players that support metadata, allowing you to add information like title, author, year, etc. Abogen automatically adds these tags when you process ePUB or PDF files, but you can also add them manually to your text files. Add metadata tags **at the beginning of your text file** like this: +``` +<> +<> +<> +<> +<> +<> +<> +``` ## `Supported Languages` ``` diff --git a/abogen/book_handler.py b/abogen/book_handler.py index 5eb63d9..1ad4805 100644 --- a/abogen/book_handler.py +++ b/abogen/book_handler.py @@ -1649,7 +1649,9 @@ class HandlerDialog(QDialog): f"<>", f"<>", f"<>", - f"<>" + f"<>", + f"<>", + f"<>" ] return "\n".join(metadata_tags) diff --git a/abogen/conversion.py b/abogen/conversion.py index c19907a..2f04733 100644 --- a/abogen/conversion.py +++ b/abogen/conversion.py @@ -751,10 +751,7 @@ class ConversionThread(QThread): "-map", "0:a", "-map_metadata", "1", "-map_chapters", "1", - # Add metadata tags - "-metadata", "composer=Narrator", - "-metadata", "genre=Audiobook", - # Add additional extracted metadata tags + # Add extracted metadata tags *metadata_options, "-c:a", "aac", "-movflags", "+faststart+use_metadata_tags", @@ -843,6 +840,8 @@ class ConversionThread(QThread): album_match = re.search(r"<]*)>>", text) year_match = re.search(r"<]*)>>", text) album_artist_match = re.search(r"<]*)>>", text) + composer_match = re.search(r"<]*)>>", text) + genre_match = re.search(r"<]*)>>", text) # Use display path or filename as fallback for title filename = os.path.splitext(os.path.basename(self.display_path if self.display_path else self.file_name))[0] @@ -878,6 +877,18 @@ class ConversionThread(QThread): metadata_options.extend(["-metadata", f"album_artist={album_artist_match.group(1)}"]) else: metadata_options.extend(["-metadata", f"album_artist=Unknown"]) + + # Add composer metadata + if composer_match: + metadata_options.extend(["-metadata", f"composer={composer_match.group(1)}"]) + else: + metadata_options.extend(["-metadata", f"composer=Narrator"]) + + # Add genre metadata + if genre_match: + metadata_options.extend(["-metadata", f"genre={genre_match.group(1)}"]) + else: + metadata_options.extend(["-metadata", f"genre=Audiobook"]) # Add these to ffmpeg command return metadata_options