fix(dash): treat a caption subtitle also marked SDH as SDH

This commit is contained in:
imSp4rky
2026-10-24 13:43:52 -06:00
parent 0de069f35a
commit 866420ed67
2 changed files with 21 additions and 2 deletions
+19
View File
@@ -0,0 +1,19 @@
import xml.etree.ElementTree as ET
from unshackle.core.manifests.dash import DASH
CAPTION = '<Role schemeIdUri="urn:mpeg:dash:role:2011" value="caption"/>'
SDH = '<Accessibility schemeIdUri="urn:tva:metadata:cs:AudioPurposeCS:2007" value="2"/>'
def test_caption_role_is_closed_caption() -> None:
element = ET.fromstring(f"<AdaptationSet>{CAPTION}</AdaptationSet>")
assert DASH.is_closed_caption(element) is True
assert DASH.is_sdh(element) is False
def test_caption_role_with_sdh_value_is_sdh_only() -> None:
# a Subtitle cannot be both CC and SDH, so a set marked both used to fail the whole title
element = ET.fromstring(f"<AdaptationSet>{CAPTION}{SDH}</AdaptationSet>")
assert DASH.is_closed_caption(element) is False
assert DASH.is_sdh(element) is True
+2 -2
View File
@@ -1293,8 +1293,8 @@ class DASH:
@staticmethod
def is_closed_caption(adaptation_set: Element) -> bool:
"""Whether the Adaptation Set is a Closed Caption Subtitle."""
return any(
"""Whether the Adaptation Set is a Closed Caption Subtitle. A caption that is also marked SDH counts as SDH."""
return not DASH.is_sdh(adaptation_set) and any(
(x.get("schemeIdUri"), x.get("value")) == ("urn:mpeg:dash:role:2011", "caption")
for x in adaptation_set.findall("Role")
)