feat(dl): add -fsl/--forced-s-lang to filter forced subtitles by language

This commit is contained in:
imSp4rky
2026-08-03 09:27:40 -06:00
parent b580ccdd42
commit 4e1ccf3230
11 changed files with 112 additions and 6 deletions
+1
View File
@@ -536,6 +536,7 @@ def _perform_download(
s_lang=params.get("s_lang", ["all"]),
require_subs=params.get("require_subs", []),
forced_subs=params.get("forced_subs", False),
forced_s_lang=params.get("forced_s_lang", []),
exact_lang=params.get("exact_lang", False),
sub_format=params.get("sub_format"),
video_only=params.get("video_only", False),
+1
View File
@@ -44,6 +44,7 @@ DEFAULT_DOWNLOAD_PARAMS = {
"s_lang": ["all"],
"require_subs": [],
"forced_subs": False,
"forced_s_lang": [],
"exact_lang": False,
"sub_format": None,
"video_only": False,
+5
View File
@@ -689,6 +689,11 @@ async def download(request: web.Request) -> web.Response:
forced_subs:
type: boolean
description: Include forced subtitle tracks (default - false)
forced_s_lang:
type: array
items:
type: string
description: Languages wanted for forced subtitles, implies forced_subs (default - [])
exact_lang:
type: boolean
description: Use exact language matching (no variants) (default - false)
+15
View File
@@ -163,6 +163,21 @@ def is_exact_match(language: Union[str, Language], languages: Sequence[Union[str
return closest_match(language, list(map(str, languages)))[1] <= LANGUAGE_EXACT_DISTANCE
def keep_forced_subtitle(
forced: bool,
language: Union[str, Language],
forced_s_lang: Sequence[str],
exact: bool = False,
) -> bool:
"""The -fsl filter: non-forced tracks always pass, forced tracks only if they match forced_s_lang."""
if not forced:
return True
if not forced_s_lang:
return False
match_func = is_exact_match if exact else is_close_match
return match_func(language, forced_s_lang)
def find_missing_langs(
requested: Sequence[str],
available: Sequence[Union[str, Language, None]],