Skip to content

Commit

Permalink
feat: add airingTimestamp and secondsUntilAiring to `/anime/sched…
Browse files Browse the repository at this point in the history
…ule` endpoint
  • Loading branch information
ghoshRitesh12 committed Jul 13, 2024
1 parent 3f0b367 commit 041c0b7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/parsers/estimatedSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
});
});

Expand Down

0 comments on commit 041c0b7

Please sign in to comment.