Use id3 duration when available
This commit is contained in:
parent
2a1c93c462
commit
f35c4efac3
1 changed files with 2 additions and 3 deletions
|
@ -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> {
|
fn read_mp3<P: AsRef<Path>>(path: P) -> Result<SongMetadata, Error> {
|
||||||
let mut metadata = read_id3(&path)?;
|
let mut metadata = read_id3(&path)?;
|
||||||
let duration = {
|
metadata.duration = metadata.duration.or_else(|| {
|
||||||
mp3_duration::from_path(path)
|
mp3_duration::from_path(path)
|
||||||
.map(|d| d.as_secs() as u32)
|
.map(|d| d.as_secs() as u32)
|
||||||
.ok()
|
.ok()
|
||||||
};
|
});
|
||||||
metadata.duration = duration;
|
|
||||||
Ok(metadata)
|
Ok(metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue