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

View File

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