aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWBRK-dev <[email protected]>2024-07-21 10:04:33 +0200
committerWBRK-dev <[email protected]>2024-07-21 10:04:33 +0200
commit62fa83a56d5e5ea4cc5e7b38b478208b0c5e6a72 (patch)
tree217e3e0e710c2c818e6e169cd39f89a6af97ca53 /src
parentbdfebb5e320c15ae9de1a57a66b6a4602bcebf4d (diff)
downloadaniwatch-api-62fa83a56d5e5ea4cc5e7b38b478208b0c5e6a72.tar.xz
aniwatch-api-62fa83a56d5e5ea4cc5e7b38b478208b0c5e6a72.zip
feat: added episode count to top airing anime
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) {