summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorVitiko <[email protected]>2022-04-27 17:46:06 -0400
committerVitiko <[email protected]>2022-04-27 17:46:06 -0400
commitf01d916f95cf41d04df8576bce05165eaee56f35 (patch)
treefa73a8f36f21eb53a0e6bad162185a95883e8a36 /libs
parent5f29baca34adcbc96ef5fac74fe38996ae813f26 (diff)
downloadbazarr-f01d916f95cf41d04df8576bce05165eaee56f35.tar.gz
bazarr-f01d916f95cf41d04df8576bce05165eaee56f35.zip
Embedded subtitles provider: improve exception handlingv1.0.4-beta.29
Related to fese's library update. Close #1819
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/fese/__init__.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/libs/fese/__init__.py b/libs/fese/__init__.py
index 9752c959d..0c30ad013 100755
--- a/libs/fese/__init__.py
+++ b/libs/fese/__init__.py
@@ -14,7 +14,7 @@ from babelfish import Language
from babelfish.exceptions import LanguageError
import pysubs2
-__version__ = "0.1.2"
+__version__ = "0.1.3"
logger = logging.getLogger(__name__)
@@ -134,19 +134,21 @@ class FFprobeSubtitleStream:
# fixme: we still don't know if "DURATION" is a common tag/key
if "DURATION" in self.tags:
try:
- h, m, s = self.tags["DURATION"].split(":")
- except ValueError:
- pass
- else:
+ h, m, s = [
+ ts.replace(",", ".").strip()
+ for ts in self.tags["DURATION"].split(":")
+ ]
self.duration = float(s) + float(m) * 60 + float(h) * 60 * 60
self.duration_ts = int(self.duration * 1000)
+ except ValueError as error:
+ logger.warning("Couldn't get duration field: %s. Using 0", error)
else:
try:
- self.duration = float(stream.get("duration", 0))
- self.duration_ts = int(stream.get("duration_ts", 0))
+ self.duration = float(stream.get("duration", "0").replace(",", "."))
+ self.duration_ts = int(stream.get("duration_ts", self.duration * 1000))
# some subtitles streams miss a duration completely and has "N/A" as value
- except ValueError:
- pass
+ except ValueError as error:
+ logger.warning("Couldn't get duration field: %s. Using 0", error)
self.start_pts = int(stream.get("start_pts", 0))