This commit is contained in:
Simon
2026-03-30 17:06:28 +00:00
parent 4df2a672b7
commit 429fb16fbd
6 changed files with 514 additions and 57 deletions

View File

@@ -362,13 +362,18 @@ impl JavtifulProvider {
.unwrap_or("")
.to_string();
let duration = parse_time_to_seconds(&raw_duration).unwrap_or(0) as u32;
let (tags, formats, views) = self
let (tags, mut formats, views) = self
.extract_media(&video_url, &mut requester, options)
.await?;
if preview.len() == 0 {
preview = format!("https://trailers.jav.si/preview/{id}.mp4");
}
if formats.is_empty() && !preview.is_empty() {
let mut format = VideoFormat::new(preview.clone(), "preview".to_string(), "video/mp4".to_string());
format.add_http_header("Referer".to_string(), video_url.clone());
formats.push(format);
}
let video_item = VideoItem::new(id, title, video_url, "javtiful".into(), thumb, duration)
.formats(formats)
.tags(tags)
@@ -428,23 +433,55 @@ impl JavtifulProvider {
.unwrap_or(0);
let quality = "1080p".to_string();
let stripped_url = crate::providers::strip_url_scheme(url);
let proxy_target = stripped_url
.strip_prefix("www.javtiful.com/")
.or_else(|| stripped_url.strip_prefix("javtiful.com/"))
.unwrap_or(stripped_url.as_str())
.trim_start_matches('/')
.to_string();
let video_url = crate::providers::build_proxy_url(
options,
"javtiful",
&proxy_target,
);
Ok((
tags,
vec![VideoFormat::new(video_url, quality, "video/mp4".into())],
views,
))
let mut formats = Vec::new();
let video_id = url
.split("/video/")
.nth(1)
.and_then(|value| value.split('/').next())
.unwrap_or("")
.trim();
let token = text
.split("data-csrf-token=\"")
.nth(1)
.and_then(|value| value.split('"').next())
.unwrap_or("")
.trim();
if !video_id.is_empty() && !token.is_empty() {
let form = wreq::multipart::Form::new()
.text("video_id", video_id.to_string())
.text("pid_c", "".to_string())
.text("token", token.to_string());
if let Ok(response) = requester
.post_multipart(
"https://javtiful.com/ajax/get_cdn",
form,
vec![("Referer".to_string(), url.to_string())],
Some(Version::HTTP_11),
)
.await
{
let payload = response.text().await.unwrap_or_default();
if let Ok(json) = serde_json::from_str::<serde_json::Value>(&payload) {
if let Some(cdn_url) = json.get("playlists").and_then(|value| value.as_str()) {
if !cdn_url.trim().is_empty() {
let mut format = VideoFormat::new(
cdn_url.to_string(),
quality.clone(),
"m3u8".into(),
);
format.add_http_header("Referer".to_string(), url.to_string());
formats.push(format);
}
}
}
}
}
let _ = options;
Ok((tags, formats, views))
}
}