diff options
| author | Ritesh Ghosh <[email protected]> | 2024-07-14 00:09:22 +0530 |
|---|---|---|
| committer | Ritesh Ghosh <[email protected]> | 2024-07-14 00:09:22 +0530 |
| commit | 041c0b7098ffb3d87a729d7dbfc774a96761d3c3 (patch) | |
| tree | 5c7152e33455cb3b54843874ecfa6bccb88fe93f /src | |
| parent | 3f0b367ae027370a81df716eb75c05703a1af905 (diff) | |
| download | aniwatch-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.ts | 6 |
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), }); }); |
