This commit is contained in:
parent
2ac2559c23
commit
59dae90b4d
13 changed files with 368 additions and 138 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue