use crate::types::File; use std::path::PathBuf; use walkdir::WalkDir; pub mod ascii_reduce; pub mod tag_extractor; pub mod transcoder; pub fn is_valid_file_extension(file_path: &PathBuf) -> bool { let ext = file_path.extension().unwrap().to_str().unwrap().to_string(); if ext == "mp3" { return true; } else if ext == "flac" { return true; } return false; } pub fn scan_for_music(src_dir: &String) -> Result, Box> { let mut files: Vec = Vec::new(); for entry in WalkDir::new(&src_dir) { let entry = entry.unwrap(); let entry_path = entry.into_path(); if entry_path.is_dir() { continue; } if is_valid_file_extension(&entry_path) { let file = File::from_path( src_dir.clone(), entry_path.into_os_string().into_string().unwrap(), ); files.push(file); } } Ok(files) }