workflow_fix #12
38
src/lib.rs
38
src/lib.rs
@@ -18,6 +18,15 @@ mod meta_nouveaou {
|
||||
match t {
|
||||
meta_type::Type::Title => match new_meta(&filepath) {
|
||||
Ok(metaa) => {
|
||||
match get_val(t, metaa.tags) {
|
||||
Ok(val) => {
|
||||
return Ok(val);
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
/*
|
||||
for item in metaa.tags {
|
||||
if item.0 == "TITLE" {
|
||||
return Ok(item.1);
|
||||
@@ -28,6 +37,7 @@ mod meta_nouveaou {
|
||||
std::io::ErrorKind::InvalidData,
|
||||
"Tag not found",
|
||||
))
|
||||
*/
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
},
|
||||
@@ -44,6 +54,34 @@ mod meta_nouveaou {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_type(t: meta_type::Type) -> Result<String, std::io::Error> {
|
||||
match t {
|
||||
meta_type::Type::Title => Ok("TITLE".to_string()),
|
||||
meta_type::Type::Artist => Ok("ARTIST".to_string()),
|
||||
meta_type::Type::Album => Ok("".to_string()),
|
||||
meta_type::Type::Genre => Ok("".to_string()),
|
||||
meta_type::Type::Year => Ok("".to_string()),
|
||||
meta_type::Type::Track => Ok("".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_val(
|
||||
t: meta_type::Type,
|
||||
tags: Vec<((String, String))>,
|
||||
) -> Result<String, std::io::Error> {
|
||||
let type_ma: String = get_type(t).unwrap();
|
||||
for tag in tags {
|
||||
if tag.0 == type_ma {
|
||||
return Ok(tag.1);
|
||||
}
|
||||
}
|
||||
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidInput,
|
||||
"Invalid",
|
||||
));
|
||||
}
|
||||
|
||||
fn new_meta(filepath: &String) -> Result<metadata::MediaFileMetadata, std::io::Error> {
|
||||
let path = std::path::Path::new(&filepath);
|
||||
metadata::MediaFileMetadata::new(&path)
|
||||
|
Reference in New Issue
Block a user