import { decodeEpgText, epgToIso, parseAmsterdamLocalMs, parseXmltvTimeMs } from "../iptv/xtream"; import { parseNowNextPrograms } from "./iptv-client"; function assert(cond: unknown, msg: string) { if (!cond) throw new Error(msg); } const startMs = parseXmltvTimeMs("20260905140000 +0200"); assert(startMs === Date.UTC(2026, 8, 5, 12, 0, 0), `offset parse got ${startMs}`); const local = parseAmsterdamLocalMs("2026-09-05 14:00:00"); assert(local != null && Number.isFinite(local), "amsterdam local"); const iso = epgToIso( { title: "X", start: "2026-09-05 14:00:00", end: "2026-09-05 15:00:00" }, "start" ); assert(iso != null, "epgToIso naive"); assert(decodeEpgText(Buffer.from("Hallo").toString("base64")).includes("Hallo"), "b64"); const listed = parseNowNextPrograms([ { title: Buffer.from("Nu live").toString("base64"), start: "2000-01-01 00:00:00", end: "2100-01-01 00:00:00", start_timestamp: Math.floor(Date.now() / 1000) - 60, stop_timestamp: Math.floor(Date.now() / 1000) + 3600, }, ]); assert(listed.now?.title === "Nu live", `now title=${listed.now?.title}`); console.log("epg-parse tests ok");