summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorVitiko <[email protected]>2023-06-12 18:48:46 -0400
committerVitiko <[email protected]>2023-06-12 18:48:46 -0400
commit1c1caeb78bc156777b4f8a5f95ebc896a3922ab4 (patch)
tree5ea0ac2419c679e2cf7f9b361b55071ffdacf8fd /libs
parenta13d69ddb2f41fcba4bd78952db368b9cce6885c (diff)
downloadbazarr-1c1caeb78bc156777b4f8a5f95ebc896a3922ab4.tar.gz
bazarr-1c1caeb78bc156777b4f8a5f95ebc896a3922ab4.zip
Embedded Subtitles provider: handle ASS errors
Fix #2168
Diffstat (limited to 'libs')
-rw-r--r--libs/subliminal_patch/providers/embeddedsubtitles.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/libs/subliminal_patch/providers/embeddedsubtitles.py b/libs/subliminal_patch/providers/embeddedsubtitles.py
index 83a6f10d8..01f92f907 100644
--- a/libs/subliminal_patch/providers/embeddedsubtitles.py
+++ b/libs/subliminal_patch/providers/embeddedsubtitles.py
@@ -14,7 +14,6 @@ from fese import FFprobeSubtitleStream
from fese import FFprobeVideoContainer
from fese import tags
from fese.exceptions import InvalidSource
-from subliminal.subtitle import fix_line_ending
from subliminal_patch.core import Episode
from subliminal_patch.core import Movie
from subliminal_patch.providers import Provider
@@ -187,19 +186,18 @@ class EmbeddedSubtitlesProvider(Provider):
def download_subtitle(self, subtitle: EmbeddedSubtitle):
path = self._get_subtitle_path(subtitle)
- modifiers = _type_modifiers.get(subtitle.stream.codec_name)
- logger.debug(
- "Found modifiers for %s type: %s", subtitle.stream.codec_name, modifiers
- )
+ modifiers = _type_modifiers.get(subtitle.stream.codec_name) or set()
+ logger.debug("Found modifiers for %s type: %s", subtitle.stream, modifiers)
- if modifiers is not None:
- for mod in modifiers:
- logger.debug("Running %s modifier for %s", mod, path)
+ for mod in modifiers:
+ logger.debug("Running %s modifier for %s", mod, path)
+ try:
mod(path, path)
+ except Exception as error:
+ logger.debug("'%s' raised running modifier", error)
with open(path, "rb") as sub:
- content = sub.read()
- subtitle.content = fix_line_ending(content)
+ subtitle.content = sub.read()
def _get_subtitle_path(self, subtitle: EmbeddedSubtitle):
container = subtitle.container
@@ -341,7 +339,7 @@ def _clean_ass_subtitles(path, output_path):
clean_lines = []
- with open(path, "r") as f:
+ with open(path, "r", encoding="utf-8", errors="ignore") as f:
lines = f.readlines()
for line in lines:
if _SIGNS_LINE_RE.search(line) is None: