bug prevention with video.url for Hottub38

This commit is contained in:
Simon
2026-02-26 11:05:32 +00:00
parent 4ad9453245
commit 060d8e7937
3 changed files with 29 additions and 6 deletions

View File

@@ -111,10 +111,10 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
let clientversion: ClientVersion = match req.headers().get("User-Agent") { let clientversion: ClientVersion = match req.headers().get("User-Agent") {
Some(v) => match v.to_str() { Some(v) => match v.to_str() {
Ok(useragent) => ClientVersion::parse(useragent) Ok(useragent) => ClientVersion::parse(useragent)
.unwrap_or_else(|| ClientVersion::new(999, 0, "999".to_string())), .unwrap_or_else(|| ClientVersion::new(999, 0, "Hot%20Tub".to_string())),
Err(_) => ClientVersion::new(999, 0, "999".to_string()), Err(_) => ClientVersion::new(999, 0, "Hot%20Tub".to_string()),
}, },
_ => ClientVersion::new(999, 0, "999".to_string()), _ => ClientVersion::new(999, 0, "Hot%20Tub".to_string()),
}; };
println!( println!(
@@ -962,7 +962,16 @@ async fn videos_post(
cache: web::types::State<VideoCache>, cache: web::types::State<VideoCache>,
pool: web::types::State<DbPool>, pool: web::types::State<DbPool>,
requester: web::types::State<Requester>, requester: web::types::State<Requester>,
req: HttpRequest,
) -> Result<impl web::Responder, web::Error> { ) -> Result<impl web::Responder, web::Error> {
let clientversion: ClientVersion = match req.headers().get("User-Agent") {
Some(v) => match v.to_str() {
Ok(useragent) => ClientVersion::parse(useragent)
.unwrap_or_else(|| ClientVersion::new(999, 0, "Hot%20Tub".to_string())),
Err(_) => ClientVersion::new(999, 0, "Hot%20Tub".to_string()),
},
_ => ClientVersion::new(999, 0, "Hot%20Tub".to_string()),
};
match video_request.query.as_deref() { match video_request.query.as_deref() {
Some(query) if query.starts_with("#") => { Some(query) if query.starts_with("#") => {
video_request.query = Some(query.trim_start_matches("#").to_string()); video_request.query = Some(query.trim_start_matches("#").to_string());
@@ -1046,7 +1055,7 @@ async fn videos_post(
duration: Some(duration), duration: Some(duration),
sort: Some(sort.clone()), sort: Some(sort.clone()),
}; };
let video_items = provider let mut video_items = provider
.get_videos( .get_videos(
cache.get_ref().clone(), cache.get_ref().clone(),
pool.get_ref().clone(), pool.get_ref().clone(),
@@ -1057,6 +1066,20 @@ async fn videos_post(
options.clone(), options.clone(),
) )
.await; .await;
// There is a bug in Hottub38 that makes the client error for a 403-url even though formats work fine
if clientversion == ClientVersion::new(38, 0, "Hot%20Tub".to_string()) {
// filter out videos without preview for old clients
video_items = video_items.into_iter().filter_map(|video| {
if !video.formats.is_none() && video.formats.as_ref().unwrap().len() > 0 {
let mut v = video;
v.url = v.formats.as_ref().unwrap().last().unwrap().url.clone();
return Some(v);
}
Some(video)
}).collect();
}
videos.items = video_items.clone(); videos.items = video_items.clone();
if video_items.len() == 0 { if video_items.len() == 0 {
videos.pageInfo = PageInfo { videos.pageInfo = PageInfo {

View File

@@ -450,7 +450,7 @@ impl HentaihavenProvider {
} }
let video_item = let video_item =
VideoItem::new(id, title, formats.last().unwrap().clone().url, "hentaihaven".into(), thumb, 0) VideoItem::new(id, title, video_url.clone(), "hentaihaven".into(), thumb, 0)
.formats(formats) .formats(formats)
.tags(tags) .tags(tags)
.views(views) .views(views)

View File

@@ -320,7 +320,7 @@ impl JavtifulProvider {
let video_item = VideoItem::new( let video_item = VideoItem::new(
id, id,
title, title,
formats.first().map(|f| f.url.clone()).unwrap_or_default(), video_url,
"javtiful".into(), "javtiful".into(),
thumb, thumb,
duration, duration,