Numbered items: also after a disc code (karaoke)
"Spotlight - 83xx's [16/19] - \"SC8367-12 - Wynette, Tammy - Singing My Song.zip\"": the disc-and-track code isn't a bare track number, so the poster-tag rule keyed every track by its own name. A stem starting with an upper-case code and digits before the track number (SC8367-12, ZMP050-04) is a numbered item too. Both implementations; tests; fixtures identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2814c77225
commit
8dfccc1c8e
3 files changed
+16
-3
No files matched your search
+11
-2
@@ -579,10 +579,17 @@ pub fn release_identity(poster: &str, subject: &str, name: &str) -> Release {
|
||||
let image = test(&IMAGE, name);
|
||||
// The poster's constant tag outside the quotes: the file's stem says which upload it is (not for images and audio).
|
||||
// Not for numbered items of a set ("003 Defining Tools with JSON Schema.mp4"): /^\d{1,3}[ ._-]/.
|
||||
// /^(?:[A-Z]{1,5}\d{2,6}[-_ ])?\d{1,3}[ ._-]/: also after a disc code ("SC8367-12 - …").
|
||||
let numbered = {
|
||||
let b = stem.as_bytes();
|
||||
let digits = b.iter().take_while(|c| c.is_ascii_digit()).count();
|
||||
(1..=3).contains(&digits) && matches!(b.get(digits), Some(b' ' | b'.' | b'_' | b'-'))
|
||||
let index_at = |at: usize| {
|
||||
let digits = b[at..].iter().take_while(|c| c.is_ascii_digit()).count();
|
||||
(1..=3).contains(&digits) && matches!(b.get(at + digits), Some(b' ' | b'.' | b'_' | b'-'))
|
||||
};
|
||||
let letters = b.iter().take_while(|c| c.is_ascii_uppercase()).count();
|
||||
let code_digits = b[letters..].iter().take_while(|c| c.is_ascii_digit()).count();
|
||||
let code = (1..=5).contains(&letters) && (2..=6).contains(&code_digits) && matches!(b.get(letters + code_digits), Some(b'-' | b'_' | b' '));
|
||||
index_at(0) || (code && index_at(letters + code_digits + 1))
|
||||
};
|
||||
let tag = !image && !numbered && !test(&AUDIO, name) && describes(&stem) && !looks_random(&stem) && is_poster_tag(&remainder, &stem);
|
||||
let prefix = if image { image_prefix(&stem) } else { String::new() };
|
||||
@@ -1085,6 +1092,8 @@ mod numbered_tests {
|
||||
let b = release_identity(poster, r#"ai-engineer-complete [422/465] - "006 ai-lesson-4-5-web-search-tools.zip" yEnc"#, "006 ai-lesson-4-5-web-search-tools.zip");
|
||||
assert_eq!(a.key, b.key);
|
||||
assert_eq!(a.name, "ai engineer complete");
|
||||
let sc = |t: &str| release_identity("p", &format!("Spotlight - 83xx's [16/19] - \"{t}.zip\" yEnc"), &format!("{t}.zip"));
|
||||
assert_eq!(sc("SC8367-12 - Wynette, Tammy - Singing My Song").key, sc("SC8367-13 - Jones, George - He Stopped Loving Her Today").key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user