cacheDuration
This commit is contained in:
107
src/api.rs
107
src/api.rs
@@ -1,10 +1,10 @@
|
||||
use capitalize::Capitalize;
|
||||
use ntex::http::header;
|
||||
use ntex::web;
|
||||
use ntex::web::HttpRequest;
|
||||
use std::cmp::Ordering;
|
||||
use std::fs;
|
||||
use tokio::task;
|
||||
use capitalize::Capitalize;
|
||||
|
||||
use crate::providers::all::AllProvider;
|
||||
use crate::providers::hanime::HanimeProvider;
|
||||
@@ -17,7 +17,7 @@ use crate::providers::rule34video::Rule34videoProvider;
|
||||
// use crate::providers::spankbang::SpankbangProvider;
|
||||
use crate::util::cache::VideoCache;
|
||||
use crate::util::requester::Requester;
|
||||
use crate::{db, providers::*, status::*, videos::*, DbPool};
|
||||
use crate::{DbPool, db, providers::*, status::*, videos::*};
|
||||
use cute::c;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -160,6 +160,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
if clientversion >= ClientVersion::new(22, 101, "22e".to_string()) {
|
||||
// pmvhaven
|
||||
@@ -171,7 +172,8 @@ 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(),
|
||||
status: "active".to_string(),
|
||||
categories: vec![],
|
||||
options: vec![ChannelOption {
|
||||
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(),
|
||||
@@ -227,11 +229,13 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
FilterOption {
|
||||
id: "Most Viewed".to_string(),
|
||||
title: "Most Viewed".to_string(),
|
||||
}
|
||||
},
|
||||
],
|
||||
multiSelect: false,
|
||||
}],
|
||||
},
|
||||
],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
}
|
||||
if clientversion >= ClientVersion::new(22, 97, "22a".to_string()) {
|
||||
@@ -302,6 +306,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
// },
|
||||
],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -364,6 +369,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// status.add_channel(Channel {
|
||||
@@ -397,6 +403,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
// multiSelect: false,
|
||||
// }],
|
||||
// nsfw: true,
|
||||
//cacheDuration: 1800,
|
||||
// });
|
||||
|
||||
status.add_channel(Channel {
|
||||
@@ -438,12 +445,16 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
let files = fs::read_dir("./src/providers").unwrap();
|
||||
let providers = files.map(|entry| entry.unwrap().file_name())
|
||||
let providers = files
|
||||
.map(|entry| entry.unwrap().file_name())
|
||||
.filter(|name| name.to_str().unwrap().ends_with(".rs"))
|
||||
.filter(|name| !name.to_str().unwrap().contains("mod.rs") && !name.to_str().unwrap().contains("all.rs"))
|
||||
.filter(|name| {
|
||||
!name.to_str().unwrap().contains("mod.rs") && !name.to_str().unwrap().contains("all.rs")
|
||||
})
|
||||
.map(|name| name.to_str().unwrap().replace(".rs", ""))
|
||||
.collect::<Vec<String>>();
|
||||
let sites = c![FilterOption {
|
||||
@@ -470,6 +481,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: true,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// Redtube
|
||||
@@ -483,6 +495,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
categories: vec![],
|
||||
options: vec![],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// ok.porn
|
||||
@@ -517,6 +530,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// pornhat
|
||||
@@ -551,6 +565,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
//perfectgirls
|
||||
@@ -585,6 +600,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// okxxx
|
||||
@@ -619,6 +635,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// homoxxx
|
||||
@@ -653,6 +670,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// // hentaimoon
|
||||
@@ -687,6 +705,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
// multiSelect: false,
|
||||
// }],
|
||||
// nsfw: true,
|
||||
// cacheDuration: 1800,
|
||||
// });
|
||||
|
||||
// xxthots
|
||||
@@ -721,6 +740,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// porn00
|
||||
@@ -755,6 +775,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// freshporno
|
||||
@@ -789,6 +810,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
// porn00
|
||||
@@ -802,6 +824,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
// categories: vec![],
|
||||
// options: vec![],
|
||||
// nsfw: true,
|
||||
// cacheDuration: 1800,
|
||||
// });
|
||||
|
||||
//missav
|
||||
@@ -931,9 +954,10 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
},
|
||||
],
|
||||
multiSelect: false,
|
||||
}
|
||||
},
|
||||
],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
//sxyprn
|
||||
@@ -996,6 +1020,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
},
|
||||
],
|
||||
nsfw: true,
|
||||
cacheDuration: 1800,
|
||||
});
|
||||
|
||||
status.iconUrl = format!("http://{}/favicon.ico", host).to_string();
|
||||
@@ -1012,7 +1037,10 @@ async fn videos_post(
|
||||
let mut conn = pool.get().expect("couldn't get db connection from pool");
|
||||
// Ensure "videos" table exists with two string columns
|
||||
if !(db::has_table(&mut conn, "videos").unwrap()) {
|
||||
let _ = db::create_table(&mut conn, "CREATE TABLE videos (id TEXT NOT NULL, url TEXT NOT NULL);");
|
||||
let _ = db::create_table(
|
||||
&mut conn,
|
||||
"CREATE TABLE videos (id TEXT NOT NULL, url TEXT NOT NULL);",
|
||||
);
|
||||
}
|
||||
|
||||
let mut videos = Videos {
|
||||
@@ -1058,22 +1086,21 @@ async fn videos_post(
|
||||
.as_deref()
|
||||
.unwrap_or("all")
|
||||
.to_string();
|
||||
let sites = video_request
|
||||
.sites
|
||||
.as_deref()
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let filter = video_request
|
||||
.filter
|
||||
.as_deref()
|
||||
.unwrap_or("new")
|
||||
.to_string();
|
||||
let sites = video_request.sites.as_deref().unwrap_or("").to_string();
|
||||
let filter = video_request.filter.as_deref().unwrap_or("new").to_string();
|
||||
let language = video_request
|
||||
.language
|
||||
.as_deref()
|
||||
.unwrap_or("en")
|
||||
.to_string();
|
||||
let options = ServerOptions { featured: Some(featured), category: Some(category), sites: Some(sites), filter: Some(filter), language: Some(language), requester: Some(requester) };
|
||||
let options = ServerOptions {
|
||||
featured: Some(featured),
|
||||
category: Some(category),
|
||||
sites: Some(sites),
|
||||
filter: Some(filter),
|
||||
language: Some(language),
|
||||
requester: Some(requester),
|
||||
};
|
||||
let video_items = provider
|
||||
.get_videos(
|
||||
cache.get_ref().clone(),
|
||||
@@ -1082,7 +1109,7 @@ async fn videos_post(
|
||||
query.clone(),
|
||||
page.to_string(),
|
||||
perPage.to_string(),
|
||||
options.clone()
|
||||
options.clone(),
|
||||
)
|
||||
.await;
|
||||
videos.items = video_items.clone();
|
||||
@@ -1114,7 +1141,7 @@ async fn videos_post(
|
||||
query_clone,
|
||||
next_page.to_string(),
|
||||
per_page_clone,
|
||||
options_clone
|
||||
options_clone,
|
||||
)
|
||||
.await;
|
||||
});
|
||||
@@ -1133,17 +1160,35 @@ pub fn get_provider(channel: &str) -> Option<AnyProvider> {
|
||||
"rule34video" => Some(AnyProvider::Rule34video(Rule34videoProvider::new())),
|
||||
"redtube" => Some(AnyProvider::Redtube(RedtubeProvider::new())),
|
||||
"okporn" => Some(AnyProvider::Okporn(OkpornProvider::new())),
|
||||
"pornhat" => Some(AnyProvider::Pornhat(crate::providers::pornhat::PornhatProvider::new())),
|
||||
"perfectgirls" => Some(AnyProvider::Perfectgirls(crate::providers::perfectgirls::PerfectgirlsProvider::new())),
|
||||
"okxxx" => Some(AnyProvider::Okxxx(crate::providers::okxxx::OkxxxProvider::new())),
|
||||
"homoxxx" => Some(AnyProvider::Homoxxx(crate::providers::homoxxx::HomoxxxProvider::new())),
|
||||
"pornhat" => Some(AnyProvider::Pornhat(
|
||||
crate::providers::pornhat::PornhatProvider::new(),
|
||||
)),
|
||||
"perfectgirls" => Some(AnyProvider::Perfectgirls(
|
||||
crate::providers::perfectgirls::PerfectgirlsProvider::new(),
|
||||
)),
|
||||
"okxxx" => Some(AnyProvider::Okxxx(
|
||||
crate::providers::okxxx::OkxxxProvider::new(),
|
||||
)),
|
||||
"homoxxx" => Some(AnyProvider::Homoxxx(
|
||||
crate::providers::homoxxx::HomoxxxProvider::new(),
|
||||
)),
|
||||
// "hentaimoon" => Some(AnyProvider::Hentaimoon(crate::providers::hentaimoon::HentaimoonProvider::new())),
|
||||
"missav" => Some(AnyProvider::Missav(crate::providers::missav::MissavProvider::new())),
|
||||
"xxthots" => Some(AnyProvider::Xxthots(crate::providers::xxthots::XxthotsProvider::new())),
|
||||
"sxyprn" => Some(AnyProvider::Sxyprn(crate::providers::sxyprn::SxyprnProvider::new())),
|
||||
"porn00" => Some(AnyProvider::Porn00(crate::providers::porn00::Porn00Provider::new())),
|
||||
"missav" => Some(AnyProvider::Missav(
|
||||
crate::providers::missav::MissavProvider::new(),
|
||||
)),
|
||||
"xxthots" => Some(AnyProvider::Xxthots(
|
||||
crate::providers::xxthots::XxthotsProvider::new(),
|
||||
)),
|
||||
"sxyprn" => Some(AnyProvider::Sxyprn(
|
||||
crate::providers::sxyprn::SxyprnProvider::new(),
|
||||
)),
|
||||
"porn00" => Some(AnyProvider::Porn00(
|
||||
crate::providers::porn00::Porn00Provider::new(),
|
||||
)),
|
||||
// "noodlemagazine" => Some(AnyProvider::Noodlemagazine(crate::providers::noodlemagazine::NoodlemagazineProvider::new())),
|
||||
"freshporno" => Some(AnyProvider::Freshporno(crate::providers::freshporno::FreshpornoProvider::new())),
|
||||
"freshporno" => Some(AnyProvider::Freshporno(
|
||||
crate::providers::freshporno::FreshpornoProvider::new(),
|
||||
)),
|
||||
_ => Some(AnyProvider::Perverzija(PerverzijaProvider::new())),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ pub struct Channel {
|
||||
pub categories: Vec<String>, //[],
|
||||
pub options: Vec<ChannelOption>,
|
||||
pub nsfw: bool, //true
|
||||
pub cacheDuration: u32, //Some(86400)
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
|
||||
Reference in New Issue
Block a user