use crate::{providers::{hanime::HanimeProvider, perverzija::PerverzijaProvider, spankbang::SpankbangProvider}, util::cache::VideoCache, videos::VideoItem, DbPool};


pub mod perverzija;
pub mod hanime;
pub mod spankbang;

pub trait Provider{
    async fn get_videos(&self, cache: VideoCache, pool: DbPool, channel: String, sort: String, query: Option<String>, page: String, per_page: String, featured: String) -> Vec<VideoItem>;
}

#[derive(Debug, Clone)]
pub enum AnyProvider {
    Perverzija(PerverzijaProvider),
    Hanime(HanimeProvider),
    Spankbang(SpankbangProvider),
}
impl Provider for AnyProvider {
    async fn get_videos(&self, cache: VideoCache, pool:DbPool, channel: String, sort: String, query: Option<String>, page: String, per_page: String, featured: String) -> Vec<VideoItem> {
        match self {
            AnyProvider::Perverzija(p) => p.get_videos(cache.clone(), pool.clone(), channel.clone(), sort.clone(), query.clone(), page.clone(), per_page.clone(), featured.clone()).await,
            AnyProvider::Hanime(p) => p.get_videos(cache, pool, channel, sort, query, page, per_page, featured).await,
            AnyProvider::Spankbang(p) => p.get_videos(cache, pool, channel, sort, query, page, per_page, featured).await,
        }
    }
}
