/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2026 metamuffin */ use super::error::MyResult; use crate::{request_info::RequestInfo, routes::node::create_nku}; use anyhow::anyhow; use jellycommon::{jellyobject::Path, *}; use jellydb::{Filter, Query}; use jellyui::components::node_page::Player; use rocket::{get, response::content::RawHtml}; // fn jellynative_url(action: &str, seek: f64, secret: &str, node: &str, session: &str) -> String { // let protocol = if CONF.tls { "https" } else { "http" }; // let host = &CONF.hostname; // let stream_url = format!( // "/n/{node}/stream{}", // StreamSpec::HlsMultiVariant { // container: StreamContainer::Matroska // } // .to_query() // ); // format!("jellynative://{action}/{secret}/{session}/{seek}/{protocol}://{host}{stream_url}",) // } #[get("/n//player?", rank = 4)] pub fn r_player(ri: RequestInfo<'_>, t: Option, slug: &str) -> MyResult> { ri.require_user()?; let _ = t; let mut nku = None; ri.state.database.transaction(&mut |txn| { if let Some(row) = txn.query_single(Query { filter: Filter::Match(Path(vec![NO_SLUG.0]), slug.into()), ..Default::default() })? { nku = Some(create_nku(txn, row)?); } Ok(()) })?; let Some(nku) = nku else { Err(anyhow!("no such node"))? }; Ok(ri.respond_ui(&Player { ri: &ri.render_info(), nku, })) }