aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRitesh Ghosh <[email protected]>2024-07-14 00:09:22 +0530
committerRitesh Ghosh <[email protected]>2024-07-14 00:09:22 +0530
commit041c0b7098ffb3d87a729d7dbfc774a96761d3c3 (patch)
tree5c7152e33455cb3b54843874ecfa6bccb88fe93f /src
parent3f0b367ae027370a81df716eb75c05703a1af905 (diff)
downloadaniwatch-api-041c0b7098ffb3d87a729d7dbfc774a96761d3c3.tar.xz
aniwatch-api-041c0b7098ffb3d87a729d7dbfc774a96761d3c3.zip
feat: add `airingTimestamp` and `secondsUntilAiring` to `/anime/schedule` endpoint
Diffstat (limited to 'src')
-rw-r--r--src/parsers/estimatedSchedule.ts6
1 files changed, 6 insertions, 0 deletions
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),
});
});