update
This commit is contained in:
parent
a5d3c14f0c
commit
11a862f6c7
6 changed files with 158 additions and 1 deletions
|
@ -1,10 +1,13 @@
|
|||
use super::api_error;
|
||||
use super::FallibleApiResponse;
|
||||
use super::ToAPI;
|
||||
use crate::library::user::User;
|
||||
use fs::NamedFile;
|
||||
use mongodb::bson::doc;
|
||||
use rocket::{fs, get, State};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::check_admin;
|
||||
use crate::library::Libary;
|
||||
|
||||
#[get("/track/<track_id>")]
|
||||
|
@ -17,6 +20,19 @@ pub async fn track_route(track_id: &str, lib: &State<Libary>) -> FallibleApiResp
|
|||
.await)
|
||||
}
|
||||
|
||||
#[get("/track/<track_id>/reload")]
|
||||
pub async fn track_reload_meta_route(
|
||||
track_id: &str,
|
||||
lib: &State<Libary>,
|
||||
u: User,
|
||||
) -> FallibleApiResponse {
|
||||
check_admin!(u);
|
||||
lib.reload_metadata(track_id)
|
||||
.await
|
||||
.map_err(|_| api_error("Error reloading metadata"))?;
|
||||
Ok(json!({"ok": 1}))
|
||||
}
|
||||
|
||||
#[get("/track/<track_id>/audio")]
|
||||
pub async fn track_audio_route(track_id: &str, lib: &State<Libary>) -> Option<NamedFile> {
|
||||
let track = lib.get_track_by_id(track_id).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue