mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-19 07:25:11 +00:00
feat(tracks)!: match a language tag to the variant it means
A tag with a region (en-US, es-419) matches only that variant and reports a miss instead of taking another region. A bare tag takes the variant it means (pt -> pt-BR, es -> es-ES) and falls back to any variant only when that one is missing. `orig` prefers the title's own tag, `-sl orig` resolves, forced and SDH subtitles are picked from their own pools, and the track name no longer strips the region from the cached language. BREAKING CHANGE: -l es-419 no longer selects es-ES, and language_priority, language_tags and muxing.default_language treat a regional tag as exact.
This commit is contained in:
@@ -46,10 +46,12 @@ def test_orig_resolves_to_the_title_language():
|
||||
assert missing_required_langs(["orig"], ["en"], None) == []
|
||||
|
||||
|
||||
def test_exact_lang_separates_a_regional_variant_from_its_base():
|
||||
def test_a_regional_tag_never_matches_another_region():
|
||||
assert missing_required_langs(["en-US"], ["en-US"], exact=True) == []
|
||||
assert missing_required_langs(["en-US"], ["en-GB"], exact=True) == ["en-US"]
|
||||
assert missing_required_langs(["en-US"], ["en-GB"]) == []
|
||||
assert missing_required_langs(["en-US"], ["en-GB"]) == ["en-US"]
|
||||
# 'orig' is the service's tag, so its region does not narrow the match
|
||||
assert missing_required_langs(["orig"], ["en-GB"], "en-US") == []
|
||||
|
||||
|
||||
def test_all_and_best_tokens_require_nothing():
|
||||
@@ -150,3 +152,8 @@ def test_all_three_require_flags_share_one_gate():
|
||||
for kind in ("audio", "video", "subtitle"):
|
||||
assert f'"{kind}",' in source
|
||||
assert "missing_required_langs(required, available, title.language, exact=exact_lang)" in source
|
||||
|
||||
|
||||
def test_exact_lang_turns_off_the_bare_tag_fallback():
|
||||
assert missing_required_langs(["en"], ["en-GB"]) == []
|
||||
assert missing_required_langs(["en"], ["en-GB"], exact=True) == ["en"]
|
||||
|
||||
Reference in New Issue
Block a user