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

@@ -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;
}
}
}