javtiful fix
This commit is contained in:
@@ -154,7 +154,7 @@ impl JavtifulProvider {
|
||||
};
|
||||
if page > 1
|
||||
&& !text.contains(&format!(
|
||||
"<li class=\"page-item active\"><span class=\"page-link\">{}</span>",
|
||||
"<a class=\"front-pagination-link is-active\" href=\"/videos\" aria-current=\"page\">{}</a>",
|
||||
page
|
||||
))
|
||||
{
|
||||
@@ -222,7 +222,7 @@ impl JavtifulProvider {
|
||||
};
|
||||
if page > 1
|
||||
&& !text.contains(&format!(
|
||||
"<li class=\"page-item active\"><span class=\"page-link\">{}</span>",
|
||||
"<a class=\"front-pagination-link is-active\" href=\"/videos\" aria-current=\"page\">{}</a>",
|
||||
page
|
||||
))
|
||||
{
|
||||
@@ -250,10 +250,11 @@ impl JavtifulProvider {
|
||||
return vec![];
|
||||
}
|
||||
|
||||
let block = match html.split("pagination ").next().and_then(|s| {
|
||||
s.split("row row-cols-1 row-cols-sm-2 row-cols-lg-3 row-cols-xl-4")
|
||||
.nth(1)
|
||||
}) {
|
||||
let block = match html
|
||||
.split("front-pagination")
|
||||
.next()
|
||||
.and_then(|s| s.split("front-video-grid").nth(1))
|
||||
{
|
||||
Some(b) => b,
|
||||
None => {
|
||||
eprint!("Javtiful Provider: Failed to get block from html");
|
||||
@@ -273,9 +274,9 @@ impl JavtifulProvider {
|
||||
};
|
||||
|
||||
let futures = block
|
||||
.split("card ")
|
||||
.split("\"front-video-card\"")
|
||||
.skip(1)
|
||||
.filter(|seg| !seg.contains("SPONSOR"))
|
||||
.filter(|seg| !seg.contains("front-ad-card"))
|
||||
.map(|el| self.get_video_item(el.to_string(), requester.clone(), options));
|
||||
|
||||
join_all(futures)
|
||||
@@ -313,20 +314,33 @@ impl JavtifulProvider {
|
||||
mut requester: Requester,
|
||||
options: &ServerOptions,
|
||||
) -> Result<VideoItem> {
|
||||
let video_url = seg
|
||||
.split(" href=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.ok_or_else(|| ErrorKind::Parse("video url\n\n{seg}".into()))?
|
||||
.to_string();
|
||||
let video_url = format!(
|
||||
"{}{}",
|
||||
self.url,
|
||||
seg.split(" href=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.ok_or_else(|| ErrorKind::Parse(format!("video url\n\n{seg}")))?
|
||||
.to_string()
|
||||
);
|
||||
|
||||
let mut title = seg
|
||||
.split(" alt=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.ok_or_else(|| ErrorKind::Parse(format!("video title\n\n{seg}").into()))?
|
||||
.trim()
|
||||
.to_string();
|
||||
let mut title = match seg.contains("front-video-title") {
|
||||
true => seg
|
||||
.split("front-video-title")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('>').nth(1))
|
||||
.and_then(|s| s.split('<').next())
|
||||
.ok_or_else(|| ErrorKind::Parse(format!("video title\n\n{seg}")))?
|
||||
.trim()
|
||||
.to_string(),
|
||||
false => seg
|
||||
.split("alt=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('\"').next())
|
||||
.ok_or_else(|| ErrorKind::Parse(format!("video title\n\n{seg}")))?
|
||||
.trim()
|
||||
.to_string(),
|
||||
};
|
||||
|
||||
title = decode(title.as_bytes())
|
||||
.to_string()
|
||||
@@ -334,21 +348,22 @@ impl JavtifulProvider {
|
||||
.titlecase();
|
||||
let id = video_url
|
||||
.split('/')
|
||||
.nth(5)
|
||||
.filter(|s| !s.is_empty())
|
||||
.nth(2)
|
||||
.and_then(|s| s.split('.').next())
|
||||
.ok_or_else(|| ErrorKind::Parse("video id\n\n{seg}".into()))?
|
||||
.ok_or_else(|| ErrorKind::Parse(format!("video id\n\n{seg}")))?
|
||||
.to_string();
|
||||
let thumb_block = seg
|
||||
.split("<img ")
|
||||
.nth(1)
|
||||
.ok_or_else(|| ErrorKind::Parse("thumb block\n\n{seg}".into()))?;
|
||||
let thumb_block = seg.split("<img ").nth(1);
|
||||
|
||||
let thumb = thumb_block
|
||||
.split("data-src=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let thumb = match thumb_block {
|
||||
Some(block) => format!("{}{}", self.url,block
|
||||
.split("src=\"")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('"').next())
|
||||
.unwrap_or("")
|
||||
.to_string()),
|
||||
None => "".to_string(),
|
||||
};
|
||||
let mut preview = seg
|
||||
.split("data-trailer=\"")
|
||||
.nth(1)
|
||||
@@ -356,7 +371,7 @@ impl JavtifulProvider {
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
let raw_duration = seg
|
||||
.split("label-duration\">")
|
||||
.split("class=\"front-duration-tag\">")
|
||||
.nth(1)
|
||||
.and_then(|s| s.split('<').next())
|
||||
.unwrap_or("")
|
||||
@@ -367,7 +382,11 @@ impl JavtifulProvider {
|
||||
if preview.len() == 0 {
|
||||
preview = format!("https://trailers.jav.si/preview/{id}.mp4");
|
||||
}
|
||||
let proxy_url = build_proxy_url(options, "javtiful", &strip_url_scheme(&video_url));
|
||||
let proxy_url = build_proxy_url(
|
||||
options,
|
||||
"javtiful",
|
||||
&strip_url_scheme(video_url.clone().as_str()),
|
||||
);
|
||||
let video_item = VideoItem::new(id, title, proxy_url, "javtiful".into(), thumb, duration)
|
||||
.tags(tags)
|
||||
.preview(preview)
|
||||
|
||||
@@ -653,6 +653,7 @@ pub fn strip_url_scheme(url: &str) -> String {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn build_proxy_url(options: &ServerOptions, proxy: &str, target: &str) -> String {
|
||||
println!("Building proxy URL with options={:?}, proxy={}, target={}", options, proxy, target);
|
||||
let target = target.trim_start_matches('/');
|
||||
let base = options
|
||||
.public_url_base
|
||||
@@ -660,6 +661,10 @@ pub fn build_proxy_url(options: &ServerOptions, proxy: &str, target: &str) -> St
|
||||
.unwrap_or("")
|
||||
.trim_end_matches('/');
|
||||
|
||||
if target.starts_with("http://") || target.starts_with("https://") {
|
||||
return format!("/proxy/{target}");
|
||||
}
|
||||
|
||||
if base.is_empty() {
|
||||
format!("/proxy/{proxy}/{target}")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user