1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
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 <metamuffin.org>
*/
use super::error::MyResult;
use crate::request_info::RequestInfo;
use anyhow::anyhow;
use jellycommon::{
jellyobject::{EMPTY, Path},
*,
};
use jellydb::{Filter, Query};
use jellyui::components::node_page::Player;
use rocket::{get, response::content::RawHtml};
use std::borrow::Cow;
// 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/<slug>/player?<t>", rank = 4)]
pub fn r_player(ri: RequestInfo<'_>, t: Option<f64>, slug: &str) -> MyResult<RawHtml<String>> {
ri.require_user()?;
let _ = t;
let mut node = 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()
})? {
node = Some(txn.get(row)?.unwrap());
}
Ok(())
})?;
let Some(node) = node else {
Err(anyhow!("no such node"))?
};
Ok(ri.respond_ui(&Player {
ri: &ri.render_info(),
nku: Nku {
node: Cow::Borrowed(&node),
userdata: Cow::Borrowed(EMPTY),
role: None,
},
}))
}
|