use chrono::{DateTime, Utc}; use std::path::PathBuf; /// Represents a media file or folder in the scanned directory #[derive(Debug, Clone)] pub struct MediaFile { pub path: PathBuf, pub name: String, pub size: u64, pub modified: DateTime, pub duration: String, pub quality: String, pub fps: String, pub is_folder: bool, pub is_problematic: bool, pub tags: Vec, } impl MediaFile { /// Create a new MediaFile from a path pub fn from_path(path: PathBuf) -> Self { let name = path .file_name() .and_then(|n| n.to_str()) .map(|s| s.to_string()) .unwrap_or_else(|| "Unknown".to_string()); Self { path, name, size: 0, modified: Utc::now(), duration: "00:00".to_string(), quality: "unknown".to_string(), fps: "unknown".to_string(), is_folder: false, is_problematic: false, tags: Vec::new(), } } /// Check if this file is tagged with the specified tag pub fn is_tagged(&self, tag: &str) -> bool { self.tags.iter().any(|t| t == tag) } /// Add a tag to this file pub fn add_tag(&mut self, tag: &str) { if !self.tags.iter().any(|t| t == tag) { self.tags.push(tag.to_string()); } } /// Remove a tag from this file pub fn remove_tag(&mut self, tag: &str) { self.tags.retain(|t| t != tag); } } /// Represents a file with its tag information #[derive(Debug, Clone)] pub struct TaggedFile { pub file: MediaFile, pub tag_type: String, } impl TaggedFile { /// Create a new TaggedFile pub fn new(file: MediaFile, tag_type: &str) -> Self { Self { file, tag_type: tag_type.to_string(), } } }