Skip to content

Commit

Permalink
feat: added mal and anilist id to anime info endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
RazeViana committed Apr 12, 2024
1 parent 05f62ad commit 55eaf06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/parsers/animeAboutInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ async function scrapeAnimeAboutInfo(
anime: {
info: {
id: null,
anilistId: null,
malId: null,
name: null,
poster: null,
description: null,
Expand Down Expand Up @@ -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 =
Expand Down
4 changes: 4 additions & 0 deletions src/types/anime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export interface Anime {
id: string | null;
anilistId: number | null;
malId: number | null;
name: string | null;
poster: string | null;
duration: string | null;
Expand Down Expand Up @@ -43,6 +45,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">;
Expand Down

0 comments on commit 55eaf06

Please sign in to comment.