From 11a4d35023c8b50469196c834cdac232adc96230 Mon Sep 17 00:00:00 2001 From: xbmc4lyfe <273732874+xbmc4lyfe@users.noreply.github.com> Date: Sun, 8 Nov 2026 04:01:50 -0600 Subject: [PATCH] media: spot titles get looked up by the spot's kind, and lose a list number A spot's title is what its spotter typed: '01. The Matrix (1999) 4k UHD Rife 60fps AI-Enhanced Dolby True-HD Atmos' reads as no category to the name rules, so media lookup and the NFO's IMDb step skipped it with 'no movie or TV title in its name'. ReleaseInfo now carries the spot's kind, and the media steps take the movie or TV parse it names. parse_movie drops a leading list number ('01. ', '3 - ', '12) ') that has a space after it, so the title is 'The Matrix', 1999. Co-Authored-By: Claude Opus 5.5 --- src/media/parse.rs | 29 +++++++++++++++++++++++++++++ src/media/steps.rs | 26 ++++++++++++++++++++++++++ src/postprocess/engine.rs | 4 +++- src/postprocess/step.rs | 2 ++ src/spotnet/mod.rs | 9 +++++++++ src/web_pending.rs | 6 ++++-- 6 files changed, 73 insertions(+), 3 deletions(-) diff --git a/src/media/parse.rs b/src/media/parse.rs index de6d953f..ac6b9e84 100644 --- a/src/media/parse.rs +++ b/src/media/parse.rs @@ -238,7 +238,13 @@ pub fn parse_tv(name: &str) -> Option { }) } +/// A number a list puts before a title: `01. The Matrix (1999)`, `3 - Alien (1979)`, `12) Heat (1995)`. Only with +/// a space after it, so `21.Jump.Street.2012` and `1917 (2019)` keep their numbers. +static LIST_NUMBER: LazyLock = LazyLock::new(|| Regex::new(r"^\s*\d{1,3}\s*(?:[.)]|\s-)\s+").unwrap()); + pub fn parse_movie(name: &str) -> Option { + let name = LIST_NUMBER.replace(name, ""); + let name = name.as_ref(); let spaced = SPACES.replace_all(&name.replace(['.', '_'], " "), " ").into_owned(); let (raw, year): (String, Option) = if let Some(c) = M1.captures(&spaced) { (c[1].to_string(), c[2].parse().ok()) @@ -369,6 +375,29 @@ mod tests { assert!(wrong.is_empty(), "{}", wrong.join("\n")); } + #[test] + fn a_list_number_before_the_title_goes() { + // spot titles from a numbered series (spot K6rspFvcMg49TvvagOSea@spot.net and its sequels) + for (name, title, year) in [ + ("01. The Matrix (1999) 4k UHD Rife 60fps AI-Enhanced Dolby True-HD Atmos", "The Matrix", Some(1999)), + ( + "02. The Matrix Reloaded (2006) 4k UHD Rife 60fps AI-Enhanced Dolby True-HD Atmos", + "The Matrix Reloaded", + Some(2006), + ), + ("3 - Alien (1979) 1080p", "Alien", Some(1979)), + ("12) Heat (1995) 1080p", "Heat", Some(1995)), + // a number that is the title, or sits in a dotted name, stays + ("21.Jump.Street.2012.1080p.BluRay.x264-GRP", "21 Jump Street", Some(2012)), + ("1917 (2019) 2160p", "1917", Some(2019)), + ("300 (2006) 1080p BluRay", "300", Some(2006)), + ("2001 A Space Odyssey (1968) 1080p", "2001 A Space Odyssey", Some(1968)), + ] { + let got = parse_movie(name).unwrap_or_else(|| panic!("{name}")); + assert_eq!((got.title.as_str(), got.year), (title, year), "{name}"); + } + } + #[test] fn an_alias_gives_the_canonical_title() { assert_eq!(parse_tv("Daily.Show.S01E02.720p.WEB-GRP").unwrap().title, "The Daily Show"); diff --git a/src/media/steps.rs b/src/media/steps.rs index 4b61accf..a785ca00 100644 --- a/src/media/steps.rs +++ b/src/media/steps.rs @@ -146,6 +146,15 @@ fn name_of(r: &ReleaseInfo) -> &str { } fn target_of(media: &Media, r: &ReleaseInfo) -> Option<(Kind, Parsed)> { + // a spot's title is what its spotter typed, which the name rules often don't read as a movie or show: the + // spotter's kind says which it is (`spotnet::category`) + if let Some(kind) = r.spot_kind { + let category = match kind { + crate::spotnet::Kind::Movie => 2000, + crate::spotnet::Kind::Series => 5000, + }; + return media_target(category, "spot_kind", name_of(r)); + } let d: Decision = category::classify_release(r, &media.category_options()); media_target(d.category, d.rule, name_of(r)) } @@ -441,6 +450,23 @@ mod tests { use super::*; use std::path::Path; + #[test] + fn a_spots_kind_gives_its_title_to_look_up() { + // a name the category rules don't read as a movie: the spot says it is one + let media = Media::new(Path::new("/nowhere/atlas.db")); + let r = ReleaseInfo { + name: "01. The Matrix (1999) 4k UHD Rife 60fps AI-Enhanced Dolby True-HD Atmos".into(), + group: "alt.binaries.boneless".into(), + poster: Some("yEncBin@Poster.com (FrameMaster)".into()), + ..Default::default() + }; + assert!(target_of(&media, &r).is_none(), "no movie by its name alone"); + let spot = ReleaseInfo { spot_kind: Some(crate::spotnet::Kind::Movie), ..r }; + let (kind, p) = target_of(&media, &spot).unwrap(); + assert_eq!((kind, p.title.as_str(), p.year), (Kind::Movie, "The Matrix", Some(1999))); + assert_eq!(MediaLookup(media.clone()).skip_reason(&spot), None); + } + #[test] fn each_step_has_its_lane() { let media = Media::new(Path::new("/nowhere/atlas.db")); diff --git a/src/postprocess/engine.rs b/src/postprocess/engine.rs index 51f34194..bd736fdb 100644 --- a/src/postprocess/engine.rs +++ b/src/postprocess/engine.rs @@ -115,7 +115,8 @@ struct Row { const ROW_COLUMNS: &str = "r.id, r.name, r.display_name, r.group_name, r.poster, r.posted_date, coalesce(r.size, 0), coalesce(r.complete, 0), coalesce(r.parts, 0), r.file_total, coalesce(r.is_obfuscated, 0), r.name_source, s.release_id is not null, coalesce(s.done, 0), coalesce(s.failed, 0), coalesce(s.db_attempts, 0), - coalesce(s.net_attempts, 0), coalesce(s.parts_seen, 0), coalesce(s.rerun_gen, 0), coalesce(s.net_transient, 0)"; + coalesce(s.net_attempts, 0), coalesce(s.parts_seen, 0), coalesce(s.rerun_gen, 0), coalesce(s.net_transient, 0), + (select kind from spots where release_id = r.id)"; fn read_row(r: &SqlRow<'_>, at: usize, shard: usize) -> rusqlite::Result { let col = |i: usize| at + i; @@ -134,6 +135,7 @@ fn read_row(r: &SqlRow<'_>, at: usize, shard: usize) -> rusqlite::Result { file_total: r.get(col(9))?, is_obfuscated: r.get::<_, i64>(col(10))? != 0, name_source: r.get(col(11))?, + spot_kind: crate::spotnet::Kind::parse(r.get::<_, Option>(col(20))?.as_deref()), }, has_state: r.get(col(12))?, done: r.get(col(13))?, diff --git a/src/postprocess/step.rs b/src/postprocess/step.rs index 342d877e..886f17ba 100644 --- a/src/postprocess/step.rs +++ b/src/postprocess/step.rs @@ -85,6 +85,8 @@ pub struct ReleaseInfo { pub file_total: Option, pub is_obfuscated: bool, pub name_source: Option, + /// a movie or series, when the release was saved from a Spotnet spot that says so (`spotnet::store::SPOTS`) + pub spot_kind: Option, } /// What a step gets for one release. diff --git a/src/spotnet/mod.rs b/src/spotnet/mod.rs index a489eb9e..c0044adf 100644 --- a/src/spotnet/mod.rs +++ b/src/spotnet/mod.rs @@ -37,6 +37,15 @@ pub enum Kind { } impl Kind { + /// The kind a `spots` row's `kind` names, if any. + pub fn parse(kind: Option<&str>) -> Option { + match kind? { + "movie" => Some(Kind::Movie), + "series" => Some(Kind::Series), + _ => None, + } + } + pub fn as_str(self) -> &'static str { match self { Kind::Movie => "movie", diff --git a/src/web_pending.rs b/src/web_pending.rs index bccfbb6b..634df02c 100644 --- a/src/web_pending.rs +++ b/src/web_pending.rs @@ -160,8 +160,9 @@ fn read_state(conn: &Connection, s: usize, id: i64) -> rusqlite::Result { .query_row( &format!( "select name, display_name, group_name, poster, posted_date, coalesce(size, 0), coalesce(complete, 0), - coalesce(parts, 0), file_total, coalesce(is_obfuscated, 0), name_source - from s{s}.releases where id = ?" + coalesce(parts, 0), file_total, coalesce(is_obfuscated, 0), name_source, + (select kind from s{s}.spots where release_id = ?1) + from s{s}.releases where id = ?1" ), [id], |r| { @@ -179,6 +180,7 @@ fn read_state(conn: &Connection, s: usize, id: i64) -> rusqlite::Result { file_total: r.get(8)?, is_obfuscated: r.get::<_, i64>(9)? != 0, name_source: r.get(10)?, + spot_kind: crate::spotnet::Kind::parse(r.get::<_, Option>(11)?.as_deref()), }) }, )