From bea2f0b781ba4b1f5bd7dea2644854a141b3884d Mon Sep 17 00:00:00 2001 From: JayZed Date: Thu, 2 May 2024 06:32:03 -0400 Subject: [PATCH] Fixed embedded ASS subtitles writing encoding error For a couple of files, I had UnicodeEncodeErrors raised when writing out a file it had successfully read in. In my case, the output file was truncated to 1 KB. --- custom_libs/subliminal_patch/providers/embeddedsubtitles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_libs/subliminal_patch/providers/embeddedsubtitles.py b/custom_libs/subliminal_patch/providers/embeddedsubtitles.py index 1c1a99f7d..002f439b7 100644 --- a/custom_libs/subliminal_patch/providers/embeddedsubtitles.py +++ b/custom_libs/subliminal_patch/providers/embeddedsubtitles.py @@ -382,7 +382,7 @@ def _clean_ass_subtitles(path, output_path): logger.debug("Cleaned lines: %d", abs(len(lines) - len(clean_lines))) - with open(output_path, "w") as f: + with open(output_path, "w", encoding="utf-8", errors="ignore") as f: f.writelines(clean_lines) logger.debug("Lines written to output path: %s", output_path)