provider refactors and fixes

This commit is contained in:
Simon
2026-03-05 13:28:38 +00:00
parent 060d8e7937
commit 8157e223fe
33 changed files with 3051 additions and 1694 deletions

View File

@@ -61,10 +61,15 @@ impl PimpbunnyProvider {
categories: self
.categories
.read()
.unwrap()
.iter()
.map(|c| c.title.clone())
.collect(),
.map(|categories| categories.iter().map(|c| c.title.clone()).collect())
.unwrap_or_else(|e| {
crate::providers::report_provider_error_background(
"pimpbunny",
"build_channel.categories_read",
&e.to_string(),
);
vec![]
}),
options: vec![ChannelOption {
id: "sort".to_string(),
title: "Sort".to_string(),
@@ -267,8 +272,20 @@ impl PimpbunnyProvider {
vec![]
}
};
let mut requester = options.requester.clone().unwrap();
let text = requester.get(&video_url, Some(Version::HTTP_11)).await.unwrap();
let mut requester =
crate::providers::requester_or_default(&options, module_path!(), "missing_requester");
let text = match requester.get(&video_url, Some(Version::HTTP_11)).await {
Ok(text) => text,
Err(e) => {
crate::providers::report_provider_error(
"pimpbunny",
"get.request",
&format!("url={video_url}; error={e}"),
)
.await;
return Ok(old_items);
}
};
let video_items: Vec<VideoItem> = self
.get_video_items_from_html(text.clone(), &mut requester)
.await;
@@ -300,28 +317,38 @@ impl PimpbunnyProvider {
"most viewed" => "&sort_by=video_viewed",
_ => "&sort_by=post_date",
};
if let Some(star) = self
.stars
.read()
.unwrap()
.iter()
.find(|s| s.title.to_ascii_lowercase() == search_string.to_ascii_lowercase())
{
video_url = format!(
"{}/onlyfans-models/{}/{}/?videos_per_page=20{}",
self.url, star.id, page, sort_string
if let Ok(stars) = self.stars.read() {
if let Some(star) = stars
.iter()
.find(|s| s.title.to_ascii_lowercase() == search_string.to_ascii_lowercase())
{
video_url = format!(
"{}/onlyfans-models/{}/{}/?videos_per_page=20{}",
self.url, star.id, page, sort_string
);
}
} else {
crate::providers::report_provider_error_background(
"pimpbunny",
"query.stars_read",
"failed to lock stars",
);
}
if let Some(cat) = self
.categories
.read()
.unwrap()
.iter()
.find(|c| c.title.to_ascii_lowercase() == search_string.to_ascii_lowercase())
{
video_url = format!(
"{}/categories/{}/{}/?videos_per_page=20{}",
self.url, cat.id, page, sort_string
if let Ok(categories) = self.categories.read() {
if let Some(cat) = categories
.iter()
.find(|c| c.title.to_ascii_lowercase() == search_string.to_ascii_lowercase())
{
video_url = format!(
"{}/categories/{}/{}/?videos_per_page=20{}",
self.url, cat.id, page, sort_string
);
}
} else {
crate::providers::report_provider_error_background(
"pimpbunny",
"query.categories_read",
"failed to lock categories",
);
}
// Check our Video Cache. If the result is younger than 1 hour, we return it.
@@ -339,9 +366,21 @@ impl PimpbunnyProvider {
}
};
let mut requester = options.requester.clone().unwrap();
let mut requester =
crate::providers::requester_or_default(&options, module_path!(), "missing_requester");
println!("Fetching URL: {}", video_url);
let text = requester.get(&video_url, Some(Version::HTTP_2)).await.unwrap();
let text = match requester.get(&video_url, Some(Version::HTTP_2)).await {
Ok(text) => text,
Err(e) => {
crate::providers::report_provider_error(
"pimpbunny",
"query.request",
&format!("url={video_url}; error={e}"),
)
.await;
return Ok(old_items);
}
};
let video_items: Vec<VideoItem> = self
.get_video_items_from_html(text.clone(), &mut requester)
.await;