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 registry management to AppState and enhance platform detection

Tonho63b452df5c67
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index fb8cc104..9f33e237 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -13,6 +13,7 @@ pub mod storage;
pub struct AppState {
pub hotmart_session: Arc<tokio::sync::Mutex<Option<HotmartSession>>>,
pub active_downloads: Arc<tokio::sync::Mutex<HashMap<u64, CancellationToken>>>,
+ pub registry: core::registry::PlatformRegistry,
}
#[tauri::command]
@@ -24,9 +25,22 @@ fn greet(name: &str) -> String {
pub fn run() {
tracing_subscriber::fmt::init();
+ let session = Arc::new(tokio::sync::Mutex::new(None));
+
+ let mut registry = core::registry::PlatformRegistry::new();
+ registry.register(Box::new(
+ platforms::hotmart::downloader::HotmartDownloader::new(
+ session.clone(),
+ models::settings::AppSettings::default().download,
+ 20,
+ 3,
+ ),
+ ));
+
let state = AppState {
- hotmart_session: Arc::new(tokio::sync::Mutex::new(None)),
+ hotmart_session: session,
active_downloads: Arc::new(tokio::sync::Mutex::new(HashMap::new())),
+ registry,
};
tauri::Builder::default()
@@ -47,6 +61,7 @@ pub fn run() {
commands::downloads::start_course_download,
commands::downloads::cancel_course_download,
commands::downloads::get_active_downloads,
+ commands::downloads::detect_platform,
commands::settings::get_settings,
commands::settings::update_settings,
commands::settings::reset_settings,