switched request module, so no need for burpsuite anymore

This commit is contained in:
Simon
2025-07-15 18:01:26 +00:00
parent fe8c564126
commit d77e292dbd
6 changed files with 49 additions and 136 deletions

View File

@@ -3,28 +3,24 @@ use std::env;
use error_chain::error_chain;
use futures::future::join_all;
use htmlentity::entity::{decode, ICodedDataTrait};
use ntex::channel::pool;
use reqwest::Client;
use reqwest::{Proxy};
use crate::db;
use crate::providers::Provider;
use crate::util::cache::VideoCache;
use crate::util::flaresolverr::{FlareSolverrRequest, Flaresolverr};
use crate::videos::{self, VideoItem};
use crate::videos::{VideoItem};
use crate::DbPool;
use crate::USER_AGENT; // Make sure Provider trait is imported
use std::collections::HashMap;
use std::time::Duration;
use tokio::time::sleep;
use wreq::Client;
use wreq_util::Emulation;
error_chain! {
foreign_links {
Io(std::io::Error);
HttpRequest(reqwest::Error);
HttpRequest(wreq::Error);
}
}
#[derive(Debug, Clone)]
pub struct SpankbangProvider {
url: String,
@@ -55,18 +51,9 @@ impl SpankbangProvider {
};
let client = match env::var("BURP_URL").as_deref() {
Ok(burp_url) =>
reqwest::Client::builder()
.user_agent(USER_AGENT)
.proxy(Proxy::https(burp_url).unwrap())
.danger_accept_invalid_certs(true)
.build()?,
Err(_) => reqwest::Client::builder()
.user_agent(USER_AGENT)
.danger_accept_invalid_certs(true)
.build()?,
};
let client = Client::builder()
.emulation(Emulation::Firefox136)
.build()?;
let response = client.get(url.clone()).send().await?;
let mut cookies_string = String::new();
@@ -151,18 +138,9 @@ impl SpankbangProvider {
};
let client = match env::var("BURP_URL").as_deref() {
Ok(burp_url) =>
reqwest::Client::builder()
.user_agent(USER_AGENT)
.proxy(Proxy::https(burp_url).unwrap())
.danger_accept_invalid_certs(true)
.build()?,
Err(_) => reqwest::Client::builder()
.user_agent(USER_AGENT)
.danger_accept_invalid_certs(true)
.build()?,
};
let client = Client::builder()
.emulation(Emulation::Firefox136)
.build()?;
let response = client.get(url.clone()).send().await?;
let mut cookies_string = String::new();
@@ -277,7 +255,6 @@ impl SpankbangProvider {
let vid = html.split("\n").collect::<Vec<&str>>();
if vid.len() > 200 {
println!("Video item has too many lines: {}", vid.len());
return Err("Video item has too many lines".into());
}
// for (index ,line) in vid.iter().enumerate() {
@@ -303,13 +280,13 @@ impl SpankbangProvider {
// else{
// preview = preview_line.split("data-src=\"").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0].to_string();
// }
let duration_str = vid.iter().find(|s| s.contains("<span class=\"video-badge l\">")).unwrap().split("<span class=\"video-badge l\">").collect::<Vec<&str>>()[1].split("m<").collect::<Vec<&str>>()[0];
let duration_str = vid[64].split("m").collect::<Vec<&str>>()[0];
let duration: u32 = duration_str.parse::<u32>().unwrap_or(0) * 60;
let view_and_rating_str: Vec<&str> = vid.iter().copied().filter(|s| s.contains("<span class=\"md:text-body-md\">")).collect();
let views_str = view_and_rating_str[0].split(">").collect::<Vec<&str>>()[1].split("K<").collect::<Vec<&str>>()[0];
let views = (views_str.parse::<f32>().unwrap_or(0.0) * 1000.0) as u32;
let rate_str = view_and_rating_str[1].split(">").collect::<Vec<&str>>()[1].split("%<").collect::<Vec<&str>>()[0];
let rating = rate_str.parse::<f32>().unwrap_or(0.0);
// let view_and_rating_str: Vec<&str> = vid.iter().copied().filter(|s| s.contains("<span class=\"md:text-body-md\">")).collect();
// let views_str = view_and_rating_str[0].split(">").collect::<Vec<&str>>()[1].split("K<").collect::<Vec<&str>>()[0];
// let views = (views_str.parse::<f32>().unwrap_or(0.0) * 1000.0) as u32;
// let rate_str = view_and_rating_str[1].split(">").collect::<Vec<&str>>()[1].split("%<").collect::<Vec<&str>>()[0];
// let rating = rate_str.parse::<f32>().unwrap_or(0.0);
let url_part = vid.iter().find(|s| s.contains("<a href=\"/")).unwrap().split("<a href=\"/").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0];
let url = match self.get_video_url(self.url.clone() + url_part, client, cookies, pool).await {
Ok(video_url) => video_url,
@@ -332,8 +309,8 @@ impl SpankbangProvider {
};
let video_item = VideoItem::new(id, title, url.clone().to_string(), "spankbang".to_string(), thumb, duration)
.views(views)
.rating(rating)
// .views(views)
// .rating(rating)
// .formats(vec![format])
// .preview(preview)
;