fixes and cleanup
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use ntex::http::header::{CONTENT_LENGTH, CONTENT_TYPE};
|
||||
use ntex::{
|
||||
http::Response,
|
||||
web::{self, HttpRequest, error},
|
||||
};
|
||||
use ntex::http::header::{CONTENT_LENGTH, CONTENT_TYPE};
|
||||
|
||||
use crate::util::requester::Requester;
|
||||
|
||||
|
||||
51
src/proxies/hqpornerthumb.rs
Normal file
51
src/proxies/hqpornerthumb.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use ntex::http::header::{CONTENT_LENGTH, CONTENT_TYPE};
|
||||
use ntex::{
|
||||
http::Response,
|
||||
web::{self, HttpRequest, error},
|
||||
};
|
||||
|
||||
use crate::util::requester::Requester;
|
||||
|
||||
pub async fn get_image(
|
||||
req: HttpRequest,
|
||||
requester: web::types::State<Requester>,
|
||||
) -> Result<impl web::Responder, web::Error> {
|
||||
let endpoint = req.match_info().query("endpoint").to_string();
|
||||
let image_url = if endpoint.starts_with("http://") || endpoint.starts_with("https://") {
|
||||
endpoint
|
||||
} else {
|
||||
format!("https://{}", endpoint.trim_start_matches('/'))
|
||||
};
|
||||
|
||||
let upstream = match requester
|
||||
.get_ref()
|
||||
.clone()
|
||||
.get_raw_with_headers(
|
||||
image_url.as_str(),
|
||||
vec![("Referer".to_string(), "https://hqporner.com/".to_string())],
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(response) => response,
|
||||
Err(_) => return Ok(web::HttpResponse::NotFound().finish()),
|
||||
};
|
||||
|
||||
let status = upstream.status();
|
||||
let headers = upstream.headers().clone();
|
||||
let bytes = upstream.bytes().await.map_err(error::ErrorBadGateway)?;
|
||||
|
||||
let mut resp = Response::build(status);
|
||||
|
||||
if let Some(ct) = headers.get(CONTENT_TYPE) {
|
||||
if let Ok(ct_str) = ct.to_str() {
|
||||
resp.set_header(CONTENT_TYPE, ct_str);
|
||||
}
|
||||
}
|
||||
if let Some(cl) = headers.get(CONTENT_LENGTH) {
|
||||
if let Ok(cl_str) = cl.to_str() {
|
||||
resp.set_header(CONTENT_LENGTH, cl_str);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(resp.body(bytes.to_vec()))
|
||||
}
|
||||
@@ -3,15 +3,12 @@ use wreq::Version;
|
||||
|
||||
use crate::util::requester::Requester;
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct JavtifulProxy {
|
||||
}
|
||||
pub struct JavtifulProxy {}
|
||||
|
||||
impl JavtifulProxy {
|
||||
pub fn new() -> Self {
|
||||
JavtifulProxy {
|
||||
}
|
||||
JavtifulProxy {}
|
||||
}
|
||||
|
||||
pub async fn get_video_url(
|
||||
@@ -25,18 +22,15 @@ impl JavtifulProxy {
|
||||
if text.is_empty() {
|
||||
return "".to_string();
|
||||
}
|
||||
let video_id = url
|
||||
.split('/')
|
||||
.nth(4)
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let video_id = url.split('/').nth(4).unwrap_or("").to_string();
|
||||
|
||||
let token = text.split("data-csrf-token=\"")
|
||||
let token = text
|
||||
.split("data-csrf-token=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
|
||||
|
||||
let form = wreq::multipart::Form::new()
|
||||
.text("video_id", video_id.clone())
|
||||
.text("pid_c", "".to_string())
|
||||
@@ -54,11 +48,13 @@ impl JavtifulProxy {
|
||||
Err(_) => return "".to_string(),
|
||||
};
|
||||
let text = resp.text().await.unwrap_or_default();
|
||||
let json: serde_json::Value = serde_json::from_str(&text).unwrap_or(serde_json::Value::Null);
|
||||
let video_url = json.get("playlists")
|
||||
let json: serde_json::Value =
|
||||
serde_json::from_str(&text).unwrap_or(serde_json::Value::Null);
|
||||
let video_url = json
|
||||
.get("playlists")
|
||||
.map(|v| v.to_string().replace("\"", ""))
|
||||
.unwrap_or_default();
|
||||
|
||||
|
||||
return video_url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ use ntex::web;
|
||||
|
||||
use crate::{proxies::sxyprn::SxyprnProxy, util::requester::Requester};
|
||||
|
||||
pub mod sxyprn;
|
||||
pub mod hanimecdn;
|
||||
pub mod hqpornerthumb;
|
||||
pub mod javtiful;
|
||||
pub mod sxyprn;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum AnyProxy {
|
||||
@@ -13,23 +14,14 @@ pub enum AnyProxy {
|
||||
}
|
||||
|
||||
pub trait Proxy {
|
||||
async fn get_video_url(
|
||||
&self,
|
||||
url: String,
|
||||
requester: web::types::State<Requester>,
|
||||
) -> String;
|
||||
async fn get_video_url(&self, url: String, requester: web::types::State<Requester>) -> String;
|
||||
}
|
||||
|
||||
|
||||
impl Proxy for AnyProxy {
|
||||
async fn get_video_url(
|
||||
&self,
|
||||
url: String,
|
||||
requester: web::types::State<Requester>,
|
||||
) -> String {
|
||||
async fn get_video_url(&self, url: String, requester: web::types::State<Requester>) -> String {
|
||||
match self {
|
||||
AnyProxy::Sxyprn(p) => p.get_video_url(url, requester).await,
|
||||
AnyProxy::Javtiful(p) => p.get_video_url(url, requester).await,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
use ntex::web;
|
||||
|
||||
use crate::util::requester::Requester;
|
||||
@@ -24,13 +24,11 @@ fn boo(sum1: u32, sum2: u32) -> String {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SxyprnProxy {
|
||||
}
|
||||
pub struct SxyprnProxy {}
|
||||
|
||||
impl SxyprnProxy {
|
||||
pub fn new() -> Self {
|
||||
SxyprnProxy {
|
||||
}
|
||||
SxyprnProxy {}
|
||||
}
|
||||
|
||||
pub async fn get_video_url(
|
||||
@@ -45,16 +43,23 @@ impl SxyprnProxy {
|
||||
return "".to_string();
|
||||
}
|
||||
let data_string = text.split("data-vnfo='").collect::<Vec<&str>>()[1]
|
||||
.split("\":\"").collect::<Vec<&str>>()[1]
|
||||
.split("\"}").collect::<Vec<&str>>()[0].replace("\\","");
|
||||
.split("\":\"")
|
||||
.collect::<Vec<&str>>()[1]
|
||||
.split("\"}")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.replace("\\", "");
|
||||
//println!("src: {}",data_string);
|
||||
let mut tmp = data_string
|
||||
.split("/")
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
//println!("tmp: {:?}",tmp);
|
||||
tmp[1] = format!("{}8/{}", tmp[1], boo(ssut51(tmp[6].as_str()), ssut51(tmp[7].as_str())));
|
||||
|
||||
tmp[1] = format!(
|
||||
"{}8/{}",
|
||||
tmp[1],
|
||||
boo(ssut51(tmp[6].as_str()), ssut51(tmp[7].as_str()))
|
||||
);
|
||||
|
||||
//println!("tmp[1]: {:?}",tmp[1]);
|
||||
//preda
|
||||
tmp[5] = format!(
|
||||
@@ -62,17 +67,25 @@ impl SxyprnProxy {
|
||||
tmp[5].parse::<u32>().unwrap() - ssut51(tmp[6].as_str()) - ssut51(tmp[7].as_str())
|
||||
);
|
||||
//println!("tmp: {:?}",tmp);
|
||||
let sxyprn_video_url = format!("https://sxyprn.com{}",tmp.join("/"));
|
||||
|
||||
let sxyprn_video_url = format!("https://sxyprn.com{}", tmp.join("/"));
|
||||
|
||||
let response = requester.get_raw(&sxyprn_video_url).await;
|
||||
match response {
|
||||
Ok(resp) => {
|
||||
return format!("https:{}", resp.headers().get("Location").unwrap().to_str().unwrap_or("").to_string());
|
||||
},
|
||||
return format!(
|
||||
"https:{}",
|
||||
resp.headers()
|
||||
.get("Location")
|
||||
.unwrap()
|
||||
.to_str()
|
||||
.unwrap_or("")
|
||||
.to_string()
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Error fetching video URL: {}", e);
|
||||
}
|
||||
}
|
||||
return "".to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user