use std::path::Path; /// Format a duration in seconds to a human-readable string pub fn format_duration(seconds: u64) -> String { let hours = seconds / 3600; let minutes = (seconds % 3600) / 60; let remaining_seconds = seconds % 60; if hours > 0 { format!("{}h {}m {}s", hours, minutes, remaining_seconds) } else if minutes > 0 { format!("{}m {}s", minutes, remaining_seconds) } else { format!("{}s", remaining_seconds) } } /// Format a file size in bytes to a human-readable string pub fn format_file_size(size: u64) -> String { const KB: u64 = 1024; const MB: u64 = KB * 1024; const GB: u64 = MB * 1024; if size >= GB { format!("{:.1} GB", size as f64 / GB as f64) } else if size >= MB { format!("{:.1} MB", size as f64 / MB as f64) } else if size >= KB { format!("{:.1} KB", size as f64 / KB as f64) } else { format!("{} B", size) } } /// Format video quality pub fn format_quality(width: Option, height: Option) -> String { match (width, height) { (Some(w), Some(h)) => { if w >= 3840 && h >= 2160 { "4K".to_string() } else if w >= 1920 && h >= 1080 { "1080p".to_string() } else if w >= 1280 && h >= 720 { "720p".to_string() } else if w >= 854 && h >= 480 { "480p".to_string() } else { format!("{}x{}", w, h) } } _ => "Unknown".to_string(), } } /// Get a display-friendly path string pub fn display_path(path: &Path) -> String { path.to_string_lossy().to_string() }