- 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
69 lines
2.0 KiB
Rust
69 lines
2.0 KiB
Rust
//! Example: File Mapping to Jellyfin Naming
|
|
//!
|
|
//! This example demonstrates how to scan a directory and map files
|
|
//! to Jellyfin-compatible naming conventions.
|
|
|
|
use movie_mapper::service::{FileMapper, FileScanner};
|
|
use std::env;
|
|
use std::path::Path;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
// Get directory from command line
|
|
let directory = env::args().nth(1).expect("Please provide a directory path");
|
|
|
|
let directory = Path::new(&directory);
|
|
|
|
// Get show information
|
|
let show_name = env::args()
|
|
.nth(2)
|
|
.unwrap_or_else(|| "Show Name".to_string());
|
|
|
|
let season_number: i32 = env::args().nth(3).and_then(|s| s.parse().ok()).unwrap_or(1);
|
|
|
|
println!("Scanning directory: {:?}", directory);
|
|
println!("Show name: {}", show_name);
|
|
println!("Season: {}", season_number);
|
|
|
|
// Create services
|
|
let scanner = FileScanner::new();
|
|
let mapper = FileMapper::new();
|
|
|
|
// Scan directory
|
|
println!("\nScanning directory...");
|
|
let files = match scanner.scan_directory(directory, None).await {
|
|
Ok(files) => files,
|
|
Err(e) => {
|
|
eprintln!("Error scanning directory: {}", e);
|
|
return;
|
|
}
|
|
};
|
|
|
|
println!("Found {} files/folders", files.len());
|
|
|
|
// Map files to Jellyfin naming
|
|
println!("\nMapping files to Jellyfin naming...");
|
|
let result = match mapper
|
|
.map_files(&files, &show_name, season_number, None)
|
|
.await
|
|
{
|
|
Ok(result) => result,
|
|
Err(e) => {
|
|
eprintln!("Error mapping files: {}", e);
|
|
return;
|
|
}
|
|
};
|
|
|
|
println!("\nMapping complete:");
|
|
println!(" Successfully renamed: {}", result.success);
|
|
println!(" Errors: {}", result.errors);
|
|
|
|
// Show sample of new filenames
|
|
println!("\nSample Jellyfin filenames:");
|
|
for i in 1..=3.min(result.success as i32) {
|
|
let filename =
|
|
mapper.generate_jellyfin_filename(&show_name, season_number, i, i, "1080p", ".mp4");
|
|
println!(" {}", filename);
|
|
}
|
|
}
|