mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 21:50:28 +02:00
Fixed cannot access local variable 'is_narrow' error
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
# 1.2.0
|
||||||
|
- Fixed `cannot access local variable 'is_narrow'` error when subtitle format `SRT` was selected, mentioned by @Kinasa0096 in #88.
|
||||||
|
|
||||||
# 1.1.9
|
# 1.1.9
|
||||||
- Fixed the issue where spaces were deleted before punctuation marks while generating subtitles.
|
- Fixed the issue where spaces were deleted before punctuation marks while generating subtitles.
|
||||||
- Fixed markdown TOC generation breaks when "Replace single newlines" is enabled.
|
- Fixed markdown TOC generation breaks when "Replace single newlines" is enabled.
|
||||||
|
|||||||
+16
-7
@@ -554,6 +554,13 @@ class ConversionThread(QThread):
|
|||||||
merged_subtitle_path = (
|
merged_subtitle_path = (
|
||||||
os.path.splitext(merged_out_path)[0] + f".{file_extension}"
|
os.path.splitext(merged_out_path)[0] + f".{file_extension}"
|
||||||
)
|
)
|
||||||
|
# Default subtitle layout flags/strings so they exist regardless
|
||||||
|
# of whether ASS-specific handling runs. This prevents runtime
|
||||||
|
# errors when non-ASS formats (like SRT) are selected.
|
||||||
|
is_centered = False
|
||||||
|
is_narrow = False
|
||||||
|
merged_subtitle_margin = ""
|
||||||
|
merged_subtitle_alignment_tag = ""
|
||||||
if "ass" in subtitle_format:
|
if "ass" in subtitle_format:
|
||||||
merged_subtitle_file = open(
|
merged_subtitle_file = open(
|
||||||
merged_subtitle_path,
|
merged_subtitle_path,
|
||||||
@@ -705,13 +712,20 @@ class ConversionThread(QThread):
|
|||||||
chapter_subtitle_path = os.path.join(
|
chapter_subtitle_path = os.path.join(
|
||||||
chapters_out_dir, f"{chapter_filename}.{file_extension}"
|
chapters_out_dir, f"{chapter_filename}.{file_extension}"
|
||||||
)
|
)
|
||||||
if "ass" in subtitle_format:
|
# Ensure these variables exist even when not using ASS so
|
||||||
|
# later code can safely reference them.
|
||||||
|
is_centered = False
|
||||||
|
is_narrow = False
|
||||||
|
chapter_subtitle_margin = ""
|
||||||
|
chapter_subtitle_alignment_tag = ""
|
||||||
|
# Open the chapter subtitle file for writing for both SRT and ASS
|
||||||
chapter_subtitle_file = open(
|
chapter_subtitle_file = open(
|
||||||
chapter_subtitle_path,
|
chapter_subtitle_path,
|
||||||
"w",
|
"w",
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
errors="replace",
|
errors="replace",
|
||||||
)
|
)
|
||||||
|
if "ass" in subtitle_format:
|
||||||
# Minimal ASS header
|
# Minimal ASS header
|
||||||
chapter_subtitle_file.write("[Script Info]\n")
|
chapter_subtitle_file.write("[Script Info]\n")
|
||||||
chapter_subtitle_file.write("Title: Generated by Abogen\n")
|
chapter_subtitle_file.write("Title: Generated by Abogen\n")
|
||||||
@@ -740,12 +754,7 @@ class ConversionThread(QThread):
|
|||||||
f"{{\\an5}}" if is_centered else ""
|
f"{{\\an5}}" if is_centered else ""
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
chapter_subtitle_file = open(
|
chapter_subtitle_file = None
|
||||||
chapter_subtitle_path,
|
|
||||||
"w",
|
|
||||||
encoding="utf-8",
|
|
||||||
errors="replace",
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
chapter_subtitle_path = None
|
chapter_subtitle_path = None
|
||||||
chapter_subtitle_file = None
|
chapter_subtitle_file = None
|
||||||
|
|||||||
Reference in New Issue
Block a user