From 2971a3a7dae9343259e527459fbabe2274815663 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Tue, 8 Sep 2026 21:31:46 -0600 Subject: [PATCH] fix(manifests): flag DASH audio using the standard description role --- tests/core/test_dash_descriptive_audio.py | 39 +++++++++++++++++++++++ unshackle/core/manifests/dash.py | 6 +++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/core/test_dash_descriptive_audio.py diff --git a/tests/core/test_dash_descriptive_audio.py b/tests/core/test_dash_descriptive_audio.py new file mode 100644 index 00000000..06da4976 --- /dev/null +++ b/tests/core/test_dash_descriptive_audio.py @@ -0,0 +1,39 @@ +import xml.etree.ElementTree as ET + +import pytest + +from unshackle.core.manifests.dash import DASH + + +def adaptation_set(scheme: str, value: str) -> ET.Element: + return ET.fromstring(f'') + + +@pytest.mark.parametrize( + "scheme,value", + [ + # "description" is the value the DASH role scheme defines. Stan writes it, and reading only + # "descriptive" left every audio-description track unflagged. + ("urn:mpeg:dash:role:2011", "description"), + ("urn:mpeg:dash:role:2011", "descriptive"), + ("urn:tva:metadata:cs:AudioPurposeCS:2007", "1"), + ], +) +def test_descriptive_accessibility_values(scheme: str, value: str) -> None: + assert DASH.is_descriptive(adaptation_set(scheme, value)) is True + + +@pytest.mark.parametrize( + "scheme,value", + [ + ("urn:mpeg:dash:role:2011", "main"), + ("urn:mpeg:dash:role:2011", "caption"), + ("urn:tva:metadata:cs:AudioPurposeCS:2007", "2"), + ], +) +def test_non_descriptive_accessibility_values(scheme: str, value: str) -> None: + assert DASH.is_descriptive(adaptation_set(scheme, value)) is False + + +def test_no_accessibility_element() -> None: + assert DASH.is_descriptive(ET.fromstring("")) is False diff --git a/unshackle/core/manifests/dash.py b/unshackle/core/manifests/dash.py index b059dd46..45425ba1 100644 --- a/unshackle/core/manifests/dash.py +++ b/unshackle/core/manifests/dash.py @@ -1111,7 +1111,11 @@ class DASH: """Whether the Adaptation Set is Descriptive.""" return any( (x.get("schemeIdUri"), x.get("value")) - in (("urn:mpeg:dash:role:2011", "descriptive"), ("urn:tva:metadata:cs:AudioPurposeCS:2007", "1")) + in ( + ("urn:mpeg:dash:role:2011", "description"), + ("urn:mpeg:dash:role:2011", "descriptive"), + ("urn:tva:metadata:cs:AudioPurposeCS:2007", "1"), + ) for x in adaptation_set.findall("Accessibility") )