// A total of video lengths and the live videos it cannot hold. The server decides what a length is // (a YouTube "length" past a day is a 24/7 stream's archive reporting the years it has run, and the // API sends none for it: `catalog.models.LENGTH_MAX_S`), so this side keeps no copy of that limit. It // only names what a sum left out: a live video — on air, upcoming, a premiere or an archive — with no // length, as the server's `Video.live_without_length` counts it for the totals it sums itself. import type { TFunction } from "i18next"; import type { Video } from "../../lib/api/feed"; export function isLiveWithoutLength(v: Pick): boolean { return v.duration_seconds == null && v.live_status !== "none"; } /** "12 hr 5 min +2 live": `total` is the formatted sum ("" when nothing summed), `live` the count * it left out. Empty when both are. */ export function withLiveCount(total: string, live: number, t: TFunction): string { const suffix = live > 0 ? t("card.liveWithoutLength", { count: live }) : ""; return [total, suffix].filter(Boolean).join(" "); }