pmvhaven category option
This commit is contained in:
44
src/api.rs
44
src/api.rs
@@ -115,6 +115,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_string();
|
.to_string();
|
||||||
let mut status = Status::new();
|
let mut status = Status::new();
|
||||||
|
// pronhub
|
||||||
status.add_channel(Channel {
|
status.add_channel(Channel {
|
||||||
id: "pornhub".to_string(),
|
id: "pornhub".to_string(),
|
||||||
name: "Pornhub".to_string(),
|
name: "Pornhub".to_string(),
|
||||||
@@ -126,6 +127,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
|||||||
options: vec![],
|
options: vec![],
|
||||||
nsfw: true,
|
nsfw: true,
|
||||||
});
|
});
|
||||||
|
// pmvhaven
|
||||||
status.add_channel(Channel {
|
status.add_channel(Channel {
|
||||||
id: "pmvhaven".to_string(),
|
id: "pmvhaven".to_string(),
|
||||||
name: "Pmvhaven".to_string(),
|
name: "Pmvhaven".to_string(),
|
||||||
@@ -134,11 +136,49 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
|||||||
favicon: "https://www.google.com/s2/favicons?sz=64&domain=pmvhaven.com".to_string(),
|
favicon: "https://www.google.com/s2/favicons?sz=64&domain=pmvhaven.com".to_string(),
|
||||||
status: "active".to_string(),
|
status: "active".to_string(),
|
||||||
categories: vec![],
|
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,
|
nsfw: true,
|
||||||
});
|
});
|
||||||
if clientversion >= ClientVersion::new(22, 97, "22a".to_string()) {
|
if clientversion >= ClientVersion::new(22, 97, "22a".to_string()) {
|
||||||
//add perverzija
|
// perverzija
|
||||||
status.add_channel(Channel {
|
status.add_channel(Channel {
|
||||||
id: "perverzija".to_string(),
|
id: "perverzija".to_string(),
|
||||||
name: "Perverzija".to_string(),
|
name: "Perverzija".to_string(),
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ impl HanimeProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get(&self, cache: VideoCache, pool: DbPool, page: u8, query: String, sort:String) -> Result<Vec<VideoItem>> {
|
async fn get(&self, cache: VideoCache, pool: DbPool, page: u8, query: String, sort:String) -> Result<Vec<VideoItem>> {
|
||||||
let index = format!("{}:{}:{}", query, page, sort);
|
let index = format!("hanime:{}:{}:{}", query, page, sort);
|
||||||
let order_by = match sort.contains("."){
|
let order_by = match sort.contains("."){
|
||||||
true => sort.split(".").collect::<Vec<&str>>()[0].to_string(),
|
true => sort.split(".").collect::<Vec<&str>>()[0].to_string(),
|
||||||
false => "created_at_unix".to_string(),
|
false => "created_at_unix".to_string(),
|
||||||
|
|||||||
@@ -233,9 +233,21 @@ impl PmvhavenProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async fn get(&self, cache: VideoCache, page: u8, category: String) -> Result<Vec<VideoItem>> {
|
async fn get(&self, cache: VideoCache, page: u8, category: String) -> Result<Vec<VideoItem>> {
|
||||||
|
let index = format!("pmvhaven:{}:{}", page, category);
|
||||||
let url = format!("{}/api/getmorevideos", self.url);
|
let url = format!("{}/api/getmorevideos", self.url);
|
||||||
let request = PmvhavenRequest::new(page as u32);
|
let mut request = PmvhavenRequest::new(page as u32);
|
||||||
let old_items = match cache.get(&url) {
|
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)) => {
|
Some((time, items)) => {
|
||||||
if time.elapsed().unwrap_or_default().as_secs() < 60 * 5 {
|
if time.elapsed().unwrap_or_default().as_secs() < 60 * 5 {
|
||||||
println!("Cache hit for URL: {}", url);
|
println!("Cache hit for URL: {}", url);
|
||||||
@@ -310,6 +322,7 @@ impl PmvhavenProvider {
|
|||||||
Err("Failed to get Videos".into())
|
Err("Failed to get Videos".into())
|
||||||
}
|
}
|
||||||
async fn query(&self, cache: VideoCache, page: u8, query: &str) -> Result<Vec<VideoItem>> {
|
async fn query(&self, cache: VideoCache, page: u8, query: &str) -> Result<Vec<VideoItem>> {
|
||||||
|
let index = format!("pmvhaven:{}:{}", query, page);
|
||||||
let url = format!("{}/api/v2/search", self.url);
|
let url = format!("{}/api/v2/search", self.url);
|
||||||
let request = PmvhavenSearch::new(query.to_string(),page as u32);
|
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.
|
// Check our Video Cache. If the result is younger than 1 hour, we return it.
|
||||||
|
|||||||
Reference in New Issue
Block a user