/* 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 crate::{ RenderInfo, format::{format_count, format_duration}, }; use chrono::DateTime; use jellycommon::{ jellyobject::{EMPTY, TypedTag}, *, }; use jellyui_locale::tr; markup::define! { Props<'a>(ri: &'a RenderInfo<'a>, nku: &'a Nku<'a>, full: bool) { .props { @if let Some(dur) = nku.node.get(NO_DURATION) { p { @format_duration(dur) } } // @if let Some(res) = nku.node.get(NO_TRACK) { // p { @m.resolution_name() } // } @if let Some(d) = nku.node.get(NO_RELEASEDATE) { p { @if *full { @DateTime::from_timestamp_millis(d).unwrap().naive_utc().to_string() } else { @DateTime::from_timestamp_millis(d).unwrap().date_naive().to_string() }} } @match nku.node.get(NO_VISIBILITY).unwrap_or(VISI_VISIBLE) { VISI_REDUCED => {p.visibility{@tr(ri.lang, "prop.vis.reduced")}} VISI_HIDDEN => {p.visibility{@tr(ri.lang, "prop.vis.hidden")}} VISI_VISIBLE | _ => {} } @if nku.child_count > 0 { p { @format!("{} items", nku.child_count) } } @for (kind, value) in nku.node.get(NO_RATINGS).unwrap_or(EMPTY).entries::() { @match TypedTag::new(kind) { RTYP_YOUTUBE_LIKES => {p.likes{ @format_count(value as usize) " Likes" }} RTYP_YOUTUBE_VIEWS => {p{ @format_count(value as usize) " Views" }} RTYP_YOUTUBE_SUBSCRIBERS => {p{ @format_count(value as usize) " Subscribers" }} RTYP_ROTTEN_TOMATOES if *full => {p.rating{ "Rotten Tomatoes: " @value "%" }} RTYP_METACRITIC if *full => {p.rating{ "Metacritic: " @value "/100" }} RTYP_IMDB => {p.rating{ "IMDb " @value }} RTYP_TMDB if *full => {p.rating{ "TMDB " @format!("{:.01}", value) }} RTYP_TRAKT if *full => {p.rating{ "Trakt " @format!("{:.01}", value) }} _ => {} } } // @match nodeu.udata.watched { // WatchedState::None => {} // WatchedState::Pending => { p.pending { @tr(ri.lang, "prop.watched.pending") } } // WatchedState::Progress(x) => { p.progress { @tr(ri.lang, "prop.watched.progress").replace("{time}", &format_duration(x)) } } // WatchedState::Watched => { p.watched { @tr(ri.lang, "prop.watched.watched") } } // } } } }