From 5f5dc85ae00d332444c4b0ecc83515bed7e48f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C5=9Eafak?= Date: Wed, 16 Jul 2025 07:14:10 +0300 Subject: [PATCH] v1.1.4 - Fixed extra metadata information not being saved to M4B files --- CHANGELOG.md | 6 ++++- abogen/VERSION | 2 +- abogen/conversion.py | 59 ++++++++++++++++++++++++++++++-------------- abogen/gui.py | 5 ++-- abogen/utils.py | 1 + 5 files changed, 50 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 270717d..3ece495 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ +# 1.1.4 +- Fixed extra metadata information not being saved to M4B files, ensuring that all metadata is correctly written to the output file. +- Reformatted the code using Black for better readability and consistency. + # 1.1.3 -- `M4B (with chapters)` generation is faster now, as it directly generates `m4b` files instead of converting from `wav`, which significantly reduces processing time. +- `M4B (with chapters)` generation is faster now, as it directly generates `m4b` files instead of converting from `wav`, which significantly reduces processing time, fixes the issue mentioned by @Milor123 in #39 - Better sleep state handling for Linux. - The app window now tries to fit the screen if its height would exceed the available display area. - Fixed issue where the app would not restart properly on Windows. diff --git a/abogen/VERSION b/abogen/VERSION index 9c1218c..1b87bcd 100644 --- a/abogen/VERSION +++ b/abogen/VERSION @@ -1 +1 @@ -1.1.3 \ No newline at end of file +1.1.4 \ No newline at end of file diff --git a/abogen/conversion.py b/abogen/conversion.py index 4f1756c..91fb12f 100644 --- a/abogen/conversion.py +++ b/abogen/conversion.py @@ -493,20 +493,26 @@ class ConversionThread(QThread): merged_out_file = None ffmpeg_proc = None # Prepare ffmpeg command for m4b output - metadata_options = self._extract_and_add_metadata_tags_to_ffmpeg_cmd() cmd = [ "ffmpeg", "-y", - "-thread_queue_size", "32768", - "-f", "f32le", - "-ar", "24000", - "-ac", "1", - "-i", "pipe:0", - "-c:a", "aac", - "-q:a", "2", - "-movflags", "+faststart+use_metadata_tags", + "-thread_queue_size", + "32768", + "-f", + "f32le", + "-ar", + "24000", + "-ac", + "1", + "-i", + "pipe:0", + "-c:a", + "aac", + "-q:a", + "2", + "-movflags", + "+faststart+use_metadata_tags", ] - cmd += metadata_options cmd.append(merged_out_path) ffmpeg_proc = create_process(cmd, stdin=subprocess.PIPE, text=False) elif self.output_format == "opus": @@ -807,7 +813,7 @@ class ConversionThread(QThread): tokens_with_timestamps, new_entries, self.max_subtitle_words, - fallback_end_time=chunk_start + chunk_dur + fallback_end_time=chunk_start + chunk_dur, ) if merged_subtitle_file: subtitle_format = getattr( @@ -945,17 +951,27 @@ class ConversionThread(QThread): orig_path = merged_out_path root, ext = os.path.splitext(orig_path) tmp_path = root + ".tmp" + ext + metadata_options = ( + self._extract_and_add_metadata_tags_to_ffmpeg_cmd() + ) cmd = [ "ffmpeg", "-y", - "-i", orig_path, - "-i", chapters_info_path, - "-map", "0:a", - "-map_metadata", "1", - "-map_chapters", "1", - "-c:a", "copy", - tmp_path + "-i", + orig_path, + "-i", + chapters_info_path, + "-map", + "0:a", + "-map_metadata", + "1", + "-map_chapters", + "1", + "-c:a", + "copy", ] + cmd += metadata_options + cmd.append(tmp_path) proc = create_process(cmd) proc.wait() os.replace(tmp_path, orig_path) @@ -1126,7 +1142,11 @@ class ConversionThread(QThread): return f"{h}:{m:02}:{s:02}.{cs:02}" def _process_subtitle_tokens( - self, tokens_with_timestamps, subtitle_entries, max_subtitle_words, fallback_end_time=None + self, + tokens_with_timestamps, + subtitle_entries, + max_subtitle_words, + fallback_end_time=None, ): """Helper function to process subtitle tokens according to the subtitle mode""" if not tokens_with_timestamps: @@ -1222,6 +1242,7 @@ class ConversionThread(QThread): start, end, text = last_entry if end is None or end <= start or end <= 0: subtitle_entries[-1] = (start, fallback_end_time, text) + def cancel(self): self.cancel_requested = True self.should_cancel = True diff --git a/abogen/gui.py b/abogen/gui.py index 0ad8199..629fb6e 100644 --- a/abogen/gui.py +++ b/abogen/gui.py @@ -2822,14 +2822,15 @@ class abogen(QWidget): def restart_app(self): from PyQt5.QtCore import QProcess import sys + exe = sys.executable args = sys.argv # On Windows, use .exe if available if platform.system() == "Windows": script_path = args[0] - if not script_path.lower().endswith('.exe'): - exe_path = os.path.splitext(script_path)[0] + '.exe' + if not script_path.lower().endswith(".exe"): + exe_path = os.path.splitext(script_path)[0] + ".exe" if os.path.exists(exe_path): args[0] = exe_path diff --git a/abogen/utils.py b/abogen/utils.py index a8dfd65..0a9a58f 100644 --- a/abogen/utils.py +++ b/abogen/utils.py @@ -245,6 +245,7 @@ def get_gpu_acceleration(enabled): def prevent_sleep_start(): from abogen.constants import PROGRAM_NAME + system = platform.system() if system == "Windows": import ctypes