fix: count pt-BR as pt-PT in subtitle status (#286)
This commit was merged in pull request #286.
This commit is contained in:
@@ -713,14 +713,13 @@ async fn missing_for(
|
||||
subtitles: &[Subtitle],
|
||||
wanted: &[String],
|
||||
) -> Result<Vec<MissingSubtitle>, ApiError> {
|
||||
let satisfied: BTreeSet<&str> = subtitles
|
||||
.iter()
|
||||
.filter(|subtitle| !subtitle.forced)
|
||||
.map(|subtitle| subtitle.language.as_str())
|
||||
.collect();
|
||||
let gaps: Vec<&String> = wanted
|
||||
.iter()
|
||||
.filter(|language| !satisfied.contains(language.as_str()))
|
||||
.filter(|language| {
|
||||
!subtitles.iter().any(|subtitle| {
|
||||
!subtitle.forced && arr_core::subs::satisfies(language, &subtitle.language)
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
if gaps.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
@@ -3183,6 +3182,24 @@ mod tests {
|
||||
assert_eq!(missing[0]["language"], "en");
|
||||
}
|
||||
|
||||
/// §15: pt-BR satisfies a pt-PT want, so an embedded pt-BR track drops
|
||||
/// pt-PT from `missing` — the same rule the daemon's gap loop applies.
|
||||
#[tokio::test]
|
||||
async fn status_counts_pt_br_as_satisfying_pt_pt() {
|
||||
let fixture = stub_application().await;
|
||||
arr_db::subtitles::record_file(
|
||||
&fixture.pool,
|
||||
&arr_db::NewSubtitleFile::embedded(1, "pt-BR"),
|
||||
)
|
||||
.await
|
||||
.expect("embedded");
|
||||
|
||||
let statuses = status(&format!("{}/api/movies/1/subtitles/status", fixture.base)).await;
|
||||
let missing = statuses[0]["missing"].as_array().expect("missing");
|
||||
assert_eq!(missing.len(), 1, "{missing:?}");
|
||||
assert_eq!(missing[0]["language"], "en");
|
||||
}
|
||||
|
||||
/// #201: `no_candidates`, `capped` and `failed` carry the attempt row's
|
||||
/// own state, and `failed` also carries `last_failure` as `detail`.
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user