From 62fa83a56d5e5ea4cc5e7b38b478208b0c5e6a72 Mon Sep 17 00:00:00 2001 From: WBRK-dev Date: Sun, 21 Jul 2024 10:04:33 +0200 Subject: [PATCH] feat: added episode count to top airing anime --- src/parsers/homePage.ts | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/src/parsers/homePage.ts b/src/parsers/homePage.ts index 979e7e9..b03b94e 100644 --- a/src/parsers/homePage.ts +++ b/src/parsers/homePage.ts @@ -5,6 +5,7 @@ import { ACCEPT_ENCODING_HEADER, extractTop10Animes, extractAnimes, + extractMostPopularAnimes, } from "../utils/index.js"; import axios, { AxiosError } from "axios"; import createHttpError, { type HttpError } from "http-errors"; @@ -158,35 +159,7 @@ async function scrapeHomePage(): Promise { } }); - const topAiringSelector: SelectorType = - "#anime-featured .row div:nth-of-type(1) .anif-block-ul ul li"; - $(topAiringSelector).each((i, el) => { - const otherInfo = $(el) - .find(".fd-infor .fdi-item") - .map((i, el) => $(el).text().trim()) - .get(); - - res.topAiringAnimes.push({ - id: $(el) - .find(".film-detail .film-name .dynamic-name") - ?.attr("href") - ?.slice(1) - ?.trim(), - name: $(el) - .find(".film-detail .film-name .dynamic-name") - ?.attr("title") - ?.trim(), - jname: $(el) - .find(".film-detail .film-name .dynamic-name") - ?.attr("data-jname") - ?.trim(), - poster: $(el) - .find(".film-poster a .film-poster-img") - ?.attr("data-src") - ?.trim(), - otherInfo, - }); - }); + res.topAiringAnimes = extractMostPopularAnimes($, "#anime-featured .row div:nth-of-type(1) .anif-block-ul ul li"); return res; } catch (err: any) {