heavyfetish and other changes

This commit is contained in:
Simon
2026-03-17 21:04:11 +00:00
parent 9ca9e820d9
commit a66f44c747
5 changed files with 1393 additions and 56 deletions

View File

@@ -10,9 +10,37 @@ use crate::util::requester::Requester;
const FIREFOX_USER_AGENT: &str =
"Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0";
const HTML_ACCEPT: &str =
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8";
const IMAGE_ACCEPT: &str =
"image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5";
fn root_referer() -> &'static str {
"https://pimpbunny.com/"
}
fn root_html_headers() -> Vec<(String, String)> {
vec![
("Referer".to_string(), root_referer().to_string()),
("User-Agent".to_string(), FIREFOX_USER_AGENT.to_string()),
("Accept".to_string(), HTML_ACCEPT.to_string()),
("Accept-Language".to_string(), "en-US,en;q=0.9".to_string()),
]
}
fn image_headers(requester: &Requester, image_url: &str) -> Vec<(String, String)> {
let mut headers = vec![
("Referer".to_string(), root_referer().to_string()),
("User-Agent".to_string(), FIREFOX_USER_AGENT.to_string()),
("Accept".to_string(), IMAGE_ACCEPT.to_string()),
("Accept-Language".to_string(), "en-US,en;q=0.9".to_string()),
];
if let Some(cookie) = requester.cookie_header_for_url(image_url) {
headers.push(("Cookie".to_string(), cookie));
}
headers
}
fn is_allowed_thumb_url(url: &str) -> bool {
let Some(url) = Url::parse(url).ok() else {
return false;
@@ -43,13 +71,12 @@ pub async fn get_image(
return Ok(web::HttpResponse::BadRequest().finish());
}
let headers = vec![
("Referer".to_string(), "https://pimpbunny.com/".to_string()),
("User-Agent".to_string(), FIREFOX_USER_AGENT.to_string()),
("Accept".to_string(), IMAGE_ACCEPT.to_string()),
("Accept-Language".to_string(), "en-US,en;q=0.9".to_string()),
];
let mut requester = requester.get_ref().clone();
let _ = requester
.get_with_headers(root_referer(), root_html_headers(), Some(Version::HTTP_11))
.await;
let mut headers = image_headers(&requester, image_url.as_str());
let mut upstream = requester
.get_raw_with_headers(image_url.as_str(), headers.clone())
@@ -63,21 +90,9 @@ pub async fn get_image(
if needs_warmup {
let _ = requester
.get_with_headers(
"https://pimpbunny.com/",
vec![
("Referer".to_string(), "https://pimpbunny.com/".to_string()),
("User-Agent".to_string(), FIREFOX_USER_AGENT.to_string()),
(
"Accept".to_string(),
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
.to_string(),
),
("Accept-Language".to_string(), "en-US,en;q=0.9".to_string()),
],
Some(Version::HTTP_11),
)
.get_with_headers(root_referer(), root_html_headers(), Some(Version::HTTP_11))
.await;
headers = image_headers(&requester, image_url.as_str());
upstream = requester
.get_raw_with_headers(image_url.as_str(), headers.clone())
@@ -94,6 +109,7 @@ pub async fn get_image(
let _ = requester
.get_with_headers(image_url.as_str(), headers.clone(), Some(Version::HTTP_11))
.await;
headers = image_headers(&requester, image_url.as_str());
upstream = requester
.get_raw_with_headers(image_url.as_str(), headers)