remove_picture #23

Merged
phoenix merged 8 commits from remove_picture into devel 2025-04-19 01:07:52 +00:00
Showing only changes of commit 2c95407b78 - Show all commits

View File

@@ -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> {