Files
unshackle/tests/core/test_dash_descriptive_audio.py
T
imSp4rky 3477d09cc2 feat(dl): add --audio-description-only and --forced-subs-only
Each keeps one kind of track inside its track type. A run of more than one title skips a title that has no such track. The REST API rejects a non-boolean value for a boolean dl param, and the DASH parser reads audio description from Role elements.
2026-10-06 12:45:52 -06:00

50 lines
1.7 KiB
Python

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'<AdaptationSet><Accessibility schemeIdUri="{scheme}" value="{value}"/></AdaptationSet>')
@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("<AdaptationSet/>")) is False
def test_descriptive_role_element() -> None:
# some manifests mark audio description with a Role and no Accessibility element
element = ET.fromstring(
'<AdaptationSet><Role schemeIdUri="urn:mpeg:dash:role:2011" value="description"/></AdaptationSet>'
)
assert DASH.is_descriptive(element) is True
main = ET.fromstring('<AdaptationSet><Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/></AdaptationSet>')
assert DASH.is_descriptive(main) is False