feat: backup architecture docs, source code, and scripts

This commit is contained in:
Warren
2026-04-25 17:15:45 +08:00
parent 59809dae1f
commit 1f84e5469f
368 changed files with 146329 additions and 261 deletions
+40
View File
@@ -0,0 +1,40 @@
use anyhow::{Context, Result};
use serde::Deserialize;
use std::path::Path;
use tracing::{info, warn};
use crate::core::db::PostgresDb;
#[derive(Debug, Deserialize)]
pub struct CastEntry {
pub name: String,
pub role: String,
pub image: Option<String>,
}
/// Ingests TMDB cast data from the JSON file generated by `tmdb_cast_fetcher.py`
pub async fn ingest_cast(db: &PostgresDb, json_path: &str) -> Result<usize> {
let path = Path::new(json_path);
if !path.exists() {
return Err(anyhow::anyhow!("Cast JSON file not found: {}", json_path));
}
let content = std::fs::read_to_string(path)
.with_context(|| format!("Failed to read cast JSON: {}", json_path))?;
let cast_list: Vec<CastEntry> =
serde_json::from_str(&content).with_context(|| "Invalid cast JSON format")?;
let mut count = 0;
for entry in &cast_list {
match db.get_or_create_identity(&entry.name).await {
Ok(_talent) => {
info!("Ingested TMDB cast: {} as {}", entry.name, entry.role);
count += 1;
}
Err(e) => warn!("Failed to create talent '{}': {}", entry.name, e),
}
}
Ok(count)
}
+1
View File
@@ -0,0 +1 @@
pub mod ingest;