fix: count pt-BR as pt-PT in subtitle status (#286)
ci / web (push) Successful in 1m7s
e2e / e2e (push) Successful in 3m22s
ci / rust (push) Successful in 3m47s
ci / image (push) Successful in 3m24s

This commit was merged in pull request #286.
This commit is contained in:
2026-11-15 17:43:22 +00:00
parent 77e5177e24
commit e93e7cff0c
5 changed files with 50 additions and 17 deletions
+3 -1
View File
@@ -26,6 +26,7 @@ import {
type SubtitleCandidate,
type SubtitleSearchResults,
type SubtitleStatus,
satisfiesWanted,
searchSubtitles,
subtitleChipLabel,
subtitleRuleLabel,
@@ -84,7 +85,8 @@ function SubtitleChip({
return (
<Chip
data-verdict={
!subtitle.forced && (wanted === null || wanted.includes(subtitle.language))
!subtitle.forced &&
(wanted === null || wanted.some((language) => satisfiesWanted(language, subtitle.language)))
? "eligible"
: undefined
}
+13 -1
View File
@@ -538,6 +538,15 @@ const SUMMARY_SHOWN = 2;
* every non-forced language shows then, which is a superset rather than a
* wrong answer.
*/
/**
* Whether a subtitle in `have` settles a want for `wanted` — §15's pt-PT
* preferred, pt-BR accepted. Mirrors `arr_core::subs::satisfies`, which the
* server's `missing` list is computed with.
*/
export function satisfiesWanted(wanted: string, have: string): boolean {
return have === wanted || (wanted === "pt-PT" && (have === "pt-BR" || have === "por-unverified"));
}
export function wantedSubtitles(subtitles: Subtitle[], wanted: string[] | null): Subtitle[] {
const present = subtitles.filter((subtitle) => !subtitle.forced);
if (wanted === null) {
@@ -545,7 +554,10 @@ export function wantedSubtitles(subtitles: Subtitle[], wanted: string[] | null):
}
// the operator's order, not the file's: two files with the same languages
// must read identically at a glance
return wanted.flatMap((language) => present.filter((subtitle) => subtitle.language === language));
const ordered = wanted.flatMap((language) =>
present.filter((subtitle) => satisfiesWanted(language, subtitle.language)),
);
return [...new Set(ordered)];
}
export function subtitleSummary(status: SubtitleStatus, wanted: string[] | null): SubtitleSummary {