more fixes
This commit is contained in:
@@ -58,20 +58,39 @@ impl Provider for AllProvider {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let futures = providers.iter().map(|provider| {
|
let futures = providers.iter().map(|provider| {
|
||||||
provider.get_videos(
|
let provider = provider.clone();
|
||||||
cache.clone(),
|
let cache = cache.clone();
|
||||||
pool.clone(),
|
let pool = pool.clone();
|
||||||
sort.clone(),
|
let sort = sort.clone();
|
||||||
query.clone(),
|
let query = query.clone();
|
||||||
page.clone(),
|
let page = page.clone();
|
||||||
per_page.clone(),
|
let per_page = per_page.clone();
|
||||||
options.clone()
|
let options = options.clone();
|
||||||
|
async move {
|
||||||
|
match tokio::time::timeout(
|
||||||
|
std::time::Duration::from_secs(55),
|
||||||
|
provider.get_videos(
|
||||||
|
cache,
|
||||||
|
pool,
|
||||||
|
sort,
|
||||||
|
query,
|
||||||
|
page,
|
||||||
|
per_page,
|
||||||
|
options,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(_) => {
|
||||||
|
// timed out -> return empty result for this provider
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
let results:Vec<Vec<VideoItem>> = join_all(futures).await;
|
let results:Vec<Vec<VideoItem>> = join_all(futures).await;
|
||||||
let video_items: Vec<VideoItem> = interleave(&results);
|
let video_items: Vec<VideoItem> = interleave(&results);
|
||||||
|
|
||||||
|
|
||||||
return video_items;
|
return video_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ error_chain! {
|
|||||||
foreign_links {
|
foreign_links {
|
||||||
Io(std::io::Error);
|
Io(std::io::Error);
|
||||||
HttpRequest(wreq::Error);
|
HttpRequest(wreq::Error);
|
||||||
|
Json(serde_json::Error);
|
||||||
|
}
|
||||||
|
errors {
|
||||||
|
Parse(msg: String) {
|
||||||
|
description("parse error")
|
||||||
|
display("parse error: {}", msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,24 +34,15 @@ pub struct BeegProvider {
|
|||||||
stars: Arc<RwLock<Vec<FilterOption>>>,
|
stars: Arc<RwLock<Vec<FilterOption>>>,
|
||||||
categories: Arc<RwLock<Vec<FilterOption>>>,
|
categories: Arc<RwLock<Vec<FilterOption>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BeegProvider {
|
impl BeegProvider {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let provider = BeegProvider {
|
let provider = BeegProvider {
|
||||||
sites: Arc::new(RwLock::new(vec![FilterOption {
|
sites: Arc::new(RwLock::new(vec![FilterOption { id: "all".into(), title: "All".into() }])),
|
||||||
id: "all".to_string(),
|
stars: Arc::new(RwLock::new(vec![FilterOption { id: "all".into(), title: "All".into() }])),
|
||||||
title: "All".to_string(),
|
categories: Arc::new(RwLock::new(vec![FilterOption { id: "all".into(), title: "All".into() }])),
|
||||||
}])),
|
|
||||||
stars: Arc::new(RwLock::new(vec![FilterOption {
|
|
||||||
id: "all".to_string(),
|
|
||||||
title: "All".to_string(),
|
|
||||||
}])),
|
|
||||||
categories: Arc::new(RwLock::new(vec![FilterOption {
|
|
||||||
id: "all".to_string(),
|
|
||||||
title: "All".to_string(),
|
|
||||||
}])),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Kick off the background load but return immediately
|
|
||||||
provider.spawn_initial_load();
|
provider.spawn_initial_load();
|
||||||
provider
|
provider
|
||||||
}
|
}
|
||||||
@@ -55,160 +53,142 @@ impl BeegProvider {
|
|||||||
let stars = Arc::clone(&self.stars);
|
let stars = Arc::clone(&self.stars);
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
// Create a tiny runtime just for these async tasks
|
let rt = match tokio::runtime::Builder::new_current_thread().enable_all().build() {
|
||||||
let rt = tokio::runtime::Builder::new_current_thread()
|
Ok(rt) => rt,
|
||||||
.enable_all()
|
Err(e) => {
|
||||||
.build()
|
eprintln!("beeg runtime init failed: {}", e);
|
||||||
.expect("build tokio runtime");
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
rt.block_on(async move {
|
rt.block_on(async move {
|
||||||
// If you have a streaming sites loader, call it here too
|
|
||||||
if let Err(e) = Self::load_sites(sites).await {
|
if let Err(e) = Self::load_sites(sites).await {
|
||||||
eprintln!("beeg load_sites_into failed: {e}");
|
eprintln!("beeg load_sites failed: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = Self::load_categories(categories).await {
|
if let Err(e) = Self::load_categories(categories).await {
|
||||||
eprintln!("beeg load_categories failed: {e}");
|
eprintln!("beeg load_categories failed: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = Self::load_stars(stars).await {
|
if let Err(e) = Self::load_stars(stars).await {
|
||||||
eprintln!("beeg load_stars failed: {e}");
|
eprintln!("beeg load_stars failed: {}", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn load_stars(stars: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
|
async fn fetch_tags() -> Result<Value> {
|
||||||
let mut requester = util::requester::Requester::new();
|
let mut requester = util::requester::Requester::new();
|
||||||
let text = requester
|
let text = match requester
|
||||||
.get("https://store.externulls.com/tag/facts/tags?get_original=true&slug=index", None)
|
.get("https://store.externulls.com/tag/facts/tags?get_original=true&slug=index", None)
|
||||||
.await
|
.await {
|
||||||
.unwrap();
|
Ok(text) => text,
|
||||||
let json: serde_json::Value = serde_json::from_str::<serde_json::Value>(&text).unwrap();
|
Err(e) => {
|
||||||
let stars_array = json.get("human").unwrap().as_array().unwrap();
|
eprintln!("beeg fetch_tags failed: {}", e);
|
||||||
for s in stars_array {
|
return Err(ErrorKind::Parse("failed to fetch tags".into()).into());
|
||||||
let star_name = s.get("tg_name").unwrap().as_str().unwrap().to_string();
|
}
|
||||||
let star_id = s.get("tg_slug").unwrap().as_str().unwrap().to_string();
|
};
|
||||||
Self::push_unique(
|
Ok(serde_json::from_str(&text)?)
|
||||||
&stars,
|
}
|
||||||
FilterOption {
|
|
||||||
id: star_id,
|
async fn load_stars(stars: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
|
||||||
title: star_name,
|
let json = Self::fetch_tags().await?;
|
||||||
},
|
let arr = json
|
||||||
);
|
.get("human")
|
||||||
|
.and_then(|v| v.as_array().map(|v| v.as_slice()))
|
||||||
|
.unwrap_or(&[]);
|
||||||
|
for s in arr {
|
||||||
|
if let (Some(name), Some(id)) = (
|
||||||
|
s.get("tg_name").and_then(|v| v.as_str()),
|
||||||
|
s.get("tg_slug").and_then(|v| v.as_str()),
|
||||||
|
) {
|
||||||
|
Self::push_unique(&stars, FilterOption { id: id.into(), title: name.into() });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Ok(());
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn load_categories(categories: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
|
async fn load_categories(categories: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
|
||||||
let mut requester = util::requester::Requester::new();
|
let json = Self::fetch_tags().await?;
|
||||||
let text = requester
|
let arr = json
|
||||||
.get("https://store.externulls.com/tag/facts/tags?get_original=true&slug=index", None)
|
.get("other")
|
||||||
.await
|
.and_then(|v| v.as_array().map(|v| v.as_slice()))
|
||||||
.unwrap();
|
.unwrap_or(&[]);
|
||||||
let json: serde_json::Value = serde_json::from_str::<serde_json::Value>(&text).unwrap();
|
for s in arr {
|
||||||
let stars_array = json.get("other").unwrap().as_array().unwrap();
|
if let (Some(name), Some(id)) = (
|
||||||
for s in stars_array {
|
s.get("tg_name").and_then(|v| v.as_str()),
|
||||||
let star_name = s.get("tg_name").unwrap().as_str().unwrap().to_string();
|
s.get("tg_slug").and_then(|v| v.as_str()),
|
||||||
let star_id = s.get("tg_slug").unwrap().as_str().unwrap().to_string();
|
) {
|
||||||
Self::push_unique(
|
Self::push_unique(
|
||||||
&categories,
|
&categories,
|
||||||
FilterOption {
|
FilterOption {
|
||||||
id: star_id.replace("{","").replace("}",""),
|
id: id.replace('{', "").replace('}', ""),
|
||||||
title: star_name.replace("{","").replace("}",""),
|
title: name.replace('{', "").replace('}', ""),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Ok(());
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn load_sites(sites: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
|
async fn load_sites(sites: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
|
||||||
let mut requester = util::requester::Requester::new();
|
let json = Self::fetch_tags().await?;
|
||||||
let text = requester
|
let arr = json
|
||||||
.get("https://store.externulls.com/tag/facts/tags?get_original=true&slug=index", None)
|
.get("productions")
|
||||||
.await
|
.and_then(|v| v.as_array().map(|v| v.as_slice()))
|
||||||
.unwrap();
|
.unwrap_or(&[]);
|
||||||
let json: serde_json::Value = serde_json::from_str::<serde_json::Value>(&text).unwrap();
|
for s in arr {
|
||||||
let stars_array = json.get("productions").unwrap().as_array().unwrap();
|
if let (Some(name), Some(id)) = (
|
||||||
for s in stars_array {
|
s.get("tg_name").and_then(|v| v.as_str()),
|
||||||
let star_name = s.get("tg_name").unwrap().as_str().unwrap().to_string();
|
s.get("tg_slug").and_then(|v| v.as_str()),
|
||||||
let star_id = s.get("tg_slug").unwrap().as_str().unwrap().to_string();
|
) {
|
||||||
Self::push_unique(
|
Self::push_unique(&sites, FilterOption { id: id.into(), title: name.into() });
|
||||||
&sites,
|
}
|
||||||
FilterOption {
|
|
||||||
id: star_id,
|
|
||||||
title: star_name,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return Ok(());
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push one item with minimal lock time and dedup by id
|
|
||||||
fn push_unique(target: &Arc<RwLock<Vec<FilterOption>>>, item: FilterOption) {
|
fn push_unique(target: &Arc<RwLock<Vec<FilterOption>>>, item: FilterOption) {
|
||||||
if let Ok(mut vec) = target.write() {
|
if let Ok(mut vec) = target.write() {
|
||||||
if !vec.iter().any(|x| x.id == item.id) {
|
if !vec.iter().any(|x| x.id == item.id) {
|
||||||
vec.push(item);
|
vec.push(item);
|
||||||
// Optional: keep it sorted for nicer UX
|
|
||||||
// vec.sort_by(|a,b| a.title.cmp(&b.title));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_channel(&self, clientversion: ClientVersion) -> Channel {
|
fn build_channel(&self, _: ClientVersion) -> Channel {
|
||||||
let _ = clientversion;
|
|
||||||
let sites: Vec<FilterOption> = self
|
|
||||||
.sites
|
|
||||||
.read()
|
|
||||||
.map(|g| g.clone()) // or: .map(|g| g.to_vec())
|
|
||||||
.unwrap_or_default(); // or: .unwrap_or_else(|_| Vec::new())
|
|
||||||
|
|
||||||
let categories: Vec<FilterOption> = self
|
|
||||||
.categories
|
|
||||||
.read()
|
|
||||||
.map(|g| g.clone()) // or: .map(|g| g.to_vec())
|
|
||||||
.unwrap_or_default(); // or: .unwrap_or_else(|_| Vec::new())
|
|
||||||
|
|
||||||
let stars: Vec<FilterOption> = self
|
|
||||||
.stars
|
|
||||||
.read()
|
|
||||||
.map(|g| g.clone()) // or: .map(|g| g.to_vec())
|
|
||||||
.unwrap_or_default(); // or: .unwrap_or_else(|_| Vec::new())
|
|
||||||
|
|
||||||
Channel {
|
Channel {
|
||||||
id: "beeg".to_string(),
|
id: "beeg".into(),
|
||||||
name: "Beeg".to_string(),
|
name: "Beeg".into(),
|
||||||
description: "Watch your favorite Porn on Beeg.com".to_string(),
|
description: "Watch your favorite Porn on Beeg.com".into(),
|
||||||
premium: false,
|
premium: false,
|
||||||
favicon: "https://www.google.com/s2/favicons?sz=64&domain=beeg.com".to_string(),
|
favicon: "https://www.google.com/s2/favicons?sz=64&domain=beeg.com".into(),
|
||||||
status: "active".to_string(),
|
status: "active".into(),
|
||||||
categories: vec![],
|
categories: vec![],
|
||||||
options: vec![
|
options: vec![
|
||||||
ChannelOption {
|
ChannelOption {
|
||||||
id: "sites".to_string(),
|
id: "sites".into(),
|
||||||
title: "Sites".to_string(),
|
title: "Sites".into(),
|
||||||
description: "Filter for different Sites".to_string(),
|
description: "Filter for different Sites".into(),
|
||||||
systemImage: "rectangle.stack".to_string(),
|
systemImage: "rectangle.stack".into(),
|
||||||
colorName: "green".to_string(),
|
colorName: "green".into(),
|
||||||
options: sites,
|
options: self.sites.read().map(|v| v.clone()).unwrap_or_default(),
|
||||||
multiSelect: false,
|
multiSelect: false,
|
||||||
},
|
},
|
||||||
ChannelOption {
|
ChannelOption {
|
||||||
id: "categories".to_string(),
|
id: "categories".into(),
|
||||||
title: "Categories".to_string(),
|
title: "Categories".into(),
|
||||||
description: "Filter for different Networks".to_string(),
|
description: "Filter for different Networks".into(),
|
||||||
systemImage: "list.dash".to_string(),
|
systemImage: "list.dash".into(),
|
||||||
colorName: "purple".to_string(),
|
colorName: "purple".into(),
|
||||||
options: categories,
|
options: self.categories.read().map(|v| v.clone()).unwrap_or_default(),
|
||||||
multiSelect: false,
|
multiSelect: false,
|
||||||
},
|
},
|
||||||
ChannelOption {
|
ChannelOption {
|
||||||
id: "stars".to_string(),
|
id: "stars".into(),
|
||||||
title: "Stars".to_string(),
|
title: "Stars".into(),
|
||||||
description: "Filter for different Pornstars".to_string(),
|
description: "Filter for different Pornstars".into(),
|
||||||
systemImage: "star.fill".to_string(),
|
systemImage: "star.fill".into(),
|
||||||
colorName: "yellow".to_string(),
|
colorName: "yellow".into(),
|
||||||
options: stars,
|
options: self.stars.read().map(|v| v.clone()).unwrap_or_default(),
|
||||||
multiSelect: false,
|
multiSelect: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -316,89 +296,61 @@ impl BeegProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_video_items_from_html(&self, json: Value) -> Vec<VideoItem> {
|
fn get_video_items_from_html(&self, json: Value) -> Vec<VideoItem> {
|
||||||
let mut items: Vec<VideoItem> = Vec::new();
|
let mut items = Vec::new();
|
||||||
let video_items = match json.as_array(){
|
let array = match json.as_array() {
|
||||||
Some(array) => array,
|
Some(a) => a,
|
||||||
None => return items,
|
None => return items,
|
||||||
};
|
};
|
||||||
for video in video_items {
|
|
||||||
// println!("video: {}\n\n\n", serde_json::to_string_pretty(&video).unwrap());
|
for video in array {
|
||||||
let file = match video.get("file"){
|
let file = match video.get("file") { Some(v) => v, None => continue };
|
||||||
|
let hls = match file.get("hls_resources") { Some(v) => v, None => continue };
|
||||||
|
let key = match hls.get("fl_cdn_multi").and_then(|v| v.as_str()) {
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
let hls_resources = match file.get("hls_resources"){
|
|
||||||
Some(v) => v,
|
let id = file.get("id").and_then(|v| v.as_i64()).unwrap_or(0).to_string();
|
||||||
None => continue,
|
let title = video
|
||||||
};
|
.get("data")
|
||||||
let video_key = match hls_resources.get("fl_cdn_multi"){
|
.and_then(|v| v.get(0))
|
||||||
Some(v) => v,
|
.and_then(|v| v.get("cd_value"))
|
||||||
None => continue,
|
.and_then(|v| v.as_str())
|
||||||
};
|
.map(|s| decode(s.as_bytes()).to_string().unwrap_or_default())
|
||||||
let video_url = format!(
|
.unwrap_or_default();
|
||||||
"https://video.externulls.com/{}",
|
|
||||||
video_key.to_string().replace("\"","")
|
let duration = file
|
||||||
);
|
.get("fl_duration")
|
||||||
let data = match file.get("data") {
|
.and_then(|v| v.as_str())
|
||||||
Some(v) => v,
|
.and_then(|s| parse_time_to_seconds(s))
|
||||||
None => continue,
|
.unwrap_or(0);
|
||||||
};
|
|
||||||
let title = match data[0].get("cd_value") {
|
let views = video
|
||||||
Some(v) => decode(v.as_str().unwrap_or("").as_bytes()).to_string().unwrap_or(v.to_string()),
|
.get("fc_facts")
|
||||||
None => "".to_string(),
|
.and_then(|v| v.get(0))
|
||||||
};
|
.and_then(|v| v.get("fc_st_views"))
|
||||||
let id = match file.get("id"){
|
.and_then(|v| v.as_str())
|
||||||
Some(v) => v.as_i64().unwrap_or(0).to_string(),
|
.and_then(|s| parse_abbreviated_number(s))
|
||||||
None => title.clone(),
|
.unwrap_or(0);
|
||||||
};
|
|
||||||
let fc_facts = match video.get("fc_facts") {
|
|
||||||
Some(v) => v[0].clone(),
|
|
||||||
None => continue,
|
|
||||||
};
|
|
||||||
let duration = match file.get("fl_duration") {
|
|
||||||
Some(v) => parse_time_to_seconds(v.as_str().unwrap_or("0")).unwrap_or(0),
|
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let tags = match video.get("tags") {
|
|
||||||
Some(v) => {
|
|
||||||
// v should be an array of tag objects
|
|
||||||
v.as_array()
|
|
||||||
.map(|arr| {
|
|
||||||
arr.iter()
|
|
||||||
.map(|tag| {
|
|
||||||
tag.get("tg_name")
|
|
||||||
.and_then(|name| name.as_str())
|
|
||||||
.unwrap_or("")
|
|
||||||
.to_string()
|
|
||||||
})
|
|
||||||
.collect::<Vec<String>>()
|
|
||||||
})
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
|
||||||
None => Vec::new(),
|
|
||||||
};
|
|
||||||
let thumb = format!("https://thumbs.externulls.com/videos/{}/0.webp?size=480x270", id);
|
let thumb = format!("https://thumbs.externulls.com/videos/{}/0.webp?size=480x270", id);
|
||||||
let views = match fc_facts.get("fc_st_views") {
|
|
||||||
Some(v) => parse_abbreviated_number(v.as_str().unwrap_or("0")).unwrap_or(0),
|
let mut item = VideoItem::new(
|
||||||
None => 0,
|
|
||||||
};
|
|
||||||
let mut video_item = VideoItem::new(
|
|
||||||
id,
|
id,
|
||||||
title,
|
title,
|
||||||
video_url.to_string(),
|
format!("https://video.externulls.com/{}", key),
|
||||||
"beeg".to_string(),
|
"beeg".into(),
|
||||||
thumb,
|
thumb,
|
||||||
duration as u32,
|
duration as u32,
|
||||||
);
|
);
|
||||||
|
|
||||||
if views > 0 {
|
if views > 0 {
|
||||||
video_item = video_item.views(views);
|
item = item.views(views);
|
||||||
}
|
}
|
||||||
if !tags.is_empty() {
|
|
||||||
video_item = video_item.tags(tags);
|
items.push(item);
|
||||||
}
|
|
||||||
items.push(video_item);
|
|
||||||
}
|
}
|
||||||
return items;
|
items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,32 +359,26 @@ impl Provider for BeegProvider {
|
|||||||
async fn get_videos(
|
async fn get_videos(
|
||||||
&self,
|
&self,
|
||||||
cache: VideoCache,
|
cache: VideoCache,
|
||||||
_pool: DbPool,
|
_: DbPool,
|
||||||
_sort: String,
|
_: String,
|
||||||
query: Option<String>,
|
query: Option<String>,
|
||||||
page: String,
|
page: String,
|
||||||
_per_page: String,
|
_: String,
|
||||||
options: ServerOptions,
|
options: ServerOptions,
|
||||||
) -> Vec<VideoItem> {
|
) -> Vec<VideoItem> {
|
||||||
let videos: std::result::Result<Vec<VideoItem>, Error> = match query {
|
let page = page.parse::<u8>().unwrap_or(1);
|
||||||
Some(q) => {
|
let result = match query {
|
||||||
self.query(cache, page.parse::<u8>().unwrap_or(1), &q, options)
|
Some(q) => self.query(cache, page, &q, options).await,
|
||||||
.await
|
None => self.get(cache, page, options).await,
|
||||||
}
|
|
||||||
None => {
|
|
||||||
self.get(cache, page.parse::<u8>().unwrap_or(1), options)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
match videos {
|
|
||||||
Ok(v) => v,
|
result.unwrap_or_else(|e| {
|
||||||
Err(e) => {
|
eprintln!("beeg provider error: {}", e);
|
||||||
println!("Error fetching videos: {}", e);
|
vec![]
|
||||||
vec![]
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn get_channel(&self, clientversion: ClientVersion) -> crate::status::Channel {
|
|
||||||
|
fn get_channel(&self, clientversion: ClientVersion) -> Channel {
|
||||||
self.build_channel(clientversion)
|
self.build_channel(clientversion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,20 +13,20 @@ pub struct FlareSolverrRequest {
|
|||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
||||||
pub struct FlaresolverrCookie {
|
pub struct FlaresolverrCookie {
|
||||||
pub name: String, //"cf_clearance",
|
pub name: String,
|
||||||
pub value: String, //"lnKoXclrIp_mDrWJFfktPGm8GDyxjSpzy9dx0qDTiRg-1748689259-1.2.1.1-AIFERAPCdCSvvdu1mposNdUpKV9wHZXBpSI2L9k9TaKkPcqmomON_XEb6ZtRBtrmQu_DC8AzKllRg2vNzVKOUsvv9ndjQ.vv8Z7cNkgzpIbGFy96kXyAYH2mUk3Q7enZovDlEbK5kpV3Sbmd2M3_bUCBE1WjAMMdXlyNElH1LOpUm149O9hrluXjAffo4SwHI4HO0UckBPWBlBqhznKPgXxU0g8VHLDeYnQKViY8rP2ud4tyzKnJUxuYXzr4aWBNMp6TESp49vesRiel_Y5m.rlTY4zSb517S9iPbEQiYHRI.uH5mMHVI3jvJl0Mx94tPrpFnkhDdmzL3DRSllJe9k786Lf21I9WBoH2cCR3yHw",
|
pub value: String,
|
||||||
pub domain: String, //".discord.com",
|
pub domain: String,
|
||||||
pub path: String, //"/",
|
pub path: String,
|
||||||
pub expires: f64, //1780225259.237105,
|
pub expires: f64,
|
||||||
pub size: u64, //438,
|
pub size: u64,
|
||||||
pub httpOnly: bool, //true,
|
pub httpOnly: bool,
|
||||||
pub secure: bool, //true,
|
pub secure: bool,
|
||||||
pub session: bool, //false,
|
pub session: bool,
|
||||||
pub sameSite: Option<String>, //"None",
|
pub sameSite: Option<String>,
|
||||||
pub priority: String, //"Medium",
|
pub priority: String,
|
||||||
pub sameParty: bool, //false,
|
pub sameParty: bool,
|
||||||
pub sourceScheme: String, //"Secure",
|
pub sourceScheme: String,
|
||||||
pub sourcePort: u32, //443,
|
pub sourcePort: u32,
|
||||||
pub partitionKey: Option<String>,
|
pub partitionKey: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,39 +39,26 @@ pub struct FlareSolverrSolution {
|
|||||||
pub cookies: Vec<FlaresolverrCookie>,
|
pub cookies: Vec<FlaresolverrCookie>,
|
||||||
pub userAgent: String,
|
pub userAgent: String,
|
||||||
}
|
}
|
||||||
// impl FlareSolverrSolution {
|
|
||||||
// fn to_client(&self,){
|
|
||||||
// let mut headers = header::HeaderMap::new();
|
|
||||||
// for (h, v) in &self.headers {
|
|
||||||
// println!("{}: {}", h, v);
|
|
||||||
// headers.insert(
|
|
||||||
// header::HeaderName::from_bytes(h.as_bytes()).unwrap(),
|
|
||||||
// header::HeaderValue::from_str(v).unwrap(),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// // let client = reqwest::Client::builder()
|
|
||||||
// // .danger_accept_invalid_certs(true)
|
|
||||||
// // .
|
|
||||||
// // .build().unwrap();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
||||||
pub struct FlareSolverrResponse {
|
pub struct FlareSolverrResponse {
|
||||||
status: String,
|
pub status: String,
|
||||||
message: String,
|
pub message: String,
|
||||||
pub solution: FlareSolverrSolution,
|
pub solution: FlareSolverrSolution,
|
||||||
startTimestamp: u64,
|
pub startTimestamp: u64,
|
||||||
endTimestamp: u64,
|
pub endTimestamp: u64,
|
||||||
version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Flaresolverr {
|
pub struct Flaresolverr {
|
||||||
url: String,
|
url: String,
|
||||||
proxy: bool,
|
proxy: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Flaresolverr {
|
impl Flaresolverr {
|
||||||
pub fn new(url: String) -> Self {
|
pub fn new(url: String) -> Self {
|
||||||
Flaresolverr {
|
Self {
|
||||||
url: url,
|
url,
|
||||||
proxy: false,
|
proxy: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,28 +72,34 @@ impl Flaresolverr {
|
|||||||
request: FlareSolverrRequest,
|
request: FlareSolverrRequest,
|
||||||
) -> Result<FlareSolverrResponse, Box<dyn std::error::Error>> {
|
) -> Result<FlareSolverrResponse, Box<dyn std::error::Error>> {
|
||||||
let client = Client::builder()
|
let client = Client::builder()
|
||||||
.emulation(Emulation::Firefox136)
|
.emulation(Emulation::Firefox136)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let mut request = client
|
let mut req = client
|
||||||
.post(&self.url)
|
.post(&self.url)
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.json(&json!({
|
.json(&json!({
|
||||||
"cmd": request.cmd,
|
"cmd": request.cmd,
|
||||||
"url": request.url,
|
"url": request.url,
|
||||||
"maxTimeout": request.maxTimeout,
|
"maxTimeout": request.maxTimeout,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if self.proxy {
|
if self.proxy {
|
||||||
if let Ok(proxy_url) = env::var("BURP_URL") {
|
if let Ok(proxy_url) = env::var("BURP_URL") {
|
||||||
let proxy = Proxy::all(&proxy_url).unwrap();
|
match Proxy::all(&proxy_url) {
|
||||||
request = request.proxy(proxy.clone());
|
Ok(proxy) => {
|
||||||
|
req = req.proxy(proxy);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Invalid proxy URL '{}': {}", proxy_url, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = request.send().await?;
|
let response = req.send().await?;
|
||||||
|
|
||||||
let body: FlareSolverrResponse = response.json::<FlareSolverrResponse>().await?;
|
let body = response.json::<FlareSolverrResponse>().await?;
|
||||||
Ok(body)
|
Ok(body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user