use maud::html; use rocket::{get, State}; use serde_json::json; use crate::library::Library; use super::vec_to_api; #[get("/search?&")] pub async fn search( query: &str, offset: Option, library: &State, ) -> Option { const NUM_OF_RESULTS: i64 = 20; // get start parameter for search result chunks let start = offset.unwrap_or(0); let mut video_matches = library.search_video(query, start, NUM_OF_RESULTS).await; Some(json!(vec_to_api(&mut video_matches).await)) } #[get("/d/")] pub async fn channel_page(dir: &str, library: &State) -> Option { let mut dir_videos = library.get_directory_videos(dir).await; Some(json!(vec_to_api(&mut dir_videos).await)) } #[get("/")] pub async fn index_page(library: &State) -> String { unimplemented!() }