database support

This commit is contained in:
Simon
2025-06-05 18:50:28 +00:00
parent 6d08362937
commit 175c9b748f
15 changed files with 333 additions and 140 deletions

View File

@@ -6,7 +6,7 @@ use ntex::web::HttpRequest;
use crate::providers::hanime::HanimeProvider;
use crate::providers::perverzija::PerverzijaProvider;
use crate::util::cache::VideoCache;
use crate::{providers::*, status::*, videos::*};
use crate::{providers::*, status::*, videos::*, DbPool};
pub fn config(cfg: &mut web::ServiceConfig) {
cfg.service(
@@ -195,7 +195,8 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
async fn videos_post(
video_request: web::types::Json<Videos_Request>,
cache: web::types::State<VideoCache>
cache: web::types::State<VideoCache>,
pool: web::types::State<DbPool>,
) -> Result<impl web::Responder, web::Error> {
let mut videos = Videos {
pageInfo: PageInfo {
@@ -232,7 +233,7 @@ async fn videos_post(
let provider = get_provider(channel.as_str())
.ok_or_else(|| web::error::ErrorBadRequest("Invalid channel".to_string()))?;
let video_items = provider
.get_videos(cache.get_ref().clone(), channel, sort, query, page.to_string(), perPage.to_string(), featured)
.get_videos(cache.get_ref().clone(), pool.get_ref().clone(), channel, sort, query, page.to_string(), perPage.to_string(), featured)
.await;
videos.items = video_items.clone();
Ok(web::HttpResponse::Ok().json(&videos))