remove_picture #23
31
src/meta.rs
31
src/meta.rs
@@ -118,6 +118,37 @@ pub mod coverart {
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_coverart(song_filepath: &String) -> Result<Vec<u8>, std::io::Error> {
|
||||
match std::fs::File::open(song_filepath) {
|
||||
Ok(mut file) => {
|
||||
match lofty::flac::FlacFile::read_from(
|
||||
&mut file,
|
||||
lofty::config::ParseOptions::new(),
|
||||
) {
|
||||
Ok(mut flac_file) => {
|
||||
let pictures = flac_file.pictures();
|
||||
let res = pictures.to_vec();
|
||||
if !res.is_empty() {
|
||||
let picture = &res[0];
|
||||
flac_file.remove_picture(0);
|
||||
Ok(picture.clone().0.into_data())
|
||||
} else {
|
||||
Err(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
"No pictures found",
|
||||
))
|
||||
}
|
||||
}
|
||||
Err(err) => Err(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidData,
|
||||
err.to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_meta(t: types::Type, filepath: &String) -> Result<String, std::io::Error> {
|
||||
|
Reference in New Issue
Block a user