/* 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) 2025 metamuffin */ use crate::{ format::{MediaInfoExt, format_count, format_duration}, locale::{Language, tr, trs}, }; use jellycommon::{ Node, Rating, Visibility, chrono::DateTime, user::{NodeUserData, WatchedState}, }; markup::define! { Props<'a>(node: &'a Node, udata: &'a NodeUserData, full: bool, lang: &'a Language) { .props { @if let Some(m) = &node.media { p { @format_duration(m.duration) } p { @m.resolution_name() } } @if let Some(d) = &node.release_date { 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 node.visibility { Visibility::Visible => {} Visibility::Reduced => {p.visibility{@trs(lang, "prop.vis.reduced")}} Visibility::Hidden => {p.visibility{@trs(lang, "prop.vis.hidden")}} } // TODO // @if !node.children.is_empty() { // p { @format!("{} items", node.children.len()) } // } @for (kind, value) in &node.ratings { @match kind { Rating::YoutubeLikes => {p.likes{ @format_count(*value as usize) " Likes" }} Rating::YoutubeViews => {p{ @format_count(*value as usize) " Views" }} Rating::YoutubeFollowers => {p{ @format_count(*value as usize) " Subscribers" }} Rating::RottenTomatoes => {p.rating{ @value " Tomatoes" }} Rating::Metacritic if *full => {p{ "Metacritic Score: " @value }} Rating::Imdb => {p.rating{ "IMDb " @value }} Rating::Tmdb => {p.rating{ "TMDB " @value }} Rating::Trakt if *full => {p.rating{ "Trakt " @value }} _ => {} } } @if let Some(f) = &node.federated { p.federation { @f } } @match udata.watched { WatchedState::None => {} WatchedState::Pending => { p.pending { @trs(lang, "prop.watched.pending") } } WatchedState::Progress(x) => { p.progress { @tr(**lang, "prop.watched.progress").replace("{time}", &format_duration(x)) } } WatchedState::Watched => { p.watched { @trs(lang, "prop.watched.watched") } } } } } }