Take the image set head back out of the subject key
f1c5af5's set head (an image's name up to its first number) split sets whose images aren't named alike: "a1.jpg" beside "a1 (2).jpg", and "468_1000.jpg" whose first number is the image's (1 release became 211 and 161 on the corpus). The random volume stem stays. Tests keep both sets whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f1c5af5f36
commit
c624a624df
3 files changed
+8
-21
No files matched your search
+3
-13
@@ -813,15 +813,8 @@ pub fn release_identity(poster: &str, subject: &str, name: &str) -> Release {
|
||||
let one_word = image && remainder.len() >= 3 && remainder.bytes().all(|c| c.is_ascii_alphabetic());
|
||||
if !tag && (names_release(&remainder) || one_word) {
|
||||
// Without a counter an image's set: its name up to its last number, digits kept; none without numbers.
|
||||
let set = if image { image_set(&stem) } else { String::new() };
|
||||
let bound = total.clone().unwrap_or_else(|| set.clone());
|
||||
let bound = total.clone().unwrap_or_else(|| if image { image_set(&stem) } else { String::new() });
|
||||
let mut parts: Vec<&str> = vec!["subject", poster, &remainder, &bound];
|
||||
// An image's set as well under a counter ("Molly Set" [i/50]: "mo103x003.jpg"): its name up to its first number,
|
||||
// when another follows (/^(\D*\d+)\D+\d+/).
|
||||
let head = if image && total.is_some() { SET_HEAD.captures(stem.as_bytes()).map(|c| String::from_utf8(c[1].to_vec()).unwrap()) } else { None };
|
||||
if let Some(h) = head.as_deref() {
|
||||
parts.push(h);
|
||||
}
|
||||
// An upload's random stem on its volumes ("Z3mMTMPsoT4ikE_Di3fKnNF21.part01.rar" under "[ TOWN ] … [ TV ]").
|
||||
let stripped: String = stem.chars().filter(|c| !matches!(c, '-' | '_')).collect();
|
||||
if !image && test(&RANDOM_VOLUME, name) && stem.bytes().all(|c| c.is_ascii_alphanumeric() || c == b'_' || c == b'-') && looks_random(&stripped) {
|
||||
@@ -933,8 +926,6 @@ static SCENE_RELEASE: LazyLock<Regex> = LazyLock::new(|| {
|
||||
});
|
||||
/// RANDOM_VOLUME (lib/release/identity.ts): a file of a multi-volume upload.
|
||||
static RANDOM_VOLUME: LazyLock<Regex> = LazyLock::new(|| re(r"(?i)\.(?:part[0-9]+\.rar|vol[0-9]+[+-][0-9]+\.par2|par2|r[0-9]{2,3}|7z\.[0-9]{3}|zip\.[0-9]{3}|[0-9]{3})$"));
|
||||
/// An image's set head (lib/release/identity.ts): its name up to its first number, when another follows.
|
||||
static SET_HEAD: LazyLock<Regex> = LazyLock::new(|| re(r"^([^0-9]*[0-9]+)[^0-9]+[0-9]+"));
|
||||
static VOLUME_NUMBER: LazyLock<Regex> = LazyLock::new(|| re(r"^(.*[^0-9. ])[. ]([0-9]{1,5})\.?$"));
|
||||
|
||||
static GENERIC: LazyLock<Regex> = LazyLock::new(|| {
|
||||
@@ -1589,9 +1580,8 @@ mod image_set_tests {
|
||||
assert_ne!(town("01", "Z3mMTMPsoT4ikE_Di3fKnNF21.part01.rar").key, town("01", "i3DpbaTUJT4L6V48fEBdbVV46.part01.rar").key);
|
||||
let show = |i: &str, n: &str| super::release_identity("p", &format!(r#"Some.Show.S01E01 [{i}/20] - "{n}" yEnc"#), n);
|
||||
assert_eq!(show("01", "The.Big.Bang.Theory.S01E01.part01.rar").key, show("20", "The.Big.Bang.Theory.S01E01.nfo").key);
|
||||
let molly = |i: &str, n: &str| super::release_identity("p", &format!(r#"Molly Set [{i}/50] - "{n}" yEnc"#), n);
|
||||
assert_eq!(molly("01", "mo103x003.jpg").key, molly("02", "mo103x004.jpg").key);
|
||||
assert_ne!(molly("01", "mo103x003.jpg").key, molly("01", "mop120x032.jpg").key);
|
||||
let tender = |i: &str, n: &str| super::release_identity("p", &format!("Tender TEEN SEX in HD - File {i} of 435 - {n}"), n);
|
||||
assert_eq!(tender("001", "a1 (2).jpg").key, tender("002", "a1.jpg").key);
|
||||
let mdg = |post: &str, i: &str, n: &str| super::release_identity("p", &format!(r#"{post} - ({i}/90) "{n}" - 16,14 MB - yEnc"#), n);
|
||||
assert_eq!(mdg("MDG005b", "01", "IMG_2307.JPG").key, mdg("MDG005b", "02", "IMG_2308.jpg").key);
|
||||
assert_ne!(mdg("MDG005b", "01", "IMG_2307.JPG").key, mdg("MDG006a", "01", "IMG_4410.JPG").key);
|
||||
|
||||
Reference in new issue
Block a user