updated api for automatically all sites
This commit is contained in:
@@ -19,3 +19,4 @@ tokio = { version = "1", features = ["full"] }
|
|||||||
wreq = { version = "5", features = ["full"] }
|
wreq = { version = "5", features = ["full"] }
|
||||||
wreq-util = "2"
|
wreq-util = "2"
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1"
|
||||||
|
capitalize = "0.3.4"
|
||||||
|
|||||||
41
src/api.rs
41
src/api.rs
@@ -2,7 +2,9 @@ use ntex::http::header;
|
|||||||
use ntex::web;
|
use ntex::web;
|
||||||
use ntex::web::HttpRequest;
|
use ntex::web::HttpRequest;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
use std::fs;
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
|
use capitalize::Capitalize;
|
||||||
|
|
||||||
use crate::providers::all::AllProvider;
|
use crate::providers::all::AllProvider;
|
||||||
use crate::providers::hanime::HanimeProvider;
|
use crate::providers::hanime::HanimeProvider;
|
||||||
@@ -15,6 +17,7 @@ use crate::providers::rule34video::Rule34videoProvider;
|
|||||||
use crate::providers::spankbang::SpankbangProvider;
|
use crate::providers::spankbang::SpankbangProvider;
|
||||||
use crate::util::cache::VideoCache;
|
use crate::util::cache::VideoCache;
|
||||||
use crate::{DbPool, providers::*, status::*, videos::*};
|
use crate::{DbPool, providers::*, status::*, videos::*};
|
||||||
|
use cute::c;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct ClientVersion {
|
struct ClientVersion {
|
||||||
@@ -436,6 +439,17 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
|||||||
nsfw: true,
|
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
|
// All
|
||||||
status.add_channel(Channel {
|
status.add_channel(Channel {
|
||||||
id: "all".to_string(),
|
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(),
|
description: "What Sites to use".to_string(), //"Sort the videos by Date or Name.".to_string(),
|
||||||
systemImage: "list.number".to_string(),
|
systemImage: "list.number".to_string(),
|
||||||
colorName: "green".to_string(),
|
colorName: "green".to_string(),
|
||||||
options: vec![
|
options: sites,
|
||||||
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(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
multiSelect: true,
|
multiSelect: true,
|
||||||
}],
|
}],
|
||||||
nsfw: true,
|
nsfw: true,
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ use dotenvy::dotenv;
|
|||||||
use ntex_files as fs;
|
use ntex_files as fs;
|
||||||
use ntex::web;
|
use ntex::web;
|
||||||
|
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate cute;
|
||||||
|
|
||||||
mod api;
|
mod api;
|
||||||
mod db;
|
mod db;
|
||||||
mod models;
|
mod models;
|
||||||
|
|||||||
Reference in New Issue
Block a user