♻️ refactor
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
JMARyA 2025-02-09 07:09:20 +01:00
parent 2ac2559c23
commit 59dae90b4d
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
13 changed files with 368 additions and 138 deletions

View file

@ -1,12 +1,21 @@
use based::request::assets::DataResponse;
use based::{auth::MaybeUser, request::assets::DataResponse};
use rocket::{get, State};
use tokio::{fs::File, io::AsyncReadExt};
use crate::library::Library;
use crate::{config::Config, library::Library};
#[get("/video/raw?<v>")]
pub async fn video_file(v: &str, library: &State<Library>) -> Option<DataResponse> {
pub async fn video_file(
v: &str,
library: &State<Library>,
conf: &State<Config>,
user: MaybeUser,
) -> Option<DataResponse> {
if conf.general.private && user.user().is_none() {
return None;
}
let video = if let Some(video) = library.get_video_by_id(v).await {
video
} else {
@ -33,7 +42,16 @@ pub async fn video_file(v: &str, library: &State<Library>) -> Option<DataRespons
}
#[get("/video/thumbnail?<v>")]
pub async fn video_thumbnail(v: &str, library: &State<Library>) -> Option<DataResponse> {
pub async fn video_thumbnail(
v: &str,
library: &State<Library>,
conf: &State<Config>,
user: MaybeUser,
) -> Option<DataResponse> {
if conf.general.private && user.user().is_none() {
return None;
}
let video = if let Some(video) = library.get_video_by_id(v).await {
video
} else {