format fixes

This commit is contained in:
Simon
2026-03-10 07:53:07 +00:00
parent 4c1815e0fc
commit 716b775105
2 changed files with 61 additions and 44 deletions

View File

@@ -62,31 +62,28 @@ impl XfreeProvider {
);
vec![]
}),
options: vec![
ChannelOption {
id: "sexuality".to_string(),
title: "Sexuality".to_string(),
description: "Sexuality of the Videos".to_string(),
systemImage: "heart".to_string(),
colorName: "red".to_string(),
multiSelect: false,
options: vec![
FilterOption {
id: "1".to_string(),
title: "Straight".to_string(),
},
FilterOption {
id: "2".to_string(),
title: "Gay".to_string(),
},
FilterOption {
id: "3".to_string(),
title: "Trans".to_string(),
},
],
},
],
options: vec![ChannelOption {
id: "sexuality".to_string(),
title: "Sexuality".to_string(),
description: "Sexuality of the Videos".to_string(),
systemImage: "heart".to_string(),
colorName: "red".to_string(),
multiSelect: false,
options: vec![
FilterOption {
id: "1".to_string(),
title: "Straight".to_string(),
},
FilterOption {
id: "2".to_string(),
title: "Gay".to_string(),
},
FilterOption {
id: "3".to_string(),
title: "Trans".to_string(),
},
],
}],
nsfw: true,
cacheDuration: None,
}
@@ -138,13 +135,21 @@ impl XfreeProvider {
let mut requester =
crate::providers::requester_or_default(&options, module_path!(), "missing_requester");
// let _ = requester.get("https://www.xfree.com/", Some(Version::HTTP_2)).await;
let text = match requester.get_with_headers(&video_url, vec![
("Apiversion".to_string(), "1.0".to_string()),
("Accept".to_string(), "application/json text/plain */*".to_string()),
("Referer".to_string(), "https://www.xfree.com/".to_string()),
],
Some(Version::HTTP_2),
).await {
let text = match requester
.get_with_headers(
&video_url,
vec![
("Apiversion".to_string(), "1.0".to_string()),
(
"Accept".to_string(),
"application/json text/plain */*".to_string(),
),
("Referer".to_string(), "https://www.xfree.com/".to_string()),
],
Some(Version::HTTP_2),
)
.await
{
Ok(text) => text,
Err(e) => {
crate::providers::report_provider_error(
@@ -190,7 +195,9 @@ impl XfreeProvider {
}
};
for post in json.get("body").and_then(|v| v.get("posts"))
for post in json
.get("body")
.and_then(|v| v.get("posts"))
.and_then(|p| p.as_array())
.unwrap_or(&vec![])
{
@@ -239,14 +246,16 @@ impl XfreeProvider {
.and_then(|v| v.as_array())
.unwrap_or(&vec![])
.iter()
.filter_map(|t|
t.get("tag").and_then(|n| n.as_str()).map(|s| s.to_string()))
.filter_map(|t| t.get("tag").and_then(|n| n.as_str()).map(|s| s.to_string()))
.collect::<Vec<String>>();
for tag in tags.iter() {
Self::push_unique(&self.categories, FilterOption {
id: tag.clone(),
title: tag.clone(),
});
Self::push_unique(
&self.categories,
FilterOption {
id: tag.clone(),
title: tag.clone(),
},
);
}
let uploader = post
.get("user")
@@ -269,8 +278,7 @@ impl XfreeProvider {
.unwrap_or_default()
.to_string()
.parse::<f32>()
.unwrap_or(0.5625)
;
.unwrap_or(0.5625);
let video_item = VideoItem::new(
id.to_string(),
title,
@@ -305,7 +313,16 @@ impl Provider for XfreeProvider {
) -> Vec<VideoItem> {
let page = page.parse::<u8>().unwrap_or(1);
let res = self.to_owned().query(cache, page, &query.unwrap_or("null".to_string()), options, pool).await;
let res = self
.to_owned()
.query(
cache,
page,
&query.unwrap_or("null".to_string()),
options,
pool,
)
.await;
res.unwrap_or_else(|e| {
eprintln!("xfree error: {e}");

View File

@@ -50,7 +50,7 @@ pub struct VideosRequest {
pub networks: Option<String>, //
pub stars: Option<String>, //
pub categories: Option<String>,
pub duration: Option<String>
pub duration: Option<String>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
@@ -66,7 +66,7 @@ pub struct ServerOptions {
pub categories: Option<String>, //
pub duration: Option<String>, //
pub sort: Option<String>, //
pub sexuality: Option<String>, //
pub sexuality: Option<String>, //
}
#[derive(serde::Serialize, Debug)]