updated api for automatically all sites
This commit is contained in:
41
src/api.rs
41
src/api.rs
@@ -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,
|
||||
|
||||
@@ -7,6 +7,10 @@ use dotenvy::dotenv;
|
||||
use ntex_files as fs;
|
||||
use ntex::web;
|
||||
|
||||
|
||||
#[macro_use]
|
||||
extern crate cute;
|
||||
|
||||
mod api;
|
||||
mod db;
|
||||
mod models;
|
||||
|
||||
Reference in New Issue
Block a user