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.1 KB
Raw Blame
use async_trait::async_trait;

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

pub struct NoopDownloader;

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

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

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

    fn can_handle(&self, _url: &str) -> bool {
        false
    }

    async fn get_media_info(&self, _url: &str) -> anyhow::Result<MediaInfo> {
        Err(anyhow::anyhow!(
            "NoopDownloader cannot fetch media info; this item is driven by an external plugin"
        ))
    }

    async fn download(
        &self,
        _info: &MediaInfo,
        _opts: &DownloadOptions,
        _progress: tokio::sync::mpsc::Sender<libreget_core::models::progress::ProgressUpdate>,
    ) -> anyhow::Result<DownloadResult> {
        Err(anyhow::anyhow!(
            "NoopDownloader cannot drive download; this item is driven by an external plugin"
        ))
    }
}