aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parsers/homePage.ts31
1 files 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<ScrapedHomePage | HttpError> {
}
});
- 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) {