Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add PlatformDownloader trait for media handling

Tonho0230970d790c
diff --git a/src-tauri/omniget-core/src/platforms/traits.rs b/src-tauri/omniget-core/src/platforms/traits.rs
new file mode 100644
index 00000000..62b0d3ef
--- /dev/null
+++ b/src-tauri/omniget-core/src/platforms/traits.rs
@@ -0,0 +1,16 @@
+use async_trait::async_trait;
+
+use crate::models::media::{DownloadOptions, DownloadResult, MediaInfo};
+
+#[async_trait]
+pub trait PlatformDownloader: Send + Sync {
+ fn name(&self) -> &str;
+ fn can_handle(&self, url: &str) -> bool;
+ async fn get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo>;
+ async fn download(
+ &self,
+ info: &MediaInfo,
+ opts: &DownloadOptions,
+ progress: tokio::sync::mpsc::Sender<f64>,
+ ) -> anyhow::Result<DownloadResult>;
+}