refactor(tracks): honour the best token and share one match rule

sort_subtitles resolved only the all token, while the video and audio sorts
resolved all and best. by_language now asks matching_languages rather than
repeating the RFC 4647 preference, with no behaviour change.
This commit is contained in:
imSp4rky
2026-08-03 10:29:09 -06:00
parent a6997f6bca
commit a5f5e7d14d
2 changed files with 14 additions and 17 deletions
+9 -2
View File
@@ -180,11 +180,18 @@ def test_no_priority_leaves_order_unchanged(many: Tracks) -> None:
assert langs(many) == ["ar", "bg", "en", "es", "fr", "ja"]
def test_all_alone_still_floats_the_original_language(many: Tracks) -> None:
many.sort_subtitles(by_language=["all"], group_by="language")
@pytest.mark.parametrize("token", ["all", "best"])
def test_magic_token_alone_floats_the_original_language(many: Tracks, token: str) -> None:
many.sort_subtitles(by_language=[token], group_by="language")
assert langs(many) == ["ja", "ar", "bg", "en", "es", "fr"]
@pytest.mark.parametrize("token", ["all", "best"])
def test_priority_outranks_either_magic_token(many: Tracks, token: str) -> None:
many.sort_subtitles(by_language=["en", "es", token], group_by="language")
assert langs(many) == ["en", "es", "ja", "ar", "bg", "fr"]
@pytest.fixture
def regionals() -> Tracks:
t = Tracks()