From e4d409fe1f4830787108e9caea9f5138db2dbe2d Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 2 May 2026 14:11:06 +0000 Subject: [PATCH] javtiful fix --- src/providers/javtiful.rs | 26 ++++++++++------------ src/proxies/javtiful.rs | 46 +++++++-------------------------------- 2 files changed, 19 insertions(+), 53 deletions(-) diff --git a/src/providers/javtiful.rs b/src/providers/javtiful.rs index f60ec30..d8a3dba 100644 --- a/src/providers/javtiful.rs +++ b/src/providers/javtiful.rs @@ -81,20 +81,16 @@ impl JavtifulProvider { colorName: "blue".to_string(), options: vec![ FilterOption { - id: "newest".into(), - title: "Newest".into(), + id: "relevance".into(), + title: "Relevance".into(), }, FilterOption { - id: "top rated".into(), - title: "Top Rated".into(), + id: "latest".into(), + title: "Latest".into(), }, FilterOption { - id: "most viewed".into(), - title: "Most Viewed".into(), - }, - FilterOption { - id: "top favorites".into(), - title: "Top Favorites".into(), + id: "popular".into(), + title: "Popular".into(), }, ], multiSelect: false, @@ -120,8 +116,8 @@ impl JavtifulProvider { options: ServerOptions, ) -> Result> { let sort_string = match sort { - "top rated" => "/sort=top_rated", - "most viewed" => "/sort=most_viewed", + "latest" => "sort=latest&", + "popular" => "sort=popular&", _ => "", }; let video_url = format!("{}/videos{}?page={}", self.url, sort_string, page); @@ -180,12 +176,12 @@ impl JavtifulProvider { options: ServerOptions, ) -> Result> { let sort_string = match options.sort.as_deref().unwrap_or("") { - "top rated" => "/sort=top_rated", - "most viewed" => "/sort=most_viewed", + "latest" => "sort=latest&", + "popular" => "sort=popular&", _ => "", }; let video_url = format!( - "{}/search/videos{}?search_query={}&page={}", + "{}/search?{}q={}&page={}", self.url, sort_string, query.replace(" ", "+"), diff --git a/src/proxies/javtiful.rs b/src/proxies/javtiful.rs index 7bfa110..eb108cf 100644 --- a/src/proxies/javtiful.rs +++ b/src/proxies/javtiful.rs @@ -1,5 +1,4 @@ use ntex::web; -use serde_json::Value; use url::Url; use wreq::Version; @@ -66,37 +65,16 @@ impl JavtifulProxy { && parsed.path().starts_with("/video/") } - fn extract_token(html: &str) -> Option { - html.split("data-csrf-token=\"") - .nth(1) - .and_then(|value| value.split('"').next()) - .map(|value| value.trim().to_string()) - .filter(|value| !value.is_empty()) - } - - fn extract_playlist_url(payload: &str) -> Option { - let json = serde_json::from_str::(payload).ok()?; - json.get("playlist") - .and_then(Value::as_str) - .or_else(|| json.get("playlists").and_then(Value::as_str)) - .map(str::trim) - .map(ToOwned::to_owned) - .filter(|value| value.starts_with("https://")) - } - pub async fn get_video_url( &self, url: String, requester: web::types::State, ) -> String { - println!("JavtifulProxy: Getting video URL for {url}"); let mut requester = requester.get_ref().clone(); - let Some((detail_url, video_id)) = Self::normalize_detail_request(&url) else { + let Some((detail_url, _)) = Self::normalize_detail_request(&url) else { println!("JavtifulProxy: Invalid detail URL: {url}"); return String::new(); }; - println!("Normalized detail URL: {detail_url}, video ID: {video_id}"); - let html = requester.get(&detail_url, Some(Version::HTTP_11)).await; let Ok(html) = html else { return String::new(); @@ -104,15 +82,16 @@ impl JavtifulProxy { if html.is_empty() { return String::new(); } - println!("Fetched HTML content for {detail_url} (length: {})", html.len()); - - let media_url = format!("https://javtiful.com{}", html.split("playerSources\":[{\"src\":\"") + let mut media_url: String = html.split("playerSources\":[{\"src\":\"") .nth(1) .and_then(|s| s.split('"').next()) .map(str::trim) - .map(ToOwned::to_owned).unwrap_or_default()); - println!("{media_url}"); - media_url + .map(ToOwned::to_owned).unwrap_or_default().replace("\\u0026", "&"); + media_url = match media_url.starts_with("/"){ + true => format!("https://javtiful.com{media_url}"), + false => media_url + }; + return media_url; } } @@ -136,13 +115,4 @@ mod tests { assert_eq!(url, "https://javtiful.com/video/1000/demo"); assert_eq!(video_id, "1000"); } - - #[test] - fn extracts_playlist_from_payload() { - let payload = r#"{"status":"ok","playlist":"https://cdn.example/106796.mp4"}"#; - assert_eq!( - JavtifulProxy::extract_playlist_url(payload).as_deref(), - Some("https://cdn.example/106796.mp4") - ); - } }