use std::fs;
use std::io::Read;
pub fn get_video_extensions() -> Result<Vec<String>, &'static str> {
fs::File::open("/etc/mime.types").ok()
.map_or(Err("tv-renamer: unable to open /etc/mime.types"), |mut file| {
let mut contents = String::with_capacity(file.metadata().map(|x| x.len()).unwrap_or(0) as usize);
file.read_to_string(&mut contents).ok()
.map_or(Err("tv-renamer: unable to read file to string"), |_| {
let mut extension_list = Vec::new();
for item in contents.lines().filter(|x| x.starts_with("video")) {
for extension in item.split_whitespace().skip(1).map(String::from).collect::<Vec<String>>() {
extension_list.push(extension);
}
}
Ok(extension_list)
})
})
}