use maud::html; use rocket::{ get, http::{ContentType, Status}, State, }; use serde_json::json; use crate::{ library::{self, Library}, pages::components::video_element, }; use super::{ components::{render_page, HTMX}, vec_to_api, }; #[get("/watch?")] pub async fn watch_page( htmx: HTMX, library: &State, v: String, ) -> (Status, (ContentType, String)) { let video = if let Some(video) = library.get_video_by_id(&v).await { video } else { // TODO : Error handling library.get_video_by_youtube_id(&v).await.unwrap() }; let content = html!( main class="container mx-auto mt-6 flex flex-col lg:flex-row gap-6" { div class="lg:w-2/3 mt-10" { div class="bg-black aspect-video rounded-lg overflow-hidden" { video controls autoplay class="w-full h-full" { source src=(format!("/video/raw?v={}", video.id)) { "Your browser does not support the video" }; }; }; div class="p-4 bg-stone-900 rounded-lg shadow-lg mt-8" { h2 class="text-2xl font-semibold" { (video.title) }; }; }; }; ); render_page(htmx, content, &format!("{} - WatchDogs", video.title)) }