database support
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user