Counters: a total padded wider than its index is none; report diff on shared ranges
- "Very Best Of The Who [01/010]", "[02/020]", "[07/070]": a posting tool's
total of index×10, so every track had a total of its own and was a
release of its own. A total zero-padded wider than its index is no
counter ("[001/010]" still is).
- corpus_sweep.py report compares builds over the ranges both replayed (the
corpus grows between builds).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1a5035d988
commit
8e07478659
4 files changed
+53
-12
No files matched your search
+18
-1
@@ -385,8 +385,9 @@ fn finish_remainder(s: &str) -> String {
|
||||
pub fn counter_total(subject: &str) -> Option<String> {
|
||||
let s = replace("ED, subject, " ", true);
|
||||
if let Some(c) = COUNTERS_CAPTURE.captures(s.as_bytes()) {
|
||||
let index = c.get(1).or(c.get(3)).unwrap().as_bytes();
|
||||
let total = c.get(2).or(c.get(4)).unwrap().as_bytes();
|
||||
return Some(js_number_string(number(total)));
|
||||
return (!broken_total(index, total)).then(|| js_number_string(number(total)));
|
||||
}
|
||||
// Dates are no counters ("08-29-2011" read as 8 of 29).
|
||||
let undated = replace(&DATES, &s, " ", true);
|
||||
@@ -959,6 +960,11 @@ fn name_like(b: &[u8]) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
/// A total zero-padded wider than its index ("[01/010]"): a posting tool's mistake, no counter (brokenTotal).
|
||||
fn broken_total(index: &[u8], total: &[u8]) -> bool {
|
||||
total.len() > 1 && total[0] == b'0' && total.len() > index.len()
|
||||
}
|
||||
|
||||
/// The second number of the first \[(\d+)/(\d+)\].
|
||||
fn file_counter_total(s: &str) -> Option<i64> {
|
||||
let b = s.as_bytes();
|
||||
@@ -973,6 +979,9 @@ fn file_counter_total(s: &str) -> Option<i64> {
|
||||
}
|
||||
let d = b[slash + 1..].iter().take_while(|c| c.is_ascii_digit()).count();
|
||||
if d > 0 && b.get(slash + 1 + d) == Some(&b']') {
|
||||
if broken_total(&b[i + 1..slash], &b[slash + 1..slash + 1 + d]) {
|
||||
return None;
|
||||
}
|
||||
return js::parse_int(&s[slash + 1..slash + 1 + d]);
|
||||
}
|
||||
}
|
||||
@@ -1283,6 +1292,14 @@ mod image_set_tests {
|
||||
assert_ne!(vlad("185", 77, "P8250001.JPG").key, vlad("234", 77, "P5300085.JPG").key);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn totals_padded_wider_than_the_index_are_no_counters() {
|
||||
let who = |i: u32, n: &str| release_identity("p", &format!(r#"Very Best Of The Who [{i:02}/{:03}] - "{n}" yEnc"#, i * 10), n);
|
||||
assert_eq!(who(3, "The Who - 01 - I Can't Explain.mp3").key, who(4, "The Who - 02 - Anyway.mp3").key);
|
||||
assert_eq!(who(3, "The Who - 01 - I Can't Explain.mp3").file_total, None);
|
||||
assert_eq!(super::counter_total(r#"x [001/010] - "a.rar""#).as_deref(), Some("10"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dates_lead_no_numbered_items_and_repeated_names_go() {
|
||||
let show = |n: &str| release_identity("#sterntuary <aa@aa.com>", &format!(r#"#sterntuary - Jeff Rense Radio Program - "{n}" yEnc"#), n);
|
||||
|
||||
Reference in new issue
Block a user