mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-12 12:05:07 +00:00
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.
20 lines
731 B
Python
20 lines
731 B
Python
from langcodes import Language
|
|
|
|
from unshackle.core.tracks import Audio, Tracks
|
|
|
|
|
|
def audio(lang: str, bitrate: int, id_: str) -> Audio:
|
|
return Audio(url=f"http://x/{id_}", id_=id_, language=lang, codec=Audio.Codec.AAC, bitrate=bitrate, channels=2.0)
|
|
|
|
|
|
def test_naming_a_track_keeps_its_region() -> None:
|
|
track = audio("fr-FR", 128000, "a1")
|
|
assert track.name is None
|
|
assert track.language.territory == "FR"
|
|
assert Language.get("fr-FR").territory == "FR"
|
|
|
|
|
|
def test_a_regional_request_picks_its_own_variant_over_a_higher_bitrate_sibling() -> None:
|
|
tracks = [audio("fr-FR", 128000, "a1"), audio("fr-CA", 192000, "a2")]
|
|
assert [str(t.language) for t in Tracks.by_language(tracks, ["fr-FR"])] == ["fr-FR"]
|