Merge pull request #39 from RazeViana/add-mal-and-anilist-id-to-anime-info

feat: added mal and anilist id to anime info endpoint
This commit is contained in:
Ritesh Ghosh
2024-04-14 08:26:17 +05:30
committed by GitHub
2 changed files with 14 additions and 0 deletions
+12
View File
@@ -19,6 +19,8 @@ async function scrapeAnimeAboutInfo(
anime: {
info: {
id: null,
anilistId: null,
malId: null,
name: null,
poster: null,
description: null,
@@ -53,6 +55,16 @@ async function scrapeAnimeAboutInfo(
const $: CheerioAPI = load(mainPage.data);
try {
res.anime.info.anilistId = Number(
JSON.parse($("body")?.find("#syncData")?.text())?.anilist_id
);
res.anime.info.malId = Number(JSON.parse($("body")?.find("#syncData")?.text())?.mal_id);
} catch (err) {
res.anime.info.anilistId = null;
res.anime.info.malId = null;
}
const selector: SelectorType = "#ani_detail .container .anis-content";
res.anime.info.id =
+2
View File
@@ -43,6 +43,8 @@ export interface TopAiringAnime extends MostPopularAnime {}
export interface AnimeGeneralAboutInfo
extends Pick<Anime, CommonAnimeProps>,
Pick<SpotlightAnime, "description"> {
anilistId: number | null;
malId: number | null;
stats: {
quality: string | null;
} & Pick<Anime, "duration" | "episodes" | "rating" | "type">;