feat: unified probe — dispatcher detects category, runs ffprobe/Python/meta per file type

This commit is contained in:
Accusys
2026-05-15 14:38:47 +08:00
parent 4ee8a42e76
commit 29eca5a224
5 changed files with 270 additions and 65 deletions

View File

@@ -117,19 +117,13 @@ pub async fn pre_process_file(file_path: &str) -> Option<String> {
let content_hash = crate::core::storage::content_hash::compute_sha256(&path).unwrap_or_default();
let probe_json: serde_json::Value = if let Ok(result) = crate::core::probe::probe_video(&canonical_str) {
serde_json::to_value(&result).unwrap_or_default()
} else {
let size = std::fs::metadata(&path).ok().map(|m| m.len()).unwrap_or(0);
serde_json::json!({
"format": {"filename": canonical_str, "size": size.to_string(), "format_name": "unknown"},
"streams": []
})
};
let scripts_dir = std::env::var("MOMENTRY_SCRIPTS_DIR")
.unwrap_or_else(|_| "/Users/accusys/momentry_core_0.1/scripts".to_string());
let python_path = std::env::var("MOMENTRY_PYTHON_PATH")
.unwrap_or_else(|_| "/opt/homebrew/bin/python3.11".to_string());
let probe_json = crate::core::probe::unified::unified_probe(&path, &scripts_dir, &python_path).await;
let file_type = if probe_json.get("streams").and_then(|s| s.as_array())
.map_or(false, |streams| streams.iter().any(|st| st.get("codec_type").and_then(|c| c.as_str()) == Some("video")))
{ "video" } else { "unknown" };
let file_type = probe_json.get("format").and_then(|f| f.get("file_type")).and_then(|v| v.as_str()).unwrap_or("unknown").to_string();
let pre_data = serde_json::json!({
"file_name": filename,