Names: stray quotes, single quotes, hosts, bracketed names; dates, repeats
From the first corpus sweep (183 ranges):
- A stray quote took the last quote pair ('"x.mp3" "Album_BY_WaRLoRD',
'"x.nfo" " yEnc', '"x.nzb" yEnc"'): the last quoted part with an
extension is the name. Each file was a release of its own.
- A single-quoted name at the end ("… [001/106] 'You, Me And Dupree.nfo'"),
not the host before it (www.x2l.nl).
- Text ending in a host ("… www.libranews.nl") is no file name; a name in
brackets comes first ("[01/77][LIBRATEAM_M2219009.par2]",
"-^-[Mnozil Brass - Seven.nzb]-^-").
- A leading date is no item number ("09-30-2008_BAK_JRS.r00": a daily
show's 32,621 files were one release under the poster's tag).
- The file name repeated elsewhere in the subject goes too
("(NELET11.par2) [01/58] - "NELET11.par2"").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
885e4e6541
commit
1a5035d988
6 files changed
+115
-11
No files matched your search
+49
-2
@@ -282,6 +282,20 @@ pub fn name_beside_quotes(quoted: &str, before_counter: &str) -> Option<String>
|
||||
if has_extension(quoted) {
|
||||
return None;
|
||||
}
|
||||
// A stray quote took the last pair: the last quoted part that is a file name.
|
||||
let mut named = None;
|
||||
let mut rest = before_counter;
|
||||
while let Some(open) = rest.find('"') {
|
||||
let Some(close) = rest[open + 1..].find('"') else { break };
|
||||
let part = &rest[open + 1..open + 1 + close];
|
||||
if has_extension(part) {
|
||||
named = Some(part);
|
||||
}
|
||||
rest = &rest[open + 1 + close + 1..];
|
||||
}
|
||||
if let Some(part) = named {
|
||||
return Some(part.to_string());
|
||||
}
|
||||
// .replace(/"[^"]*"/g, ' ')
|
||||
let mut text = String::with_capacity(before_counter.len());
|
||||
let mut rest = before_counter;
|
||||
@@ -344,6 +358,15 @@ pub fn unquoted_name(before_counter: &str) -> Option<String> {
|
||||
let word = &before[before.rfind(' ').map_or(0, |i| i + 1)..];
|
||||
return has_extension(word).then(|| word.to_string());
|
||||
}
|
||||
// A single-quoted name at the end: /'([^']*[^.\s']\.[A-Za-z0-9]{2,4})'$/
|
||||
if let Some(inner) = text.strip_suffix('\'') {
|
||||
if let Some(open) = inner.rfind('\'') {
|
||||
let part = &inner[open + 1..];
|
||||
if has_extension(part) {
|
||||
return Some(part.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
if has_extension(text) {
|
||||
let bracket = text.rfind("] ").map_or(0, |i| i + 2);
|
||||
// A track or part number (/ - \d{1,3} - /): the name starts there; else after the last " - ".
|
||||
@@ -361,9 +384,30 @@ pub fn unquoted_name(before_counter: &str) -> Option<String> {
|
||||
return Some(last.to_string());
|
||||
}
|
||||
}
|
||||
return (!name.is_empty() && has_extension(name)).then(|| name.to_string());
|
||||
// Ending in a host is no file name: the one in brackets or a word follows.
|
||||
if !is_host(name) {
|
||||
return (!name.is_empty() && has_extension(name)).then(|| name.to_string());
|
||||
}
|
||||
}
|
||||
text.split(' ').find(|w| has_extension(w)).map(str::to_string)
|
||||
// A name in brackets: the last /\[([^[\]]*[^.\s[\]]\.[A-Za-z0-9]{2,4})\]/.
|
||||
let mut bracketed = None;
|
||||
for (open, _) in text.match_indices('[') {
|
||||
let inside = &text[open + 1..];
|
||||
let Some(close) = inside.find(']') else { break };
|
||||
let part = &inside[..close];
|
||||
if !part.contains('[') && has_extension(part) {
|
||||
bracketed = Some(part);
|
||||
}
|
||||
}
|
||||
if let Some(part) = bracketed {
|
||||
return Some(part.to_string());
|
||||
}
|
||||
text.split(' ').find(|w| has_extension(w) && !is_host(w)).map(str::to_string)
|
||||
}
|
||||
|
||||
/// /www\./i: a host ("www.libranews.nl"), whose ".nl" is no extension.
|
||||
fn is_host(s: &str) -> bool {
|
||||
s.to_ascii_lowercase().contains("www.")
|
||||
}
|
||||
|
||||
/// One line of an XOVER reply: number, subject, from, date, message-id, bytes, xref (scanOverviewText).
|
||||
@@ -935,6 +979,9 @@ mod unquoted_tests {
|
||||
("[03/21 Geroellheimer - S03E16.part01.rar\" yEnc ", Some("Geroellheimer - S03E16.part01.rar")),
|
||||
("<Group> FP -> {EXL01~P~004} -> Alexia (3) -> VF -> [0001 of 0076] -> Exclusive-tgirls_000000-lg.jpg ", Some("Exclusive-tgirls_000000-lg.jpg")),
|
||||
("<abm> <Duke> here's a little thanksgiving present: AB: part2 0573-1002 043.jpg ", Some("043.jpg")),
|
||||
("xlady post You, Me And Dupree www.x2l.nl [001/106] 'You, Me And Dupree.nfo'", Some("You, Me And Dupree.nfo")),
|
||||
("[01/77][LIBRATEAM_M2219009.par2] Onbeperkt downloaden met een snelheid van 1,22 MB p.s. en dat voor maar 7,95 p.m. www.libranews.nl", Some("LIBRATEAM_M2219009.par2")),
|
||||
("patensas post -^-[Mnozil Brass - Seven.nzb]-^-www.usenet2day.cc -^-[000/107]-^-www.libranews.nl-^- yEnc", Some("Mnozil Brass - Seven.nzb")),
|
||||
("[7w] - 9BbEV2MrTi59GBTEFlVrssBrXNwXf2SK9cQEeDjg yEnc ", None),
|
||||
("Re: Will somebody answer the question? ", None),
|
||||
];
|
||||
|
||||
Reference in new issue
Block a user