mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-06-10 11:12:13 +00:00
feat(dl): gate s_lang/a_lang miss behind --best-available
Missing requested subtitle and audio languages now warn and continue when --best-available is set instead of hard-exiting. Without the flag, missing languages still produce an error and exit, matching the prior strict behavior. Audio missing-lang detection is now symmetric with subtitles. - add find_missing_langs helper in core/utilities for reuse between s_lang and a_lang paths (skips all/best/orig sentinels) - refactor dl.py s_lang/a_lang checks to share the helper - add tests/lang_selection covering match primitives, helper output, and tricky langcodes corners (zh-Hans/zh-Hant/zh-CN/zh-TW/zh-HK, cmn/yue, fil/tl/tgl) - clean up unused-var ruff F841 in tests/remote/unit/
This commit is contained in:
@@ -24,7 +24,6 @@ def _run(coro):
|
||||
|
||||
|
||||
def test_skips_when_client_does_not_accept_gzip() -> None:
|
||||
payload = b"x" * 4096
|
||||
body_json = json.dumps({"data": "x" * 4096}).encode()
|
||||
|
||||
async def handler(req): # noqa: ARG001
|
||||
|
||||
@@ -6,13 +6,8 @@ import json
|
||||
|
||||
import pytest
|
||||
|
||||
from unshackle.core.api.errors import (
|
||||
APIError,
|
||||
APIErrorCode,
|
||||
build_error_response,
|
||||
categorize_exception,
|
||||
handle_api_exception,
|
||||
)
|
||||
from unshackle.core.api.errors import (APIError, APIErrorCode, build_error_response, categorize_exception,
|
||||
handle_api_exception)
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
@@ -5,16 +5,9 @@ from __future__ import annotations
|
||||
import pytest
|
||||
from langcodes import Language
|
||||
|
||||
from unshackle.core.api.handlers import (
|
||||
sanitize_log,
|
||||
serialize_audio_track,
|
||||
serialize_drm,
|
||||
serialize_subtitle_track,
|
||||
serialize_title,
|
||||
serialize_video_track,
|
||||
validate_download_parameters,
|
||||
validate_service,
|
||||
)
|
||||
from unshackle.core.api.handlers import (sanitize_log, serialize_audio_track, serialize_drm, serialize_subtitle_track,
|
||||
serialize_title, serialize_video_track, validate_download_parameters,
|
||||
validate_service)
|
||||
from unshackle.core.titles.episode import Episode
|
||||
from unshackle.core.titles.movie import Movie
|
||||
from unshackle.core.tracks import Audio, Subtitle, Video
|
||||
|
||||
@@ -6,16 +6,8 @@ from enum import Enum
|
||||
|
||||
import pytest
|
||||
|
||||
from unshackle.core.remote_service import (
|
||||
_build_title,
|
||||
_build_tracks,
|
||||
_deserialize_audio,
|
||||
_deserialize_subtitle,
|
||||
_deserialize_video,
|
||||
_enum_get,
|
||||
_match_track,
|
||||
_reconstruct_drm,
|
||||
)
|
||||
from unshackle.core.remote_service import (_build_title, _build_tracks, _deserialize_audio, _deserialize_subtitle,
|
||||
_deserialize_video, _enum_get, _match_track, _reconstruct_drm)
|
||||
from unshackle.core.titles.episode import Episode
|
||||
from unshackle.core.titles.movie import Movie
|
||||
from unshackle.core.tracks import Audio, Subtitle, Video
|
||||
|
||||
@@ -105,7 +105,7 @@ async def test_get_session_store_returns_singleton() -> None:
|
||||
async def test_max_sessions_evicts_oldest(store: SessionStore, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(type(store), "_max_sessions", property(lambda _: 2))
|
||||
|
||||
a = await store.create("A", _FakeService(), session_id="a")
|
||||
await store.create("A", _FakeService(), session_id="a")
|
||||
await asyncio.sleep(0.01)
|
||||
b = await store.create("B", _FakeService(), session_id="b")
|
||||
await asyncio.sleep(0.01)
|
||||
|
||||
Reference in New Issue
Block a user