feat: rank 4K first, fall back to good 1080p
Resolution preference becomes strict tiers (step 10 000) and every size band gains a ceiling that waives bloated releases, so a 60 GB remux cannot win the top tier unattended. Movie grab, TV grab, RSS and the search deck now share one ranking key from arr-core. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
abb7e0a489
commit
cd9e8a891c
@@ -19,7 +19,7 @@ use std::sync::Arc;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use arr_core::policy::{evaluate, Candidate};
|
||||
use arr_core::score::{claimed_episode_count, score};
|
||||
use arr_core::score::{claimed_episode_count, score, RankKey};
|
||||
use arr_core::{Language, Policy, TitleOverrides, Verdict};
|
||||
use arr_db::{blacklist, Blacklist, Db, MoviePolicy};
|
||||
use arr_dl::{AddTorrent, QbitClient, TorrentSource};
|
||||
@@ -262,13 +262,7 @@ impl GrabAction {
|
||||
candidates.push(candidate);
|
||||
}
|
||||
}
|
||||
candidates.sort_by(|left, right| {
|
||||
right
|
||||
.score
|
||||
.cmp(&left.score)
|
||||
.then_with(|| left.indexer_id.cmp(&right.indexer_id))
|
||||
.then_with(|| left.guid.cmp(&right.guid))
|
||||
});
|
||||
candidates.sort_by(|left, right| left.rank_key().cmp(&right.rank_key()));
|
||||
Ok(candidates)
|
||||
}
|
||||
|
||||
@@ -885,6 +879,16 @@ pub(crate) struct Eligible {
|
||||
pub(crate) score: i64,
|
||||
}
|
||||
|
||||
impl Eligible {
|
||||
pub(crate) fn rank_key(&self) -> RankKey<'_> {
|
||||
RankKey {
|
||||
score: self.score,
|
||||
indexer_id: self.indexer_id,
|
||||
guid: &self.guid,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The gap, straight out of the domain rows (§8).
|
||||
///
|
||||
/// A title with an unfinished grab is not a gap — that is what stops a
|
||||
@@ -1648,7 +1652,7 @@ mod tests {
|
||||
<item>
|
||||
<title>Dune.Part.Two.2024.2160p.REMUX</title>
|
||||
<guid>huge</guid><link>https://tracker/huge.torrent</link>
|
||||
<size>64424509440</size>
|
||||
<size>42949672960</size>
|
||||
<torznab:attr xmlns:torznab="http://torznab.com/schemas/2015/feed" name="seeders" value="12"/>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -425,12 +425,7 @@ struct Grabbable {
|
||||
/// Better score first, then the tiebreaks targeted search sorts by, so both
|
||||
/// triggers pick the same release out of the same candidates.
|
||||
fn beats(candidate: &Eligible, incumbent: &Eligible) -> bool {
|
||||
candidate
|
||||
.score
|
||||
.cmp(&incumbent.score)
|
||||
.then_with(|| incumbent.indexer_id.cmp(&candidate.indexer_id))
|
||||
.then_with(|| incumbent.guid.cmp(&candidate.guid))
|
||||
== std::cmp::Ordering::Greater
|
||||
candidate.rank_key() < incumbent.rank_key()
|
||||
}
|
||||
|
||||
/// Every wanted title with neither a file nor a grab in flight.
|
||||
@@ -736,7 +731,7 @@ mod tests {
|
||||
<item>
|
||||
<title>Fallout.S01.2160p.WEB-DL.DDP5.1.Atmos.H.265-GROUP</title>
|
||||
<guid>tv-pack</guid><link>https://indexer.invalid/download/tv-pack</link>
|
||||
<enclosure url="https://indexer.invalid/download/tv-pack" length="85899345920"
|
||||
<enclosure url="https://indexer.invalid/download/tv-pack" length="10737418240"
|
||||
type="application/x-bittorrent"/>
|
||||
<torznab:attr name="seeders" value="120"/>
|
||||
</item>
|
||||
|
||||
@@ -1186,13 +1186,7 @@ fn best_candidate<'a>(
|
||||
let mut eligible: Vec<&Eligible> = candidates
|
||||
.filter_map(|candidate| candidate.eligible.as_ref())
|
||||
.collect();
|
||||
eligible.sort_by(|left, right| {
|
||||
right
|
||||
.score
|
||||
.cmp(&left.score)
|
||||
.then_with(|| left.indexer_id.cmp(&right.indexer_id))
|
||||
.then_with(|| left.guid.cmp(&right.guid))
|
||||
});
|
||||
eligible.sort_by(|left, right| left.rank_key().cmp(&right.rank_key()));
|
||||
eligible
|
||||
.into_iter()
|
||||
.find(|candidate| !blacklist.blocks_candidate(&candidate.name, &candidate.download_url))
|
||||
@@ -1239,7 +1233,7 @@ mod tests {
|
||||
<item>
|
||||
<title>Fallout.S01.2160p.WEB-DL.DDP5.1.Atmos</title>
|
||||
<guid>pack</guid><link>https://tracker/pack.torrent</link>
|
||||
<size>85899345920</size>
|
||||
<size>32212254720</size>
|
||||
<torznab:attr xmlns:torznab="http://torznab.com/schemas/2015/feed" name="seeders" value="120"/>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
Reference in New Issue
Block a user