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(afyainternato): implement AfyaInternatoDownloader for course handling

Tonhofae19f47bf24
diff --git a/src-tauri/omniget-plugin-courses/src/platforms/afyainternato/mod.rs b/src-tauri/omniget-plugin-courses/src/platforms/afyainternato/mod.rs
new file mode 100644
index 00000000..684e988c
--- /dev/null
+++ b/src-tauri/omniget-plugin-courses/src/platforms/afyainternato/mod.rs
@@ -0,0 +1,71 @@
+pub mod api;
+pub mod downloader;
+
+use anyhow::anyhow;
+use async_trait::async_trait;
+use tokio::sync::mpsc;
+
+use omniget_core::models::media::{DownloadOptions, DownloadResult, MediaInfo, MediaType, VideoQuality};
+use crate::platforms::traits::PlatformDownloader;
+
+pub struct AfyaInternatoDownloader;
+
+impl AfyaInternatoDownloader {
+ pub fn new() -> Self {
+ Self
+ }
+}
+
+impl Default for AfyaInternatoDownloader {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+#[async_trait]
+impl PlatformDownloader for AfyaInternatoDownloader {
+ fn name(&self) -> &str {
+ "afyainternato"
+ }
+
+ fn can_handle(&self, url: &str) -> bool {
+ if let Ok(parsed) = url::Url::parse(url) {
+ if let Some(host) = parsed.host_str() {
+ let host = host.to_lowercase();
+ return host == "afya.com.br"
+ || host.ends_with(".afya.com.br");
+ }
+ }
+ false
+ }
+
+ async fn get_media_info(&self, url: &str) -> anyhow::Result<MediaInfo> {
+ Ok(MediaInfo {
+ title: "Afya Internato Course".to_string(),
+ author: String::new(),
+ platform: "afyainternato".to_string(),
+ duration_seconds: None,
+ thumbnail_url: None,
+ available_qualities: vec![VideoQuality {
+ label: "course".to_string(),
+ width: 0,
+ height: 0,
+ url: url.to_string(),
+ format: "course".to_string(),
+ }],
+ media_type: MediaType::Course,
+ file_size_bytes: None,
+ })
+ }
+
+ async fn download(
+ &self,
+ _info: &MediaInfo,
+ _opts: &DownloadOptions,
+ _progress: mpsc::Sender<f64>,
+ ) -> anyhow::Result<DownloadResult> {
+ Err(anyhow!(
+ "Use the courses interface to download Afya Internato courses"
+ ))
+ }
+}