From b829ea5c5e357127bbca8e7ea6f9846b930ce296 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 20 Feb 2024 19:29:21 +0000 Subject: [PATCH] DASH: Detect SDH subtitles via AudioPurposeCS:2007=2 --- devine/core/manifests/dash.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/devine/core/manifests/dash.py b/devine/core/manifests/dash.py index 425292f..af1008f 100644 --- a/devine/core/manifests/dash.py +++ b/devine/core/manifests/dash.py @@ -168,8 +168,9 @@ class DASH: track_type = Subtitle track_codec = Subtitle.Codec.from_codecs(codecs or "vtt") track_args = dict( - forced=self.is_forced(adaptation_set), - cc=self.is_closed_caption(adaptation_set) + cc=self.is_closed_caption(adaptation_set), + sdh=self.is_sdh(adaptation_set), + forced=self.is_forced(adaptation_set) ) elif content_type == "image": # we don't want what's likely thumbnails for the seekbar @@ -638,6 +639,14 @@ class DASH: for x in adaptation_set.findall("Role") ) + @staticmethod + def is_sdh(adaptation_set: Element) -> bool: + """Check if contents of Adaptation Set is for the Hearing Impaired.""" + return any( + (x.get("schemeIdUri"), x.get("value")) == ("urn:tva:metadata:cs:AudioPurposeCS:2007", "2") + for x in adaptation_set.findall("Accessibility") + ) + @staticmethod def is_closed_caption(adaptation_set: Element) -> bool: """Check if contents of Adaptation Set is a Closed Caption Subtitle."""