Remove dashes and repeated spaces when comparing names for dupes.
This commit is contained in:
parent
b2ef1d3d3d
commit
70174e9e49
11
src/lib.rs
11
src/lib.rs
@ -371,16 +371,23 @@ impl Movies {
|
||||
/// If there is a yearless movie and one or more movies with a year exist, then the yearless
|
||||
/// movie will be removed
|
||||
pub fn duplicate_candidates(&self) -> Vec<(&Movie, Vec<&Movie>)> {
|
||||
lazy_static! {
|
||||
static ref MULTIPLE_SPACES: Regex = Regex::new(r"\s+").unwrap();
|
||||
}
|
||||
let date_re = Regex::new(r"\(\d{4}\)$").unwrap();
|
||||
let mut movie_counter = HashMap::new();
|
||||
let mut movies_without_date_counter = HashMap::new();
|
||||
for m in &self.movies {
|
||||
let (path, _cmd) = m.files.first().unwrap();
|
||||
let parent = clean_path_parent(path)
|
||||
let parent = MULTIPLE_SPACES
|
||||
.replace_all(
|
||||
&clean_path_parent(path)
|
||||
.to_string_lossy()
|
||||
.to_ascii_lowercase()
|
||||
.replace("-", " ")
|
||||
.replace("'", "")
|
||||
.replace("'", " "),
|
||||
" ",
|
||||
)
|
||||
.to_string();
|
||||
if date_re.is_match(&parent) {
|
||||
movie_counter.entry(parent).or_insert(Vec::new()).push(m);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user