summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVitiko <[email protected]>2022-11-25 23:42:32 -0400
committerVitiko <[email protected]>2022-11-25 23:42:32 -0400
commit8c3a844071e67db9d7d83f262527b01e804f91d2 (patch)
tree2214242c1fe2010e075cd14d2565b824ab7308a0
parentd064ac77ec3a8476733158cc2003186a2aa3241f (diff)
downloadbazarr-6f28b3437c7e38ea64157fdc3007ba87476d8280.tar.gz
bazarr-6f28b3437c7e38ea64157fdc3007ba87476d8280.zip
Embedded Provider: improve streams filteringv1.1.3-beta.24
-rwxr-xr-xlibs/fese/__init__.py2
-rw-r--r--libs/fese/disposition.py6
-rwxr-xr-xlibs/fese/stream.py6
-rw-r--r--libs/subliminal_patch/providers/embeddedsubtitles.py7
4 files changed, 19 insertions, 2 deletions
diff --git a/libs/fese/__init__.py b/libs/fese/__init__.py
index ae8c75c38..e22c03152 100755
--- a/libs/fese/__init__.py
+++ b/libs/fese/__init__.py
@@ -4,4 +4,4 @@
from .container import FFprobeVideoContainer
from .stream import FFprobeSubtitleStream
-__version__ = "0.2.3"
+__version__ = "0.2.5"
diff --git a/libs/fese/disposition.py b/libs/fese/disposition.py
index d3582fda5..8b72323cc 100644
--- a/libs/fese/disposition.py
+++ b/libs/fese/disposition.py
@@ -55,6 +55,12 @@ class FFprobeSubtitleDisposition:
def suffix(self):
return self._content_type or ""
+ def language_kwargs(self):
+ return {
+ "hi": self._content_type == "hearing_impaired",
+ "forced": self._content_type == "forced",
+ }
+
def __str__(self):
return self.suffix.upper() or "GENERIC"
diff --git a/libs/fese/stream.py b/libs/fese/stream.py
index 1039cdd8b..340951380 100755
--- a/libs/fese/stream.py
+++ b/libs/fese/stream.py
@@ -5,6 +5,8 @@ from __future__ import annotations
from datetime import timedelta
import logging
+from babelfish import Language
+
from .disposition import FFprobeSubtitleDisposition
from .exceptions import UnsupportedCodec
from .tags import FFprobeGenericSubtitleTags
@@ -85,6 +87,10 @@ class FFprobeSubtitleStream:
# Legacy
return self.tags.language
+ @language.setter
+ def language(self, value: Language):
+ self.tags.language = value
+
@property
def extension(self):
return self._codec["copy_format"] or self._codec["convert_default_format"] or ""
diff --git a/libs/subliminal_patch/providers/embeddedsubtitles.py b/libs/subliminal_patch/providers/embeddedsubtitles.py
index 38089070d..cc322ba43 100644
--- a/libs/subliminal_patch/providers/embeddedsubtitles.py
+++ b/libs/subliminal_patch/providers/embeddedsubtitles.py
@@ -297,8 +297,13 @@ def _discard_possible_incomplete_subtitles(streams):
valid_streams = []
for stream in streams:
+ # Make sure to update stream's language to reflect disposition
+ stream.language = Language.rebuild(
+ stream.language, **stream.disposition.language_kwargs()
+ )
+
# 500 < 1200
- if stream.tags.frames < max_frames // 2:
+ if not stream.language.forced and stream.tags.frames < max_frames // 2:
logger.debug(
"Possible bad subtitle found: %s (%s frames - %s frames)",
stream,