From 041c0b7098ffb3d87a729d7dbfc774a96761d3c3 Mon Sep 17 00:00:00 2001 From: Ritesh Ghosh Date: Sun, 14 Jul 2024 00:09:22 +0530 Subject: [PATCH] feat: add `airingTimestamp` and `secondsUntilAiring` to `/anime/schedule` endpoint --- src/parsers/estimatedSchedule.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/parsers/estimatedSchedule.ts b/src/parsers/estimatedSchedule.ts index 6fc3d1a..822102b 100644 --- a/src/parsers/estimatedSchedule.ts +++ b/src/parsers/estimatedSchedule.ts @@ -40,6 +40,10 @@ async function scrapeEstimatedSchedule( } $(selector).each((_, el) => { + const airingTimestamp = new Date( + `${date}T${$(el)?.find("a .time")?.text()?.trim()}:00` + ).getTime(); + res.scheduledAnimes.push({ id: $(el)?.find("a")?.attr("href")?.slice(1)?.trim() || null, time: $(el)?.find("a .time")?.text()?.trim() || null, @@ -49,6 +53,8 @@ async function scrapeEstimatedSchedule( ?.find("a .film-name.dynamic-name") ?.attr("data-jname") ?.trim() || null, + airingTimestamp, + secondsUntilAiring: Math.floor((airingTimestamp - Date.now()) / 1000), }); });