Handle missing display_aspect_ratio and movies differing only in case.

This commit is contained in:
Bill Thiede 2019-12-04 21:31:23 -08:00
parent 4d0ce2cd13
commit da717aeae1
2 changed files with 59 additions and 22 deletions

View File

@ -149,7 +149,7 @@ enum Stream {
codec_long_name: String,
coded_height: usize,
coded_width: usize,
display_aspect_ratio: String,
display_aspect_ratio: Option<String>,
#[serde(default, deserialize_with = "from_str")]
duration: f32,
height: usize,
@ -376,7 +376,10 @@ impl Movies {
let mut movie_counter = HashMap::new();
for m in &self.movies {
let (path, _cmd) = m.files.first().unwrap();
let parent = clean_path_parent(path).to_string_lossy().to_string();
let parent = clean_path_parent(path)
.to_string_lossy()
.to_ascii_lowercase()
.to_string();
movie_counter.entry(parent).or_insert(Vec::new()).push(m);
}
let mut dupes = Vec::new();

View File

@ -37,7 +37,7 @@ fn test_simple_library() {
short_name: "mp3".to_string(),
long_name: "MP3 (MPEG audio layer 3)".to_string(),
channels: 2,
channel_layout: "stereo".to_string(),
channel_layout: Some("stereo".to_string()),
title: None,
language: None,
}],
@ -116,6 +116,16 @@ fn build_complex_metadata() -> HashMap<String, CompactMetadata> {
(1920, 1080),
5000,
),
build_tuple(
"two movies different caps (2019)/abcdef123456789.mkv",
(1920, 1080),
100,
),
build_tuple(
"Two Movies Different Caps (2019)/abcdef123456789.mkv",
(640, 480),
1,
),
]
.into_iter()
.collect()
@ -158,6 +168,16 @@ fn build_complex_movies() -> Movies {
(1920, 1080),
5000,
)]),
build_movie(vec![(
"two movies different caps (2019)/abcdef123456789.mkv",
(1920, 1080),
100,
)]),
build_movie(vec![(
"Two Movies Different Caps (2019)/abcdef123456789.mkv",
(640, 480),
1,
)]),
],
};
m.movies.sort_by(|a, b| {
@ -200,25 +220,39 @@ fn validate_duplicates(got: Vec<(&Movie, Vec<&Movie>)>, want: Vec<(Movie, Vec<Mo
fn test_duplicate_candidates() -> Result<(), Box<dyn Error>> {
let movies = build_complex_movies();
let got = movies.duplicate_candidates();
let want = vec![(
build_movie(vec![(
"Two Movies With Multi Parts (2019)/somethingelse.mkv",
(1920, 1080),
5000,
)]),
vec![build_movie(vec![
(
"Two Movies With Multi Parts (2019)/abcdef123456789 part 1.mkv",
(1280, 720),
1000,
),
(
"Two Movies With Multi Parts (2019)/abcdef123456789 part 2.mkv",
(1280, 720),
1000,
),
])],
)];
let want = vec![
(
build_movie(vec![(
"Two Movies With Multi Parts (2019)/somethingelse.mkv",
(1920, 1080),
5000,
)]),
vec![build_movie(vec![
(
"Two Movies With Multi Parts (2019)/abcdef123456789 part 1.mkv",
(1280, 720),
1000,
),
(
"Two Movies With Multi Parts (2019)/abcdef123456789 part 2.mkv",
(1280, 720),
1000,
),
])],
),
(
build_movie(vec![(
"two movies different caps (2019)/abcdef123456789.mkv",
(1920, 1080),
100,
)]),
vec![build_movie(vec![(
"Two Movies Different Caps (2019)/abcdef123456789.mkv",
(640, 480),
1,
)])],
),
];
validate_duplicates(got, want);
Ok(())
}