diff --git a/src/main.rs b/src/main.rs index bb88ece..4a4dce6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -71,7 +71,7 @@ use std::sync::{Arc, Mutex}; use std::sync::mpsc::channel; use simplelog::{Config, TermLogger, LogLevelFilter}; #[cfg(unix)] -use simplelog::{SimpleLogger}; +use simplelog::SimpleLogger; mod api; mod config; @@ -126,9 +126,7 @@ fn init_log(log_level: LogLevelFilter, options: &getopts::Matches) -> Result<()> if let Err(e) = TermLogger::init(log_level, Config::default()) { bail!("Error starting terminal logger: {}", e); }; - } - else - { + } else { if let Err(e) = SimpleLogger::init(log_level, Config::default()) { bail!("Error starting simple logger: {}", e); } diff --git a/src/metadata.rs b/src/metadata.rs index e65b53e..99cfc44 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -35,7 +35,9 @@ pub fn read(path: &Path) -> Result { fn read_id3(path: &Path) -> Result { let tag = id3::Tag::read_from_path(&path)?; - let duration = mp3_duration::from_path(&path).map(|d| d.as_secs() as u32).ok(); + let duration = mp3_duration::from_path(&path) + .map(|d| d.as_secs() as u32) + .ok(); let artist = tag.artist().map(|s| s.to_string()); let album_artist = tag.album_artist().map(|s| s.to_string()); @@ -53,7 +55,7 @@ fn read_id3(path: &Path) -> Result { album_artist: album_artist, album: album, title: title, - duration: duration, + duration: duration, disc_number: disc_number, track_number: track_number, year: year, @@ -102,7 +104,7 @@ fn read_ape(path: &Path) -> Result { album_artist: album_artist, album: album, title: title, - duration: None, + duration: None, disc_number: disc_number, track_number: track_number, year: year, @@ -119,7 +121,7 @@ fn read_vorbis(path: &Path) -> Result { album_artist: None, album: None, title: None, - duration:None, + duration: None, disc_number: None, track_number: None, year: None, @@ -150,8 +152,10 @@ fn read_flac(path: &Path) -> Result { let year = vorbis.get("DATE").and_then(|d| d[0].parse::().ok()); let streaminfo = tag.get_blocks(metaflac::BlockType::StreamInfo); let duration = match streaminfo.first() { - Some(&&metaflac::Block::StreamInfo(ref s)) => Some((s.total_samples as u32 / s.sample_rate) as u32), - _ => None + Some(&&metaflac::Block::StreamInfo(ref s)) => { + Some((s.total_samples as u32 / s.sample_rate) as u32) + } + _ => None, }; Ok(SongTags { @@ -175,12 +179,19 @@ fn test_read_metadata() { artist: Some("TEST ARTIST".into()), album_artist: Some("TEST ALBUM ARTIST".into()), album: Some("TEST ALBUM".into()), - duration: None, + duration: None, year: Some(2016), }; - let flac_sample_tag = SongTags {duration: Some(0), ..sample_tags.clone()}; - let mp3_sample_tag = SongTags {duration: Some(0), ..sample_tags.clone()}; + let flac_sample_tag = SongTags { + duration: Some(0), + ..sample_tags.clone() + }; + let mp3_sample_tag = SongTags { + duration: Some(0), + ..sample_tags.clone() + }; assert_eq!(read(Path::new("test/sample.mp3")).unwrap(), mp3_sample_tag); assert_eq!(read(Path::new("test/sample.ogg")).unwrap(), sample_tags); - assert_eq!(read(Path::new("test/sample.flac")).unwrap(), flac_sample_tag); + assert_eq!(read(Path::new("test/sample.flac")).unwrap(), + flac_sample_tag); }