diff --git a/src/lib.rs b/src/lib.rs index b20dcaf..24dab37 100644 --- a/src/lib.rs +++ b/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 { + 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 { + 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); + } + } } }