Add interstitial endpoints and enhance media and template functionalities: implement MapInterstitialEndpoints in Program.cs, add preview functionality for media assets in MediaEndpoints, and introduce template preview capabilities in TemplateEndpoints. Remove obsolete bumper settings from Channel and related classes to streamline configuration.
This commit is contained in:
@@ -18,16 +18,23 @@ export function formatMinute(minute: number | null) {
|
||||
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Момент UTC во времени канала. Сетка задаётся в нём, поэтому предпросмотр показывается так же:
|
||||
* локальное время админа тут только запутало бы.
|
||||
*/
|
||||
export function channelTime(iso: string, utcOffsetMinutes: number): Date {
|
||||
return new Date(new Date(iso).getTime() + utcOffsetMinutes * 60_000)
|
||||
}
|
||||
|
||||
/** «HH:MM» во времени канала. */
|
||||
export function formatChannelTime(iso: string, utcOffsetMinutes: number): string {
|
||||
const d = channelTime(iso, utcOffsetMinutes)
|
||||
return `${String(d.getUTCHours()).padStart(2, '0')}:${String(d.getUTCMinutes()).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
/** ffmpeg-цвет (0xRRGGBB / имя) → CSS для превью-плашки. */
|
||||
export function cssColor(value: string): string {
|
||||
const v = value.trim()
|
||||
if (v.startsWith('0x')) return `#${v.slice(2)}`
|
||||
return v
|
||||
}
|
||||
|
||||
/** Ограничивает вероятность появления заставки диапазоном 0..1 (пустой ввод → 0). */
|
||||
export function clampChance(value: string): number {
|
||||
const n = Number(value)
|
||||
if (Number.isNaN(n)) return 0
|
||||
return Math.min(1, Math.max(0, n))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user