diff options
| author | Ritesh Ghosh <[email protected]> | 2024-04-14 08:26:17 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-14 08:26:17 +0530 |
| commit | 7688301bf2224bb81bd20d9843cdba977ad48a44 (patch) | |
| tree | 1849929a9fc27c56249d48060606c0ae6a8ed20c /src | |
| parent | 05f62add7689dd4308f53d5777961d5720afbe93 (diff) | |
| parent | 4682af675db9434b389d044d29fd551822542d88 (diff) | |
| download | aniwatch-api-7688301bf2224bb81bd20d9843cdba977ad48a44.tar.xz aniwatch-api-7688301bf2224bb81bd20d9843cdba977ad48a44.zip | |
Merge pull request #39 from RazeViana/add-mal-and-anilist-id-to-anime-info
feat: added mal and anilist id to anime info endpoint
Diffstat (limited to 'src')
| -rw-r--r-- | src/parsers/animeAboutInfo.ts | 12 | ||||
| -rw-r--r-- | src/types/anime.ts | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/parsers/animeAboutInfo.ts b/src/parsers/animeAboutInfo.ts index cc3f936..54af57f 100644 --- a/src/parsers/animeAboutInfo.ts +++ b/src/parsers/animeAboutInfo.ts @@ -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 = diff --git a/src/types/anime.ts b/src/types/anime.ts index 7365c5e..abb15f2 100644 --- a/src/types/anime.ts +++ b/src/types/anime.ts @@ -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">; |
