From 060d8e79376f6611d3e0457fed7ab3511f54ef72 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 26 Feb 2026 11:05:32 +0000 Subject: [PATCH] bug prevention with video.url for Hottub38 --- src/api.rs | 31 +++++++++++++++++++++++++++---- src/providers/hentaihaven.rs | 2 +- src/providers/javtiful.rs | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/api.rs b/src/api.rs index e039a7a..0fa291e 100644 --- a/src/api.rs +++ b/src/api.rs @@ -111,10 +111,10 @@ async fn status(req: HttpRequest) -> Result { 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, "999".to_string())), - Err(_) => ClientVersion::new(999, 0, "999".to_string()), + .unwrap_or_else(|| ClientVersion::new(999, 0, "Hot%20Tub".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!( @@ -962,7 +962,16 @@ async fn videos_post( cache: web::types::State, pool: web::types::State, requester: web::types::State, + req: HttpRequest, ) -> Result { + 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() { Some(query) if query.starts_with("#") => { video_request.query = Some(query.trim_start_matches("#").to_string()); @@ -1046,7 +1055,7 @@ async fn videos_post( duration: Some(duration), sort: Some(sort.clone()), }; - let video_items = provider + let mut video_items = provider .get_videos( cache.get_ref().clone(), pool.get_ref().clone(), @@ -1057,6 +1066,20 @@ async fn videos_post( options.clone(), ) .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(); if video_items.len() == 0 { videos.pageInfo = PageInfo { diff --git a/src/providers/hentaihaven.rs b/src/providers/hentaihaven.rs index adb5cc1..3ddbde8 100644 --- a/src/providers/hentaihaven.rs +++ b/src/providers/hentaihaven.rs @@ -450,7 +450,7 @@ impl HentaihavenProvider { } 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) .tags(tags) .views(views) diff --git a/src/providers/javtiful.rs b/src/providers/javtiful.rs index 82d7b5b..caf9e81 100644 --- a/src/providers/javtiful.rs +++ b/src/providers/javtiful.rs @@ -320,7 +320,7 @@ impl JavtifulProvider { let video_item = VideoItem::new( id, title, - formats.first().map(|f| f.url.clone()).unwrap_or_default(), + video_url, "javtiful".into(), thumb, duration,