better matches

This commit is contained in:
Max Bradbury 2022-11-06 23:27:30 +00:00
parent ef110fcb94
commit 3c471c46b0
1 changed files with 3 additions and 3 deletions

View File

@ -102,10 +102,10 @@ fn handle_mp3(file: DirEntry) {
} }
} }
/// if filename contains something like `(1971)` or `[2003]` it's a movie /// if filename contains something like `(1971)` or `[2003]` or `.1985.` it's a movie
fn is_movie(file: &DirEntry) -> bool { fn is_movie(file: &DirEntry) -> bool {
lazy_static! { lazy_static! {
static ref MOVIE: Regex = Regex::new(r"\(\d{4}\)|\[\d{4}]").unwrap(); static ref MOVIE: Regex = Regex::new(r"\.\d{4}\.|\(\d{4}\)|\[\d{4}]").unwrap();
} }
MOVIE.is_match(file.file_name().to_str().unwrap()) MOVIE.is_match(file.file_name().to_str().unwrap())
@ -114,7 +114,7 @@ fn is_movie(file: &DirEntry) -> bool {
/// if filename contains something like "S03E21" it's a TV programme /// if filename contains something like "S03E21" it's a TV programme
fn is_tv_episode(file: &DirEntry) -> bool { fn is_tv_episode(file: &DirEntry) -> bool {
lazy_static! { lazy_static! {
static ref TV: Regex = Regex::new(r"s\d{2}\s*e\d{2}").unwrap(); static ref TV: Regex = Regex::new(r"[sS]\d{2}\s*[eE][pP]?\d{2}").unwrap();
} }
TV.is_match(file.file_name().to_str().unwrap()) TV.is_match(file.file_name().to_str().unwrap())