Added code to get tag info #10
51
src/lib.rs
51
src/lib.rs
@@ -38,6 +38,46 @@ mod meta {
|
||||
}
|
||||
}
|
||||
|
||||
mod meta_nouveaou {
|
||||
use super::*;
|
||||
|
||||
use metadata;
|
||||
|
||||
pub fn get_meta(t: meta_type::Type, filepath: &String) -> Result<String, std::io::Error> {
|
||||
match t {
|
||||
meta_type::Type::Title => match new_meta(&filepath) {
|
||||
Ok(metaa) => {
|
||||
let mut result = String::new();
|
||||
|
||||
for item in metaa.tags {
|
||||
result += &String::from(" ");
|
||||
result += &item.0;
|
||||
result += &item.1;
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
},
|
||||
/*
|
||||
meta_type::Type::Title
|
||||
meta_type::Type::Title
|
||||
meta_type::Type::Title
|
||||
meta_type::Type::Title
|
||||
*/
|
||||
_ => 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)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -52,5 +92,16 @@ mod tests {
|
||||
println!("Path: {:?}", full_path);
|
||||
|
||||
assert!(full_path.exists(), "Path does not exists {:?}", full_path);
|
||||
let filepath = full_path.display().to_string();
|
||||
|
||||
match meta_nouveaou::get_meta(meta_type::Type::Title, &filepath) {
|
||||
Ok(_title) => {
|
||||
let found = _title.contains("Just");
|
||||
assert!(found, "Meta information was not found");
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user