Import pipeline: probe, hardlink, rename, layout (#82)
This commit was merged in pull request #82.
This commit is contained in:
@@ -332,6 +332,27 @@ pub fn parse(name: &str) -> NameClaims {
|
||||
claims
|
||||
}
|
||||
|
||||
/// Collapse a release name to the blacklist key (`DESIGN.md` §6.3): lowercase,
|
||||
/// every run of non-alphanumerics as one dot. The same release reappearing
|
||||
/// with different separators or a different infohash still matches.
|
||||
#[must_use]
|
||||
pub fn normalise(name: &str) -> String {
|
||||
let mut out = String::with_capacity(name.len());
|
||||
let mut pending_gap = false;
|
||||
for character in name.chars() {
|
||||
if character.is_alphanumeric() {
|
||||
if pending_gap && !out.is_empty() {
|
||||
out.push('.');
|
||||
}
|
||||
pending_gap = false;
|
||||
out.extend(character.to_lowercase());
|
||||
} else {
|
||||
pending_gap = true;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn apply_marker(claims: &mut NameClaims, sources: &mut Vec<Source>, m: Marker) {
|
||||
match m {
|
||||
Marker::Resolution(r) => {
|
||||
|
||||
@@ -423,3 +423,15 @@ fn non_tv_names_claim_no_episode() {
|
||||
assert_eq!(parse(name).episode, None, "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normalisation_is_separator_and_case_blind() {
|
||||
let key = arr_parse::normalise("Dune.Part.Two.2024.2160p.WEB-DL.DDP5.1.Atmos");
|
||||
assert_eq!(key, "dune.part.two.2024.2160p.web.dl.ddp5.1.atmos");
|
||||
assert_eq!(
|
||||
arr_parse::normalise("dune part two [2024] 2160p WEB DL DDP5 1 atmos "),
|
||||
key,
|
||||
"the same release under different separators is the same blacklist key"
|
||||
);
|
||||
assert_eq!(arr_parse::normalise("!!!"), "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user