use std::path::{Path, PathBuf}; const VIDEO_EXTENSIONS: &[&str] = &[".mp4", ".mkv", ".avi", ".mov", ".webm", ".m4v"]; pub fn is_video_file(path: &Path) -> bool { if let Some(ext) = path.extension() { if let Some(ext_str) = ext.to_str() { return VIDEO_EXTENSIONS.contains(&ext_str.to_lowercase().as_str()); } } false } pub fn find_largest_video_file(files: &[(String, u64)]) -> Option<(usize, String, u64)> { let video_files: Vec<_> = files .iter() .enumerate() .filter(|(_, (name, _))| { let path = Path::new(name); is_video_file(path) }) .map(|(idx, (name, size))| (idx, name.clone(), *size)) .collect(); if video_files.is_empty() { return None; } // Find the largest video file video_files .into_iter() .max_by_key(|(_, _, size)| *size) .map(|(idx, name, size)| (idx, name, size)) }