javtiful fix
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
use crate::DbPool;
|
||||
use crate::api::ClientVersion;
|
||||
use crate::providers::Provider;
|
||||
use crate::providers::{Provider, build_proxy_url, strip_url_scheme};
|
||||
use crate::status::*;
|
||||
use crate::util::cache::VideoCache;
|
||||
use crate::util::discord::{format_error_chain, send_discord_error_report};
|
||||
use crate::util::requester::Requester;
|
||||
use crate::util::time::parse_time_to_seconds;
|
||||
use crate::videos::{ServerOptions, VideoFormat, VideoItem};
|
||||
use crate::videos::{ServerOptions, VideoItem};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use error_chain::error_chain;
|
||||
@@ -362,20 +362,13 @@ impl JavtifulProvider {
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let duration = parse_time_to_seconds(&raw_duration).unwrap_or(0) as u32;
|
||||
let (tags, mut formats, views) = self
|
||||
.extract_media(&video_url, &mut requester, options)
|
||||
.await?;
|
||||
let (tags, views) = self.extract_media(&video_url, &mut requester).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)
|
||||
let proxy_url = build_proxy_url(options, "javtiful", &strip_url_scheme(&video_url));
|
||||
let video_item = VideoItem::new(id, title, proxy_url, "javtiful".into(), thumb, duration)
|
||||
.tags(tags)
|
||||
.preview(preview)
|
||||
.views(views);
|
||||
@@ -386,8 +379,7 @@ impl JavtifulProvider {
|
||||
&self,
|
||||
url: &str,
|
||||
requester: &mut Requester,
|
||||
options: &ServerOptions,
|
||||
) -> Result<(Vec<String>, Vec<VideoFormat>, u32)> {
|
||||
) -> Result<(Vec<String>, u32)> {
|
||||
let text = requester
|
||||
.get(url, Some(Version::HTTP_2))
|
||||
.await
|
||||
@@ -432,56 +424,7 @@ impl JavtifulProvider {
|
||||
.and_then(|s| s.replace(".", "").parse::<u32>().ok())
|
||||
.unwrap_or(0);
|
||||
|
||||
let quality = "1080p".to_string();
|
||||
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))
|
||||
Ok((tags, views))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user