fixes and cleanup

This commit is contained in:
Simon
2026-03-05 18:18:48 +00:00
parent 76fd5a4f4f
commit 2627505ade
49 changed files with 3245 additions and 1376 deletions

View File

@@ -2,8 +2,8 @@ use ntex::web::{self, HttpRequest};
use crate::proxies::javtiful::JavtifulProxy;
use crate::proxies::sxyprn::SxyprnProxy;
use crate::util::requester::Requester;
use crate::proxies::*;
use crate::util::requester::Requester;
pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(
@@ -21,21 +21,26 @@ pub fn config(cfg: &mut web::ServiceConfig) {
.route(web::post().to(crate::proxies::hanimecdn::get_image))
.route(web::get().to(crate::proxies::hanimecdn::get_image)),
)
;
.service(
web::resource("/hqporner-thumb/{endpoint}*")
.route(web::post().to(crate::proxies::hqpornerthumb::get_image))
.route(web::get().to(crate::proxies::hqpornerthumb::get_image)),
);
}
async fn proxy2redirect(req: HttpRequest,
requester: web::types::State<Requester>,) -> Result<impl web::Responder, web::Error> {
async fn proxy2redirect(
req: HttpRequest,
requester: web::types::State<Requester>,
) -> Result<impl web::Responder, web::Error> {
let proxy = get_proxy(req.uri().to_string().split("/").collect::<Vec<&str>>()[2]).unwrap();
let endpoint = req.match_info().query("endpoint").to_string();
let video_url = match proxy.get_video_url(endpoint, requester).await{
let video_url = match proxy.get_video_url(endpoint, requester).await {
url if url != "" => url,
_ => "Error".to_string(),
};
Ok(web::HttpResponse::Found()
.header("Location", video_url)
.finish())
.header("Location", video_url)
.finish())
}
fn get_proxy(proxy: &str) -> Option<AnyProxy> {
@@ -44,4 +49,4 @@ fn get_proxy(proxy: &str) -> Option<AnyProxy> {
"javtiful" => Some(AnyProxy::Javtiful(JavtifulProxy::new())),
_ => None,
}
}
}