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.

1.6 KB
Raw Blame
pub mod api;
pub mod downloader;

use anyhow::anyhow;
use async_trait::async_trait;
use tokio::sync::mpsc;

use crate::platforms::traits::PlatformDownloader;
use libreget_core::models::media::{DownloadOptions, DownloadResult, MediaInfo, MediaType};

pub struct VoompPlayDownloader;

impl VoompPlayDownloader {
    pub fn new() -> Self {
        Self
    }
}

impl Default for VoompPlayDownloader {
    fn default() -> Self {
        Self::new()
    }
}

#[async_trait]
impl PlatformDownloader for VoompPlayDownloader {
    fn name(&self) -> &str {
        "voompplay"
    }

    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 == "voompplay.com.br" || host.ends_with(".voompplay.com.br");
            }
        }
        false
    }

    async fn get_media_info(&self, _url: &str) -> anyhow::Result<MediaInfo> {
        Ok(MediaInfo {
            title: "Voomp Play".to_string(),
            author: String::new(),
            platform: "voompplay".to_string(),
            duration_seconds: None,
            thumbnail_url: None,
            available_qualities: vec![],
            media_type: MediaType::Course,
            file_size_bytes: None,
        })
    }

    async fn download(
        &self,
        _info: &MediaInfo,
        _opts: &DownloadOptions,
        _progress: tokio::sync::mpsc::Sender<libreget_core::models::progress::ProgressUpdate>,
    ) -> anyhow::Result<DownloadResult> {
        Err(anyhow!(
            "Use the courses interface to download from Voomp Play"
        ))
    }
}