now with pornstars fetch

This commit is contained in:
Simon
2025-10-04 18:12:23 +00:00
parent 499e528697
commit b2a07b0392
3 changed files with 58 additions and 19 deletions

View File

@@ -1215,6 +1215,11 @@ async fn videos_post(
.as_deref() .as_deref()
.unwrap_or("") .unwrap_or("")
.to_string(); .to_string();
let stars = video_request
.stars
.as_deref()
.unwrap_or("")
.to_string();
let options = ServerOptions { let options = ServerOptions {
featured: Some(featured), featured: Some(featured),
category: Some(category), category: Some(category),
@@ -1223,6 +1228,7 @@ async fn videos_post(
language: Some(language), language: Some(language),
requester: Some(requester), requester: Some(requester),
network: Some(network), network: Some(network),
stars: Some(stars),
}; };
let video_items = provider let video_items = provider
.get_videos( .get_videos(

View File

@@ -54,6 +54,7 @@ impl OmgxxxProvider {
let url = self.url.clone(); let url = self.url.clone();
let sites = Arc::clone(&self.sites); let sites = Arc::clone(&self.sites);
let networks = Arc::clone(&self.networks); let networks = Arc::clone(&self.networks);
let stars = Arc::clone(&self.stars);
thread::spawn(move || { thread::spawn(move || {
// Create a tiny runtime just for these async tasks // Create a tiny runtime just for these async tasks
@@ -71,41 +72,45 @@ impl OmgxxxProvider {
if let Err(e) = Self::load_networks(&url, networks).await { if let Err(e) = Self::load_networks(&url, networks).await {
eprintln!("load_networks failed: {e}"); eprintln!("load_networks failed: {e}");
} }
if let Err(e) = Self::load_stars(&url, stars).await {
eprintln!("load_stars failed: {e}");
}
}); });
}); });
} }
async fn load_stars(base_url: &str, networks: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> { async fn load_stars(base_url: &str, stars: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
let mut requester = util::requester::Requester::new(); let mut requester = util::requester::Requester::new();
let mut page = 0; let mut page = 0;
loop { loop {
page += 1; page += 1;
let text = requester let text = requester
.get(format!("{}/sites/{}/", &base_url, page).as_str()) .get(format!("{}/models/{}/?gender_id=0", &base_url, page).as_str())
.await .await
.unwrap(); .unwrap();
if text.contains("404 Not Found") || text.is_empty() { if text.contains("404 Not Found") || text.is_empty() {
break; break;
} }
let sites_div = text let stars_div = text
.split("id=\"list_content_sources_sponsors_list_items\"").collect::<Vec<&str>>()[1] .split("id=\"list_models_models_list_items\"").collect::<Vec<&str>>()[1]
.split("class=\"pagination\"").collect::<Vec<&str>>()[0]; .split("class=\"pagination\"").collect::<Vec<&str>>()[0];
for sites_element in for stars_element in
sites_div.split("class=\"headline\"").collect::<Vec<&str>>()[1..].to_vec() stars_div.split("<a ").collect::<Vec<&str>>()[1..].to_vec()
{ {
let site_url = sites_element.split("href=\"").collect::<Vec<&str>>()[1] let star_url = stars_element.split("href=\"").collect::<Vec<&str>>()[1]
.split("\"") .split("\"")
.collect::<Vec<&str>>()[0]; .collect::<Vec<&str>>()[0];
let site_id = site_url.split("/").collect::<Vec<&str>>()[4].to_string(); let star_id = star_url.split("/").collect::<Vec<&str>>()[4].to_string();
let site_name = sites_element.split("<h2>").collect::<Vec<&str>>()[1] let star_name = stars_element.split("title=\"").collect::<Vec<&str>>()[1]
.split("<") .split("\"")
.collect::<Vec<&str>>()[0] .collect::<Vec<&str>>()[0]
.to_string(); .to_string();
Self::push_unique( Self::push_unique(
&networks, &stars,
FilterOption { FilterOption {
id: site_id, id: star_id,
title: site_name, title: star_name,
}, },
); );
} }
@@ -113,7 +118,7 @@ impl OmgxxxProvider {
return Ok(()); return Ok(());
} }
async fn load_sites(base_url: &str, networks: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> { async fn load_sites(base_url: &str, sites: Arc<RwLock<Vec<FilterOption>>>) -> Result<()> {
let mut requester = util::requester::Requester::new(); let mut requester = util::requester::Requester::new();
let mut page = 0; let mut page = 0;
loop { loop {
@@ -140,7 +145,7 @@ impl OmgxxxProvider {
.collect::<Vec<&str>>()[0] .collect::<Vec<&str>>()[0]
.to_string(); .to_string();
Self::push_unique( Self::push_unique(
&networks, &sites,
FilterOption { FilterOption {
id: site_id, id: site_id,
title: site_name, title: site_name,
@@ -207,6 +212,12 @@ impl OmgxxxProvider {
.map(|g| g.clone()) // or: .map(|g| g.to_vec()) .map(|g| g.clone()) // or: .map(|g| g.to_vec())
.unwrap_or_default(); // or: .unwrap_or_else(|_| Vec::new()) .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: "omgxxx".to_string(), id: "omgxxx".to_string(),
name: "OMG XXX".to_string(), name: "OMG XXX".to_string(),
@@ -241,7 +252,7 @@ impl OmgxxxProvider {
ChannelOption { ChannelOption {
id: "sites".to_string(), id: "sites".to_string(),
title: "Sites".to_string(), title: "Sites".to_string(),
description: "Sort the Videos".to_string(), description: "Filter for different Sites".to_string(),
systemImage: "list.bullet.indent".to_string(), systemImage: "list.bullet.indent".to_string(),
colorName: "green".to_string(), colorName: "green".to_string(),
options: sites, options: sites,
@@ -250,12 +261,21 @@ impl OmgxxxProvider {
ChannelOption { ChannelOption {
id: "networks".to_string(), id: "networks".to_string(),
title: "Networks".to_string(), title: "Networks".to_string(),
description: "Sort the Videos".to_string(), description: "Filter for different Networks".to_string(),
systemImage: "list.dash".to_string(), systemImage: "list.dash".to_string(),
colorName: "purple".to_string(), colorName: "purple".to_string(),
options: networks, options: networks,
multiSelect: false, multiSelect: false,
}, },
ChannelOption {
id: "stars".to_string(),
title: "Stars".to_string(),
description: "Filter for different Pornstars".to_string(),
systemImage: "star".to_string(),
colorName: "gold".to_string(),
options: stars,
multiSelect: false,
},
], ],
nsfw: true, nsfw: true,
cacheDuration: None, cacheDuration: None,
@@ -274,17 +294,28 @@ impl OmgxxxProvider {
"most-popular" => "most-popular".to_string(), "most-popular" => "most-popular".to_string(),
_ => "latest-updates".to_string(), _ => "latest-updates".to_string(),
}; };
let alt_sort_string: String = match sort {
"top-rated" => "/top-rated".to_string(),
"most-popular" => "/most-popular".to_string(),
_ => "".to_string(),
};
if options.network.is_some() if options.network.is_some()
&& !options.network.as_ref().unwrap().is_empty() && !options.network.as_ref().unwrap().is_empty()
&& options.network.as_ref().unwrap() != "all" && options.network.as_ref().unwrap() != "all"
{ {
sort_string = format!("networks/{}", options.network.as_ref().unwrap()); sort_string = format!("networks/{}{}", options.network.as_ref().unwrap(), alt_sort_string);
} }
if options.sites.is_some() if options.sites.is_some()
&& !options.sites.as_ref().unwrap().is_empty() && !options.sites.as_ref().unwrap().is_empty()
&& options.sites.as_ref().unwrap() != "all" && options.sites.as_ref().unwrap() != "all"
{ {
sort_string = format!("sites/{}", options.sites.as_ref().unwrap()); sort_string = format!("sites/{}{}", options.sites.as_ref().unwrap(), alt_sort_string);
}
if options.stars.is_some()
&& !options.sites.as_ref().unwrap().is_empty()
&& options.sites.as_ref().unwrap() != "all"
{
sort_string = format!("sites/{}{}", options.sites.as_ref().unwrap(), alt_sort_string);
} }
let video_url = format!("{}/{}/{}/", self.url, sort_string, page); let video_url = format!("{}/{}/{}/", self.url, sort_string, page);
let old_items = match cache.get(&video_url) { let old_items = match cache.get(&video_url) {

View File

@@ -31,6 +31,7 @@ pub struct VideosRequest {
pub filter: Option<String>, // pub filter: Option<String>, //
pub language: Option<String>, // pub language: Option<String>, //
pub networks: Option<String>, // pub networks: Option<String>, //
pub stars: Option<String>, //
} }
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
@@ -42,6 +43,7 @@ pub struct ServerOptions {
pub language: Option<String>, // "en" pub language: Option<String>, // "en"
pub requester: Option<Requester>, pub requester: Option<Requester>,
pub network: Option<String>, // pub network: Option<String>, //
pub stars: Option<String>, //
} }
#[derive(serde::Serialize, Debug)] #[derive(serde::Serialize, Debug)]