From 2a26a6030e25127a3967dd5bccba1fb05d485ab1 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 17 Dec 2023 20:58:10 +0100 Subject: chapters --- server/src/routes/ui/node.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'server/src') diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 6ce82c2..fbbf012 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -26,7 +26,7 @@ use anyhow::{anyhow, Context, Result}; use jellybase::permission::NodePermissionExt; use jellycommon::{ user::{NodeUserData, WatchedState}, - MediaInfo, NodeKind, NodePublic, Rating, SourceTrackKind, + Chapter, MediaInfo, NodeKind, NodePublic, Rating, SourceTrackKind, }; use rocket::{get, serde::json::Json, Either, State}; @@ -142,6 +142,14 @@ markup::define! { li { @format!("{track}") } }} } + @if !media.chapters.is_empty() { + details { + summary { "Chapters" } + ol { @for chap in &media.chapters { + li { @format_chapter(chap) } + }} + } + } } } @if matches!(node.kind, NodeKind::Collection | NodeKind::Channel) { @@ -280,3 +288,12 @@ fn format_count(n: impl Into) -> String { format!("{n}") } } + +fn format_chapter(c: &Chapter) -> String { + format!( + "{}-{}: {}", + c.time_start.map(format_duration).unwrap_or_default(), + c.time_end.map(format_duration).unwrap_or_default(), + c.labels.first().map(|l| l.1.clone()).unwrap_or_default() + ) +} -- cgit v1.2.3-70-g09d2