Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(project): add missing_media() detection method

Domica4296aa3d11dd
diff --git a/engine/crates/concat-project/src/model.rs b/engine/crates/concat-project/src/model.rs
index 18b4a3b3..70b66731 100644
--- a/engine/crates/concat-project/src/model.rs
+++ b/engine/crates/concat-project/src/model.rs
@@ -1197,6 +1197,17 @@ pub struct Project {
pub active_timeline_id: String,
}
+/// A media reference that points to a non-existent file.
+#[derive(Clone, Debug)]
+pub struct MissingMedia {
+ /// The media item's stable id (e.g. "m1", "m2").
+ pub id: String,
+ /// Display name in the bin.
+ pub name: String,
+ /// The absolute path that no longer exists on disk.
+ pub path: String,
+}
+
impl Project {
/// A new project: one timeline, four lanes, at the default frame.
pub fn new() -> Self {
@@ -1251,6 +1262,19 @@ impl Project {
pub fn media_by_id(&self, media_id: &str) -> Option<&MediaItem> {
self.media.iter().find(|item| item.id == media_id)
}
+
+ /// Returns every media item whose file does not exist on disk.
+ pub fn missing_media(&self) -> Vec<MissingMedia> {
+ self.media
+ .iter()
+ .filter(|item| !std::path::Path::new(&item.path).exists())
+ .map(|item| MissingMedia {
+ id: item.id.clone(),
+ name: item.name.clone(),
+ path: item.path.clone(),
+ })
+ .collect()
+ }
}
impl MediaItem {