diff --git a/crates/arr-api/src/search.rs b/crates/arr-api/src/search.rs index a2acfde..5d7dffa 100644 --- a/crates/arr-api/src/search.rs +++ b/crates/arr-api/src/search.rs @@ -490,8 +490,12 @@ fn classify( Candidate::PreGrab(&parsed), release.size.unwrap_or_default(), release.seeders.unwrap_or_default(), - ) - .total; + ); + let score = if release.size.is_some() { + score.total + } else { + score.source.saturating_add(score.seeders) + }; Ok(ClassifiedRelease { indexer_id: release.indexer_id, guid: release.guid, @@ -765,6 +769,55 @@ mod tests { ); } + #[test] + fn releases_without_sizes_skip_the_size_score() { + let policy = Policy { + id: PolicyId(1), + name: "test".into(), + required_audio: RequiredAudio::OriginalLanguage, + dub_blacklist: Vec::new(), + hdr_rules: HdrRules { + rejected_dolby_vision_profiles: Vec::new(), + }, + size_bands: std::collections::BTreeMap::from([( + Resolution::R2160p, + SizeBand { + floor_bytes: gib(8), + target_bytes: gib(22), + penalty_points_per_gib_over: 60, + }, + )]), + resolution_preference: vec![Resolution::R2160p], + source_weights: std::collections::BTreeMap::from([(Source::WebDl, 2)]), + score_weights: ScoreWeights::default(), + }; + let release = SearchRelease { + indexer_id: 1, + guid: "release".into(), + name: "Dune.Part.Two.2024.2160p.WEB-DL".into(), + size: None, + seeders: Some(8), + publish_date: None, + download_url: "https://tracker/release".into(), + }; + let parsed = arr_parse::parse(&release.name); + let core_score = score(&policy, Candidate::PreGrab(&parsed), 0, 8); + + let classified = classify( + release, + &policy, + &MovieOverrides::default(), + &Language::Other("en".into()), + ) + .expect("classified release"); + + assert_eq!( + classified.score, + core_score.source.saturating_add(core_score.seeders) + ); + assert_ne!(classified.score, core_score.total); + } + #[test] fn manual_inputs_skip_title_upstreams() { assert!(matches!(