fix: count pt-BR as pt-PT in subtitle status (#286)
This commit was merged in pull request #286.
This commit is contained in:
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user