diff --git a/src/api.rs b/src/api.rs index 78fa3f2..6081348 100644 --- a/src/api.rs +++ b/src/api.rs @@ -115,6 +115,7 @@ async fn status(req: HttpRequest) -> Result { .unwrap_or_default() .to_string(); let mut status = Status::new(); + // pronhub status.add_channel(Channel { id: "pornhub".to_string(), name: "Pornhub".to_string(), @@ -126,6 +127,7 @@ async fn status(req: HttpRequest) -> Result { options: vec![], nsfw: true, }); + // pmvhaven status.add_channel(Channel { id: "pmvhaven".to_string(), name: "Pmvhaven".to_string(), @@ -134,11 +136,49 @@ async fn status(req: HttpRequest) -> Result { favicon: "https://www.google.com/s2/favicons?sz=64&domain=pmvhaven.com".to_string(), status: "active".to_string(), categories: vec![], - options: vec![], + options: vec![ + ChannelOption { + id: "category".to_string(), + title: "Category".to_string(), + description: "Category of PMV Video get".to_string(), //"Sort the videos by Date or Name.".to_string(), + systemImage: "list.number".to_string(), + colorName: "blue".to_string(), + options: vec![ + FilterOption { + id: "all".to_string(), + title: "All".to_string(), + }, + FilterOption { + id: "pmv".to_string(), + title: "PMV".to_string(), + }, + FilterOption { + id: "hmv".to_string(), + title: "HMV".to_string(), + }, + FilterOption { + id: "tiktok".to_string(), + title: "Tiktok".to_string(), + }, + FilterOption { + id: "koreanbj".to_string(), + title: "KoreanBJ".to_string(), + }, + FilterOption { + id: "hypno".to_string(), + title: "Hypno".to_string(), + }, + FilterOption { + id: "other".to_string(), + title: "Other".to_string(), + }, + ], + multiSelect: false, + },], nsfw: true, }); if clientversion >= ClientVersion::new(22, 97, "22a".to_string()) { - //add perverzija + // perverzija status.add_channel(Channel { id: "perverzija".to_string(), name: "Perverzija".to_string(), diff --git a/src/providers/hanime.rs b/src/providers/hanime.rs index 21f8c79..ee5fa89 100644 --- a/src/providers/hanime.rs +++ b/src/providers/hanime.rs @@ -189,7 +189,7 @@ impl HanimeProvider { } async fn get(&self, cache: VideoCache, pool: DbPool, page: u8, query: String, sort:String) -> Result> { - let index = format!("{}:{}:{}", query, page, sort); + let index = format!("hanime:{}:{}:{}", query, page, sort); let order_by = match sort.contains("."){ true => sort.split(".").collect::>()[0].to_string(), false => "created_at_unix".to_string(), diff --git a/src/providers/pmvhaven.rs b/src/providers/pmvhaven.rs index 1349ee6..f7152e3 100644 --- a/src/providers/pmvhaven.rs +++ b/src/providers/pmvhaven.rs @@ -233,9 +233,21 @@ impl PmvhavenProvider { } } async fn get(&self, cache: VideoCache, page: u8, category: String) -> Result> { + let index = format!("pmvhaven:{}:{}", page, category); let url = format!("{}/api/getmorevideos", self.url); - let request = PmvhavenRequest::new(page as u32); - let old_items = match cache.get(&url) { + let mut request = PmvhavenRequest::new(page as u32); + println!("Category: {}", category); + request = match category.as_str() { + "hypno" => { request.hypno(); request }, + "pmv" => { request.pmv(); request }, + "hmv" => { request.hmv(); request }, + "tiktok" => { request.tiktok(); request }, + "koreanbj" => { request.koreanbj(); request }, + "other" => { request.other(); request }, + _ => request, + }; + + let old_items = match cache.get(&index) { Some((time, items)) => { if time.elapsed().unwrap_or_default().as_secs() < 60 * 5 { println!("Cache hit for URL: {}", url); @@ -310,6 +322,7 @@ impl PmvhavenProvider { Err("Failed to get Videos".into()) } async fn query(&self, cache: VideoCache, page: u8, query: &str) -> Result> { + let index = format!("pmvhaven:{}:{}", query, page); let url = format!("{}/api/v2/search", self.url); let request = PmvhavenSearch::new(query.to_string(),page as u32); // Check our Video Cache. If the result is younger than 1 hour, we return it.