various bugfixes

This commit is contained in:
Simon
2026-01-13 18:13:51 +00:00
parent aaff7d00c6
commit 34992242b7
21 changed files with 243 additions and 289 deletions

View File

@@ -3,7 +3,7 @@ use ntex::http::header;
use ntex::web;
use ntex::web::HttpRequest;
use std::cmp::Ordering;
use std::fs;
use std::{fs, io};
use tokio::task;
use crate::providers::all::AllProvider;
@@ -15,6 +15,7 @@ use crate::providers::redtube::RedtubeProvider;
use crate::providers::rule34video::Rule34videoProvider;
// use crate::providers::spankbang::SpankbangProvider;
use crate::util::cache::VideoCache;
use crate::util::discord::send_discord_error_report;
use crate::util::requester::Requester;
use crate::{DbPool, db, status::*, videos::*};
use cute::c;
@@ -104,7 +105,12 @@ pub fn config(cfg: &mut web::ServiceConfig) {
web::resource("/videos")
// .route(web::get().to(videos_get))
.route(web::post().to(videos_post)),
);
)
.service(
web::resource("/test")
.route(web::get().to(test))
)
;
}
async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
@@ -345,40 +351,6 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
cacheDuration: None,
});
// status.add_channel(Channel {
// id: "spankbang".to_string(),
// name: "SpankBang".to_string(),
// description: "Popular Porn Videos - SpankBang".to_string(),
// premium: false,
// favicon: "https://www.google.com/s2/favicons?sz=64&domain=spankbang.com".to_string(),
// status: "active".to_string(),
// categories: vec![],
// options: vec![ChannelOption {
// id: "sort".to_string(),
// title: "Sort".to_string(),
// description: "Sort the Videos".to_string(), //"Sort the videos by Date or Name.".to_string(),
// systemImage: "list.number".to_string(),
// colorName: "blue".to_string(),
// options: vec![
// FilterOption {
// id: "trending_videos".to_string(),
// title: "Trending".to_string(),
// },
// FilterOption {
// id: "new_videos".to_string(),
// title: "New".to_string(),
// },
// FilterOption {
// id: "most_popular".to_string(),
// title: "Popular".to_string(),
// },
// ],
// multiSelect: false,
// }],
// nsfw: true,
//cacheDuration: Some(1800),
// });
// rule34video
status.add_channel(Channel {
id: "rule34video".to_string(),
@@ -647,41 +619,6 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
cacheDuration: Some(1800),
});
// // hentaimoon
// status.add_channel(Channel {
// id: "hentaimoon".to_string(),
// name: "Hentai Moon".to_string(),
// description: "Your Hentai Sputnik".to_string(),
// premium: false,
// favicon: "https://www.google.com/s2/favicons?sz=64&domain=hentai-moon.com".to_string(),
// status: "active".to_string(),
// categories: vec![],
// options: vec![ChannelOption {
// id: "sort".to_string(),
// title: "Sort".to_string(),
// description: "Sort the Videos".to_string(), //"Sort the videos by Date or Name.".to_string(),
// systemImage: "list.number".to_string(),
// colorName: "blue".to_string(),
// options: vec![
// FilterOption {
// id: "new".to_string(),
// title: "New".to_string(),
// },
// FilterOption {
// id: "popular".to_string(),
// title: "Popular".to_string(),
// },
// FilterOption {
// id: "top-rated".to_string(),
// title: "Top Rated".to_string(),
// },
// ],
// multiSelect: false,
// }],
// nsfw: true,
// cacheDuration: Some(1800),
// });
// xxthots
status.add_channel(Channel {
id: "xxthots".to_string(),
@@ -852,20 +789,6 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
cacheDuration: None,
});
// noodlemagazine
// status.add_channel(Channel {
// id: "noodlemagazine".to_string(),
// name: "Noodlemagazine".to_string(),
// description: "Discover the Best Adult Videos".to_string(),
// premium: false,
// favicon: "https://www.google.com/s2/favicons?sz=64&domain=noodlemagazine.com".to_string(),
// status: "active".to_string(),
// categories: vec![],
// options: vec![],
// nsfw: true,
// cacheDuration: Some(1800),
// });
//missav
status.add_channel(Channel {
id: "missav".to_string(),
@@ -1065,7 +988,9 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
}
for provider in ALL_PROVIDERS.values() {
status.add_channel(provider.get_channel(clientversion.clone()));
if let Some(channel) = provider.get_channel(clientversion.clone()){
status.add_channel(channel);
}
}
status.iconUrl = format!("http://{}/favicon.ico", host).to_string();
Ok(web::HttpResponse::Ok().json(&status))
@@ -1261,3 +1186,19 @@ pub fn get_provider(channel: &str) -> Option<DynProvider> {
x => ALL_PROVIDERS.get(x).cloned(),
}
}
pub async fn test() -> Result<impl web::Responder, web::Error> {
// Simply await the function instead of blocking the thread
let e = io::Error::new(io::ErrorKind::Other, "test error");
let _ = send_discord_error_report(
e.to_string(),
Some("chain_str".to_string()),
Some("Context"),
Some("xtra info"),
file!(),
line!(),
module_path!(),
).await;
Ok(web::HttpResponse::Ok())
}