vidara proxy for sxyprn

This commit is contained in:
Simon
2026-05-05 08:58:26 +00:00
committed by ForgeCode
parent 60d29ca905
commit 8ae0fcb544
8 changed files with 212 additions and 178 deletions

View File

@@ -11,6 +11,7 @@ use crate::proxies::shooshtime::ShooshtimeProxy;
use crate::proxies::spankbang::SpankbangProxy;
use crate::proxies::vjav::VjavProxy;
use crate::{proxies::sxyprn::SxyprnProxy, util::requester::Requester};
use crate::proxies::vidara::VidaraProxy;
pub mod archivebate;
pub mod doodstream;
@@ -28,6 +29,7 @@ pub mod pornhubthumb;
pub mod shooshtime;
pub mod spankbang;
pub mod sxyprn;
pub mod vidara;
pub mod vjav;
#[derive(Debug, Clone)]
@@ -44,6 +46,7 @@ pub enum AnyProxy {
Hqporner(HqpornerProxy),
Heavyfetish(HeavyfetishProxy),
Vjav(VjavProxy),
Vidara(VidaraProxy),
}
pub trait Proxy {
@@ -65,6 +68,7 @@ impl Proxy for AnyProxy {
AnyProxy::Hqporner(p) => p.get_video_url(url, requester).await,
AnyProxy::Heavyfetish(p) => p.get_video_url(url, requester).await,
AnyProxy::Vjav(p) => p.get_video_url(url, requester).await,
AnyProxy::Vidara(p) => p.get_video_url(url, requester).await,
}
}
}

View File

@@ -70,46 +70,8 @@ impl SxyprnProxy {
println!("tmp: {:?}", tmp);
let sxyprn_video_url = format!("https://sxyprn.com{}", tmp.join("/"));
println!("sxyprn_video_url: {}", sxyprn_video_url);
// let response = requester.get_raw_with_headers(&sxyprn_video_url, vec![
// ("Accept".to_string(), "*/*".to_string()),
// // ("Accept-Encoding".to_string(), "identity".to_string()),
// // ("Accept-Language".to_string(), "de,en-US;q=0.9,en;q=0.8".to_string()),
// // ("Cache-Control".to_string(), "no-cache".to_string()),
// // ("Connection".to_string(), "keep-alive".to_string()),
// ("Host".to_string(), "sxyprn.com".to_string()),
// // ("Pragma".to_string(), "no-cache".to_string()),
// // ("Priority".to_string(), "u=4".to_string()),
// // ("Range".to_string(), "bytes=0-".to_string()),
// // ("Referer".to_string(), url.clone()),
// // ("Sec-Fetch-Dest".to_string(), "video".to_string()),
// // ("Sec-Fetch-Mode".to_string(), "no-cors".to_string()),
// // ("Sec-Fetch-Site".to_string(), "same-origin".to_string()),
// // ("Sec-GPC".to_string(), "1".to_string()),
// // ("TE".to_string(), "trailers".to_string()),
// ("User-Agent".to_string(), "curl/8.5.0".to_string())
// ])
// .await;
// match response {
// Ok(resp) => {
// println!("Response headers: {:?}", resp.headers());
// println!("Response status: {}", resp.status());
// return format!(
// "https:{}",
// resp.headers()
// .get("location")
// .unwrap()
// .to_str()
// .unwrap_or("")
// .to_string()
// );
// }
// Err(e) => {
// println!("Error fetching video URL: {}", e);
// }
// }
match crate::util::get_redirect_location(&sxyprn_video_url) {
Ok(Some(loc)) => {println!("Redirect target found: {}", loc); return format!("https:{}", loc)},
Ok(Some(loc)) => {return format!("https:{}", loc)},
Ok(None) => println!("No redirect found for {}", sxyprn_video_url),
Err(e) => eprintln!("Request failed: {}", e),
}

124
src/proxies/vidara.rs Normal file
View File

@@ -0,0 +1,124 @@
use ntex::web;
use url::Url;
use serde_json::json;
use crate::util::requester::Requester;
#[derive(Debug, Clone)]
pub struct VidaraProxy {}
impl VidaraProxy {
pub fn new() -> Self {
VidaraProxy {}
}
fn normalize_detail_request(endpoint: &str) -> Option<(String, String)> {
let endpoint = endpoint.trim().trim_start_matches('/');
if endpoint.is_empty() {
return None;
}
let detail_url = if endpoint.starts_with("http://") || endpoint.starts_with("https://") {
endpoint.to_string()
} else if endpoint.starts_with("vidara.so/") || endpoint.starts_with("www.vidara.so/")
{
format!("https://{endpoint}")
} else {
format!("https://vidara.so/{endpoint}")
};
if !Self::is_allowed_detail_url(&detail_url) {
return None;
}
let parsed = Url::parse(&detail_url).ok()?;
let video_id = parsed.path_segments()?
.last()
.map(ToOwned::to_owned)?;
Some((detail_url, video_id))
}
fn is_allowed_detail_url(url: &str) -> bool {
let Some(parsed) = Url::parse(url).ok() else {
return false;
};
if parsed.scheme() != "https" {
return false;
}
let Some(host) = parsed.host_str() else {
return false;
};
(host == "vidara.so" || host == "www.vidara.so")
&& (parsed.path().starts_with("/v/")||parsed.path().starts_with("/e/"))
}
pub async fn get_video_url(
&self,
url: String,
requester: web::types::State<Requester>,
) -> String {
let mut requester = requester.get_ref().clone();
let Some((detail_url, video_id)) = Self::normalize_detail_request(&url) else {
println!("VidaraProxy: Invalid detail URL: {url}");
return String::new();
};
let body = json!({
"filecode": video_id,
"device": "web"
});
// println!("VidaraProxy: Requesting streaming URL for {detail_url} with body: {body}");
let response = requester
.post_json(
"https://vidara.so/api/stream",
&body,
vec![
("Referer".to_string(), detail_url.clone())
],
)
.await;
// println!("VidaraProxy: Requested streaming URL for {detail_url}, got response: {:?}", response);
let Ok(response) = response else {
return String::new();
};
let Ok(response_text) = response.text().await else {
return String::new();
};
// println!("VidaraProxy: Response text for {detail_url}: {response_text}");
let Ok(json): Result<serde_json::Value, _> = serde_json::from_str(&response_text) else {
return String::new();
};
json["streaming_url"]
.as_str()
.map(ToOwned::to_owned)
.unwrap_or_default()
}
}
#[cfg(test)]
mod tests {
use super::VidaraProxy;
#[test]
fn normalizes_detail_request_with_full_url() {
let (url, video_id) =
VidaraProxy::normalize_detail_request("https://vidara.so/v/eJ9O4QqG1Ln2")
.expect("detail request should parse");
assert_eq!(url, "https://vidara.so/v/eJ9O4QqG1Ln2");
assert_eq!(video_id, "eJ9O4QqG1Ln2");
}
#[test]
fn normalizes_detail_request_with_path_only() {
let (url, video_id) = VidaraProxy::normalize_detail_request("video/1000/demo")
.expect("detail request should parse");
assert_eq!(url, "https://vidara.so/video/1000/demo");
assert_eq!(video_id, "1000");
}
}