doodstream and lulustream in sxyprn integrated
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
100
src/proxies/lulustream.rs
Normal file
100
src/proxies/lulustream.rs
Normal file
@@ -0,0 +1,100 @@
|
||||
use ntex::web;
|
||||
use url::Url;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::util::requester::Requester;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LulustreamProxy {}
|
||||
|
||||
impl LulustreamProxy {
|
||||
pub fn new() -> Self {
|
||||
LulustreamProxy {}
|
||||
}
|
||||
|
||||
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("lulustream.com/") || endpoint.starts_with("www.lulustream.com/") ||
|
||||
endpoint.starts_with("luluvdo.com/")
|
||||
{
|
||||
format!("https://{endpoint}")
|
||||
} else {
|
||||
format!("https://lulustream.com/{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 == "lulustream.com" || host == "www.lulustream.com" || host == "luluvdo.com")
|
||||
&& (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!("LulustreamProxy: Invalid detail URL: {url}");
|
||||
return String::new();
|
||||
};
|
||||
let text = requester.get(&detail_url, None).await.unwrap_or_default();
|
||||
let video_url = text.split("sources: [{file:\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
if video_url.is_empty() {
|
||||
println!("LulustreamProxy: Failed to extract video URL for video ID: {video_id}");
|
||||
}
|
||||
video_url
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::LulustreamProxy;
|
||||
|
||||
#[test]
|
||||
fn normalizes_detail_request_with_full_url() {
|
||||
let (url, video_id) =
|
||||
LulustreamProxy::normalize_detail_request("https://lulustream.com/d/s484n23k8opy")
|
||||
.expect("detail request should parse");
|
||||
assert_eq!(url, "https://lulustream.com/d/s484n23k8opy");
|
||||
assert_eq!(video_id, "s484n23k8opy");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normalizes_detail_request_with_path_only() {
|
||||
let (url, video_id) = LulustreamProxy::normalize_detail_request("d/s484n23k8opy")
|
||||
.expect("detail request should parse");
|
||||
assert_eq!(url, "https://lulustream.com/d/s484n23k8opy");
|
||||
assert_eq!(video_id, "s484n23k8opy");
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use crate::proxies::spankbang::SpankbangProxy;
|
||||
use crate::proxies::vjav::VjavProxy;
|
||||
use crate::{proxies::sxyprn::SxyprnProxy, util::requester::Requester};
|
||||
use crate::proxies::vidara::VidaraProxy;
|
||||
use crate::proxies::lulustream::LulustreamProxy;
|
||||
|
||||
pub mod archivebate;
|
||||
pub mod doodstream;
|
||||
@@ -20,6 +21,7 @@ pub mod heavyfetish;
|
||||
pub mod hqporner;
|
||||
pub mod hqpornerthumb;
|
||||
pub mod javtiful;
|
||||
pub mod lulustream;
|
||||
pub mod noodlemagazine;
|
||||
pub mod pimpbunny;
|
||||
pub mod porndish;
|
||||
@@ -38,6 +40,7 @@ pub enum AnyProxy {
|
||||
Doodstream(DoodstreamProxy),
|
||||
Sxyprn(SxyprnProxy),
|
||||
Javtiful(javtiful::JavtifulProxy),
|
||||
Lulustream(LulustreamProxy),
|
||||
Pornhd3x(Pornhd3xProxy),
|
||||
Pimpbunny(PimpbunnyProxy),
|
||||
Porndish(PorndishProxy),
|
||||
@@ -60,6 +63,7 @@ impl Proxy for AnyProxy {
|
||||
AnyProxy::Doodstream(p) => p.get_video_url(url, requester).await,
|
||||
AnyProxy::Sxyprn(p) => p.get_video_url(url, requester).await,
|
||||
AnyProxy::Javtiful(p) => p.get_video_url(url, requester).await,
|
||||
AnyProxy::Lulustream(p) => p.get_video_url(url, requester).await,
|
||||
AnyProxy::Pornhd3x(p) => p.get_video_url(url, requester).await,
|
||||
AnyProxy::Pimpbunny(p) => p.get_video_url(url, requester).await,
|
||||
AnyProxy::Porndish(p) => p.get_video_url(url, requester).await,
|
||||
|
||||
@@ -38,7 +38,7 @@ impl SxyprnProxy {
|
||||
) -> String {
|
||||
let mut requester = requester.get_ref().clone();
|
||||
let url = "https://sxyprn.com/".to_string() + &url;
|
||||
println!("Fetching URL: {}", url);
|
||||
// println!("Fetching URL: {}", url);
|
||||
let text = requester.get(&url, None).await.unwrap_or("".to_string());
|
||||
if text.is_empty() {
|
||||
return "".to_string();
|
||||
@@ -49,27 +49,27 @@ impl SxyprnProxy {
|
||||
.split("\"}")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.replace("\\", "");
|
||||
println!("src: {}", data_string);
|
||||
// println!("src: {}", data_string);
|
||||
let mut tmp = data_string
|
||||
.split("/")
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
println!("tmp: {:?}", tmp);
|
||||
// println!("tmp: {:?}", tmp);
|
||||
tmp[1] = format!(
|
||||
"{}8/{}",
|
||||
tmp[1],
|
||||
boo(ssut51(tmp[6].as_str()), ssut51(tmp[7].as_str()))
|
||||
);
|
||||
|
||||
println!("tmp[1]: {:?}", tmp[1]);
|
||||
// println!("tmp[1]: {:?}", tmp[1]);
|
||||
//preda
|
||||
tmp[5] = format!(
|
||||
"{}",
|
||||
tmp[5].parse::<u32>().unwrap() - ssut51(tmp[6].as_str()) - ssut51(tmp[7].as_str())
|
||||
);
|
||||
println!("tmp: {:?}", tmp);
|
||||
// println!("tmp: {:?}", tmp);
|
||||
let sxyprn_video_url = format!("https://sxyprn.com{}", tmp.join("/"));
|
||||
println!("sxyprn_video_url: {}", sxyprn_video_url);
|
||||
// println!("sxyprn_video_url: {}", sxyprn_video_url);
|
||||
match crate::util::get_redirect_location(&sxyprn_video_url) {
|
||||
Ok(Some(loc)) => {return format!("https:{}", loc)},
|
||||
Ok(None) => println!("No redirect found for {}", sxyprn_video_url),
|
||||
|
||||
Reference in New Issue
Block a user