Use a lazy quantifier in the title capture group so that the titleSeparator capture group actually works
This commit is contained in:
parent
9bd87f4e60
commit
a834ab8bb9
2 changed files with 5 additions and 11 deletions
10
src/main.rs
10
src/main.rs
|
@ -13,7 +13,7 @@ use rules::*;
|
|||
use utils::status_icon::*;
|
||||
|
||||
const VIDEO_EXTENSIONS: [&str; 14] = ["mkv", "mp4", "avi", "webm", "mov", "wmv", "flv", "ogg", "ogv", "yuv", "amv", "mpg", "mpeg", "m4v"];
|
||||
pub(crate) const SERIES_REGEX: &str = r"^(?P<title>.+)(?P<titleSeparator>-\s)?(?P<seasonPrefix>[Ss]|\s|\.)(?P<season>\d{1,3})(?P<episodePrefix>[Ee]|[Xx]|[Ss])(?P<episode>\d{1,3})([Ee](?P<episode2>\d{2,3}))?((?P<nameSeparator>\s-\s)?(?P<name>.+))?\.(?P<ext>...)$";
|
||||
pub(crate) const SERIES_REGEX: &str = r"^(?P<title>.*?)(?P<titleSeparator>\s-\s?)?(?P<seasonPrefix>[Ss]|\s|\.)(?P<season>\d{1,3})(?P<episodePrefix>[Ee]|[Xx]|[Ss])(?P<episode>\d{1,3})([Ee](?P<episode2>\d{2,3}))?((?P<nameSeparator>\s-\s)?(?P<name>.+))?\.(?P<ext>...)$";
|
||||
// const FILE_EXT_REGEX: &str = r"^(?P<title>.+)\.(?P<ext>...)$";
|
||||
// const MOVIE_REGEX: &str = r"^(?P<title>.+)\s(?P<year>\(\d{4}\))\s(?P<resolution>\[.+\])\.(?P<ext>...)$";
|
||||
|
||||
|
@ -107,6 +107,10 @@ fn lint_file_name(file: &DirEntry, filename: &str, regex: &Regex, episode_name:
|
|||
|
||||
let captures = captures.unwrap();
|
||||
|
||||
if let Some(reason) = DashInTitle::check(filename, &captures) {
|
||||
return ComplianceStatus::NonCompliant(reason);
|
||||
}
|
||||
|
||||
if let Some(reason) = EpisodeMarker::check(filename, &captures) {
|
||||
return ComplianceStatus::NonCompliant(reason);
|
||||
}
|
||||
|
@ -127,9 +131,5 @@ fn lint_file_name(file: &DirEntry, filename: &str, regex: &Regex, episode_name:
|
|||
return ComplianceStatus::NonCompliant(reason);
|
||||
}
|
||||
|
||||
if let Some(reason) = DashInTitle::check(filename, &captures) {
|
||||
return ComplianceStatus::NonCompliant(reason);
|
||||
}
|
||||
|
||||
ComplianceStatus::Compliant
|
||||
}
|
|
@ -10,12 +10,6 @@ impl Rule for DashInTitle {
|
|||
return Some(NonCompliantReason::DashInTitle)
|
||||
}
|
||||
|
||||
let title = captures.name("title").unwrap();
|
||||
|
||||
if title.as_str().contains("-") {
|
||||
return Some(NonCompliantReason::DashInTitle)
|
||||
}
|
||||
|
||||
return None
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue