Skip to content

Commit

Permalink
feat(routes/nautiljon): improve the manga-releases route (#18303)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fafnor authored Feb 8, 2025
1 parent 5a2abb6 commit 71d3166
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions lib/routes/nautiljon/manga-releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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: {
Expand All @@ -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();

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(),
};
});
.filter((item) => isVolumeReleased($(item).find('td').first().text()));
const items = list.map((item) => {
item = $(item);
const releaseDate = item.find('td').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',
Expand Down

0 comments on commit 71d3166

Please sign in to comment.