diff --git a/devine/core/tracks/subtitle.py b/devine/core/tracks/subtitle.py index 97111da5..300b8946 100644 --- a/devine/core/tracks/subtitle.py +++ b/devine/core/tracks/subtitle.py @@ -16,6 +16,7 @@ from pycaption.geometry import Layout from pymp4.parser import MP4 from subtitle_filter import Subtitles +from subby import ISMTConverter from devine.core import binaries from devine.core.tracks.track import Track @@ -274,6 +275,12 @@ def convert(self, codec: Subtitle.Codec) -> Path: stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) + elif self.codec in Subtitle.Codec.fTTML: + output_path = self.path.with_suffix(".srt") + converter = ISMTConverter() + srt = converter.from_file(self.path) + srt.save(output_path) + codec = Subtitle.Codec.SubRip else: writer = { # pycaption generally only supports these subtitle formats diff --git a/pyproject.toml b/pyproject.toml index 5b6012ea..502ee32a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,6 +62,7 @@ Unidecode = "^1.3.8" urllib3 = "^2.2.1" chardet = "^5.2.0" curl-cffi = "^0.7.0b4" +subby = {git = "https://github.com/Parasitic5283/subby.git", rev = "Update-lxml"} # Until https://github.com/vevv/subby/pull/31 is merged [tool.poetry.dev-dependencies] pre-commit = "^3.7.0"