pmvhaven fix

This commit is contained in:
Simon
2025-10-12 19:23:16 +00:00
parent dcb5148da6
commit 09c06df163
2 changed files with 10 additions and 29 deletions

View File

@@ -26,6 +26,7 @@ struct PmvhavenRequest {
other: bool, // false,
explicitContent: Option<bool>, //null,
sameSexContent: Option<bool>, //null,
transContent: Option<String>, //null
seizureWarning: Option<bool>, //null,
tags: Vec<String>, //[],
music: Vec<String>, //[],
@@ -37,7 +38,6 @@ struct PmvhavenRequest {
aspectRatio: String, //"Aspect Ratio",
activeView: String, //"Newest",
index: u32, //2,
hideUntagged: bool, //true,
showSubscriptionsOnly: bool, //false,
query: String, //"no",
profile: Option<String>, //null
@@ -55,6 +55,7 @@ impl PmvhavenRequest {
other: false,
explicitContent: None,
sameSexContent: None,
transContent: None,
seizureWarning: None,
tags: vec![],
music: vec![],
@@ -66,7 +67,6 @@ impl PmvhavenRequest {
aspectRatio: "Aspect Ratio".to_string(),
activeView: "Newest".to_string(),
index: page,
hideUntagged: true,
showSubscriptionsOnly: false,
query: "no".to_string(),
profile: None,
@@ -210,32 +210,8 @@ impl PmvhavenVideo {
}
}
// Define a percent-encoding set that encodes all non-ASCII characters
// const EMOJI_ENCODE_SET: &AsciiSet = &CONTROLS
// .add(b' ')
// .add(b'"')
// .add(b'#')
// .add(b'%')
// .add(b'<')
// .add(b'>')
// .add(b'?')
// .add(b'[')
// .add(b'\\')
// .add(b']')
// .add(b'^')
// .add(b'`')
// .add(b'{')
// .add(b'|')
// .add(b'}');
//
// Helper function to percent-encode emojis and other non-ASCII chars
// fn percent_encode_emojis(s: &str) -> String {
// utf8_percent_encode(s, EMOJI_ENCODE_SET).to_string()
// }
#[derive(serde::Deserialize)]
struct PmvhavenResponse {
_httpStatusCode: Option<u32>,
data: Vec<PmvhavenVideo>,
_count: Option<u32>,
}
@@ -311,7 +287,7 @@ impl PmvhavenProvider {
};
let mut requester = options.requester.clone().unwrap();
let response = requester.post(&url, &request).await.unwrap();
let response = requester.post(&url, &request, vec![("Content-Type".to_string(),"text/plain;charset=UTF-8".to_string())]).await.unwrap();
let videos = match response.json::<PmvhavenResponse>().await {
Ok(resp) => resp,
Err(e) => {
@@ -355,7 +331,7 @@ impl PmvhavenProvider {
};
let mut requester = options.requester.clone().unwrap();
let response = requester.post(&url, &request).await.unwrap();
let response = requester.post(&url, &request, vec![("Content-Type".to_string(),"text/plain;charset=UTF-8".to_string())]).await.unwrap();
let videos = match response.json::<PmvhavenResponse>().await {
Ok(resp) => resp,
Err(e) => {

View File

@@ -83,7 +83,7 @@ impl Requester {
request.send().await
}
pub async fn post<S>(&mut self, url: &str, data: &S) -> Result<Response, wreq::Error>
pub async fn post<S>(&mut self, url: &str, data: &S, headers: Vec<(String, String)>) -> Result<Response, wreq::Error>
where
S: Serialize + ?Sized,
{
@@ -96,6 +96,11 @@ impl Requester {
let mut request = client.post(url).version(Version::HTTP_11).json(data);
// Set custom headers
for (key, value) in headers.iter() {
request = request.header(key, value);
}
if self.proxy {
if let Ok(proxy_url) = env::var("BURP_URL") {
let proxy = Proxy::all(&proxy_url).unwrap();