fix(core): waive untagged audio on main roots (#282)
This commit was merged in pull request #282.
This commit is contained in:
@@ -259,6 +259,15 @@ When none resolve it, tag the track `por-unverified` and surface it. Do not
|
||||
guess. Guessing toward `kids` gives a child a Brazilian dub; guessing toward
|
||||
`main` rejects a Brazilian film's own audio.
|
||||
|
||||
**Untagged audio.** A track tagged `und`, or carrying no language at all, says
|
||||
nothing. On `main`, when no track matches the original language but one is
|
||||
untagged, it is a soft fail (`audio_language_untagged`): import with a waiver
|
||||
instead of rejecting. Sloppy tags are common in WEB-DL packs, often on a single
|
||||
episode, and a hard fail there blacklists the whole pack (§5.7) over a file
|
||||
that almost always carries the original soundtrack. `kids` is unchanged: its
|
||||
missing-pt-PT case is already a soft fail, and an untagged track never counts
|
||||
as pt-PT.
|
||||
|
||||
**Sourcing consequence for `kids`.** European Portuguese dubs live almost
|
||||
entirely in streaming WEB-DLs (Disney+, Netflix, Max) and essentially never in
|
||||
BluRay encodes or remuxes. That root biases hard toward WEB-DL sources, and
|
||||
|
||||
@@ -243,8 +243,7 @@ async fn probe_subtitles(state: &AppState) -> SubtitleHealth {
|
||||
// quiet rather than failing on data the operator has not entered yet.
|
||||
let enabled = settings
|
||||
.as_ref()
|
||||
.map(|settings| settings.providers_enabled.as_slice())
|
||||
.unwrap_or_default();
|
||||
.map_or_default(|settings| settings.providers_enabled.as_slice());
|
||||
let engine = settings
|
||||
.as_ref()
|
||||
.and_then(|settings| settings.translation_engine.as_deref());
|
||||
|
||||
@@ -947,6 +947,7 @@ fn rule_name(rule: &Rule) -> String {
|
||||
Rule::RequiredAudio => "required_audio".into(),
|
||||
Rule::DubBlacklist(_) => "dub_blacklist".into(),
|
||||
Rule::PortugueseUnverified => "portuguese_unverified".into(),
|
||||
Rule::AudioLanguageUntagged => "audio_language_untagged".into(),
|
||||
Rule::DolbyVisionProfile(_) => "dolby_vision_profile".into(),
|
||||
Rule::Resolution(_) => "resolution".into(),
|
||||
Rule::Source(_) => "source".into(),
|
||||
|
||||
@@ -641,10 +641,7 @@ async fn embedded_tracks_of(
|
||||
.fetch_optional(pool(state)?)
|
||||
.await?
|
||||
.flatten();
|
||||
Ok(probed
|
||||
.as_deref()
|
||||
.map(extractable_tracks)
|
||||
.unwrap_or_default())
|
||||
Ok(probed.as_deref().map_or_default(extractable_tracks))
|
||||
}
|
||||
|
||||
/// The `sub_tracks` array of a `probed` blob, filtered to what §15 allows an
|
||||
|
||||
@@ -422,6 +422,9 @@ pub enum Rule {
|
||||
DubBlacklist(Language),
|
||||
/// A Portuguese track whose pt-PT / pt-BR flavour no signal resolved.
|
||||
PortugueseUnverified,
|
||||
/// An audio track tagged `und` (or untagged) where none matched the
|
||||
/// original language: probably the original, but nothing says so.
|
||||
AudioLanguageUntagged,
|
||||
DolbyVisionProfile(DolbyVisionProfile),
|
||||
Resolution(Resolution),
|
||||
Source(Source),
|
||||
@@ -438,6 +441,7 @@ impl Rule {
|
||||
Self::RequiredAudio => "required_audio".into(),
|
||||
Self::DubBlacklist(_) => "dub_blacklist".into(),
|
||||
Self::PortugueseUnverified => "portuguese_unverified".into(),
|
||||
Self::AudioLanguageUntagged => "audio_language_untagged".into(),
|
||||
Self::DolbyVisionProfile(_) => "dolby_vision_profile".into(),
|
||||
Self::Resolution(_) => "resolution".into(),
|
||||
Self::Source(_) => "source".into(),
|
||||
|
||||
@@ -470,6 +470,13 @@ impl PolicyRule for RequiredAudioRule {
|
||||
if context.overrides.allow_english_audio && languages.contains(&english) {
|
||||
return RuleEvaluation::SoftFail(Rule::RequiredAudio);
|
||||
}
|
||||
if matches!(
|
||||
context.policy.required_audio,
|
||||
RequiredAudio::OriginalLanguage
|
||||
) && languages.contains(&Language::Other("und".to_owned()))
|
||||
{
|
||||
return RuleEvaluation::SoftFail(Rule::AudioLanguageUntagged);
|
||||
}
|
||||
Self::failure(context)
|
||||
}
|
||||
}
|
||||
@@ -1242,6 +1249,33 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn main_untagged_audio_is_waived_not_rejected() {
|
||||
let media = probed_audio(vec![track(Language::Other("und".to_owned()))]);
|
||||
assert_eq!(
|
||||
verdict_for(&policy(), &en(), Candidate::PostDownload(&media)),
|
||||
Verdict::Waived(Rule::AudioLanguageUntagged)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn main_untagged_audio_beside_the_original_stays_eligible() {
|
||||
let media = probed_audio(vec![track(en()), track(Language::Other("und".to_owned()))]);
|
||||
assert_eq!(
|
||||
verdict_for(&policy(), &en(), Candidate::PostDownload(&media)),
|
||||
Verdict::Eligible
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kids_untagged_audio_keeps_the_required_audio_waiver() {
|
||||
let media = probed_audio(vec![track(Language::Other("und".to_owned()))]);
|
||||
assert_eq!(
|
||||
verdict_for(&kids_policy(), &en(), Candidate::PostDownload(&media)),
|
||||
Verdict::Waived(Rule::RequiredAudio)
|
||||
);
|
||||
}
|
||||
|
||||
// §5.2 truth table, `kids` root: require pt-PT, or the original language
|
||||
// when that is already Portuguese; pt-BR never satisfies the requirement.
|
||||
|
||||
|
||||
@@ -165,14 +165,13 @@ impl FakeQbit {
|
||||
.torrents()
|
||||
.into_iter()
|
||||
.find(|torrent| torrent.hash.eq_ignore_ascii_case(&hash))
|
||||
.map(|torrent| {
|
||||
.map_or_default(|torrent| {
|
||||
torrent
|
||||
.files
|
||||
.into_iter()
|
||||
.map(|(path, size)| json!({"name": path, "size": size}))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
});
|
||||
ResponseTemplate::new(200).set_body_json(files)
|
||||
}
|
||||
|
||||
@@ -281,8 +280,7 @@ fn decode(input: &str) -> String {
|
||||
fn text(parts: &HashMap<String, Vec<u8>>, key: &str) -> String {
|
||||
parts
|
||||
.get(key)
|
||||
.map(|bytes| String::from_utf8_lossy(bytes).into_owned())
|
||||
.unwrap_or_default()
|
||||
.map_or_default(|bytes| String::from_utf8_lossy(bytes).into_owned())
|
||||
}
|
||||
|
||||
/// The named parts of a `multipart/form-data` body.
|
||||
|
||||
@@ -787,21 +787,19 @@ impl From<RawVideo> for Video {
|
||||
}
|
||||
|
||||
fn cast_from(raw: Option<RawCredits>) -> Vec<CastMember> {
|
||||
let mut cast: Vec<CastMember> = raw
|
||||
.map(|credits| {
|
||||
credits
|
||||
.cast
|
||||
.into_iter()
|
||||
.map(|member| CastMember {
|
||||
tmdb_id: member.id,
|
||||
name: member.name,
|
||||
character: member.character,
|
||||
profile_path: non_empty(member.profile_path),
|
||||
order: member.order,
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let mut cast: Vec<CastMember> = raw.map_or_default(|credits| {
|
||||
credits
|
||||
.cast
|
||||
.into_iter()
|
||||
.map(|member| CastMember {
|
||||
tmdb_id: member.id,
|
||||
name: member.name,
|
||||
character: member.character,
|
||||
profile_path: non_empty(member.profile_path),
|
||||
order: member.order,
|
||||
})
|
||||
.collect()
|
||||
});
|
||||
// TMDB's own ordering is by `order`; sorting makes the truncation hold
|
||||
// even if a fixture or future API revision sends them shuffled.
|
||||
cast.sort_by_key(|member| member.order);
|
||||
@@ -810,9 +808,8 @@ fn cast_from(raw: Option<RawCredits>) -> Vec<CastMember> {
|
||||
}
|
||||
|
||||
fn trailer_from(raw: Option<RawVideoList>) -> Option<Video> {
|
||||
let videos: Vec<Video> = raw
|
||||
.map(|list| list.results.into_iter().map(Into::into).collect())
|
||||
.unwrap_or_default();
|
||||
let videos: Vec<Video> =
|
||||
raw.map_or_default(|list| list.results.into_iter().map(Into::into).collect());
|
||||
select_trailer(&videos)
|
||||
}
|
||||
|
||||
|
||||
@@ -463,6 +463,7 @@ const RULE_LABEL: Record<string, string> = {
|
||||
required_audio: "audio",
|
||||
dub_blacklist: "dub",
|
||||
portuguese_unverified: "pt unverified",
|
||||
audio_language_untagged: "audio untagged",
|
||||
dolby_vision_profile: "dv profile",
|
||||
resolution: "resolution",
|
||||
source: "source",
|
||||
|
||||
Reference in New Issue
Block a user