diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/routes/ui/node.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 2c335d3..83719d0 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -17,7 +17,7 @@ use crate::{ uri, }; use anyhow::{anyhow, Context}; -use jellycommon::{MediaInfo, NodeKind, NodePublic, SourceTrackKind}; +use jellycommon::{MediaInfo, NodeKind, NodePublic, Rating, SourceTrackKind}; use rocket::{get, serde::json::Json, Either, State}; #[get("/n/<id>")] @@ -74,7 +74,7 @@ markup::define! { } NodeCard<'a>(id: &'a str, node: &'a NodePublic) { @PosterCard { - wide: matches!(node.kind, NodeKind::Collection), + wide: matches!(node.kind, NodeKind::Collection | NodeKind::Video), dir: !matches!(node.kind, NodeKind::Movie | NodeKind::Episode), id, title: &node.title @@ -129,6 +129,13 @@ markup::define! { p { @format_duration(m.duration) } p { @m.resolution_name() } } + @for r in &node.ratings { + p { @match r { + Rating::YoutubeLikes(n) => { @format_count(*n) " Likes" } + Rating::YoutubeViews(n) => { @format_count(*n) " Views" } + _ => { "Unknown Rating" } + } } + } } h3 { @node.tagline } p { @node.description } @@ -187,6 +194,7 @@ impl MediaInfoExt for MediaInfo { match maxw { 7680.. => "8K", 3840.. => "4K", + 2560.. => "WQHD", 1920.. => "Full HD", 1280.. => "HD 720p", 640.. => "NTSC", @@ -194,3 +202,15 @@ impl MediaInfoExt for MediaInfo { } } } + +fn format_count(n: impl Into<usize>) -> String { + let n: usize = n.into(); + + if n >= 1_000_000 { + format!("{:.1}M", n as f32 / 1_000_000.) + } else if n >= 1_000 { + format!("{:.1}k", n as f32 / 1_000.) + } else { + format!("{n}") + } +} |