updated api for automatically all sites

This commit is contained in:
Simon
2025-08-14 18:54:05 +00:00
parent e67025e104
commit 58871d8db9
3 changed files with 21 additions and 27 deletions

View File

@@ -2,7 +2,9 @@ use ntex::http::header;
use ntex::web;
use ntex::web::HttpRequest;
use std::cmp::Ordering;
use std::fs;
use tokio::task;
use capitalize::Capitalize;
use crate::providers::all::AllProvider;
use crate::providers::hanime::HanimeProvider;
@@ -15,6 +17,7 @@ use crate::providers::rule34video::Rule34videoProvider;
use crate::providers::spankbang::SpankbangProvider;
use crate::util::cache::VideoCache;
use crate::{DbPool, providers::*, status::*, videos::*};
use cute::c;
#[derive(Debug)]
struct ClientVersion {
@@ -436,6 +439,17 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
nsfw: true,
});
let files = fs::read_dir("./src/providers").unwrap();
let providers = files.map(|entry| entry.unwrap().file_name())
.filter(|name| name.to_str().unwrap().ends_with(".rs"))
.filter(|name| !name.to_str().unwrap().contains("mod.rs") && !name.to_str().unwrap().contains("all.rs"))
.map(|name| name.to_str().unwrap().replace(".rs", ""))
.collect::<Vec<String>>();
let sites = c![FilterOption {
id: x.to_string(),
title: x.capitalize().to_string(),
}, for x in providers.iter()];
// All
status.add_channel(Channel {
id: "all".to_string(),
@@ -451,32 +465,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
description: "What Sites to use".to_string(), //"Sort the videos by Date or Name.".to_string(),
systemImage: "list.number".to_string(),
colorName: "green".to_string(),
options: vec![
FilterOption {
id: "hanime".to_string(),
title: "Hanime".to_string(),
},
FilterOption {
id: "perverzija".to_string(),
title: "Perverzija".to_string(),
},
FilterOption {
id: "pmvhaven".to_string(),
title: "PMVHaven".to_string(),
},
FilterOption {
id: "pornhub".to_string(),
title: "Pornhub".to_string(),
},
FilterOption {
id: "redtube".to_string(),
title: "Redtube".to_string(),
},
FilterOption {
id: "rule34video".to_string(),
title: "Rule34Video".to_string(),
},
],
options: sites,
multiSelect: true,
}],
nsfw: true,