Jarian Cottingham 6dd4e83ddf feat: Add Rust implementation for performance-critical components
- Implement core Rust backend with FFmpeg integration
- Add TheTVDB API client with token caching
- Implement directory scanner with progress callbacks
- Create file manager with rename and move operations
- Add audit logging functionality
- Implement file mapping for TV episode renaming
- Build Node.js native addon via NAPI
- Include comprehensive unit and integration tests
- Update gitignore to exclude build artifacts and temp files

Resolves #TBD
2026-02-28 09:52:08 -06:00

76 lines
1.8 KiB
Rust

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<Utc>,
pub duration: String,
pub quality: String,
pub fps: String,
pub is_folder: bool,
pub is_problematic: bool,
pub tags: Vec<String>,
}
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(),
}
}
}