From 71d31668fc7fa2e3a7c3e8097a2afb1e535dede0 Mon Sep 17 00:00:00 2001 From: Juan-Lucas Date: Sat, 8 Feb 2025 17:41:29 +0100 Subject: [PATCH] feat(routes/nautiljon): improve the manga-releases route (#18303) --- lib/routes/nautiljon/manga-releases.ts | 39 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/routes/nautiljon/manga-releases.ts b/lib/routes/nautiljon/manga-releases.ts index 0a6a41294..7eb6974ef 100644 --- a/lib/routes/nautiljon/manga-releases.ts +++ b/lib/routes/nautiljon/manga-releases.ts @@ -8,7 +8,7 @@ const host = 'https://www.nautiljon.com'; export const route: Route = { path: '/releases/manga', categories: ['reading'], - example: 'nautiljon/releases/manga', + example: '/nautiljon/releases/manga', parameters: {}, features: { requireConfig: false, @@ -29,6 +29,14 @@ export const route: Route = { url: 'nautiljon.com', }; +const isVolumeReleased = (releaseDate: string) => { + const releaseDateToCheck = parseDate(releaseDate, 'DD/MM/YYYY'); + const todayDate = new Date(); + todayDate.setHours(0, 0, 0, 0); + + return releaseDateToCheck <= todayDate; +}; + async function handler() { const response = await ofetch(`${host}/planning/manga/`, { headers: { @@ -37,21 +45,24 @@ async function handler() { }); const $ = load(response); - const items = $('table#planning tbody tr') + const list = $('table#planning tbody tr') .toArray() - .map((item) => { - item = $(item); - const a = item.find('td.p_titre').find('a.sim').first(); - const img = item.find('td:nth-child(2) a').first(); + .filter((item) => isVolumeReleased($(item).find('td').first().text())); + const items = list.map((item) => { + item = $(item); + const releaseDate = item.find('td').first().text(); - return { - title: a.text(), - link: `${host}${a.attr('href')}`, - pubDate: parseDate(item.find('td').first().text(), 'DD/MM/YYYY'), - image: `${host}${img.attr('im')}`, - category: item.find('td.p_titre div.fl').first().text(), - }; - }); + const a = item.find('td.p_titre').find('a.sim').first(); + const img = item.find('td:nth-child(2) a').first(); + + return { + title: a.text(), + link: `${host}${a.attr('href')}`, + pubDate: parseDate(releaseDate, 'DD/MM/YYYY'), + image: `${host}${img.attr('im')}`, + category: item.find('td.p_titre div.fl').first().text(), + }; + }); return { title: 'Nautiljon France Manga Releases',