Use id3 duration when available

This commit is contained in:
Antoine Gersant 2025-02-04 00:51:10 -08:00
parent 2a1c93c462
commit f35c4efac3

View file

@ -111,12 +111,11 @@ fn read_id3<P: AsRef<Path>>(path: P) -> Result<SongMetadata, Error> {
fn read_mp3<P: AsRef<Path>>(path: P) -> Result<SongMetadata, Error> {
let mut metadata = read_id3(&path)?;
let duration = {
metadata.duration = metadata.duration.or_else(|| {
mp3_duration::from_path(path)
.map(|d| d.as_secs() as u32)
.ok()
};
metadata.duration = duration;
});
Ok(metadata)
}