diff options
| author | WBRK-dev <[email protected]> | 2024-04-28 11:44:26 +0200 |
|---|---|---|
| committer | WBRK-dev <[email protected]> | 2024-04-28 11:44:26 +0200 |
| commit | f6261199f8e83fd52714055023d033afbc09e53f (patch) | |
| tree | 2aecc16392a4afb284659ba69257c7e08c378e17 /src | |
| parent | 8abde11e7b09652447938afda936b0fa2bca7c76 (diff) | |
| download | aniwatch-api-f6261199f8e83fd52714055023d033afbc09e53f.tar.xz aniwatch-api-f6261199f8e83fd52714055023d033afbc09e53f.zip | |
feat: added characters and voice actors to `/info` endpoint response
Diffstat (limited to 'src')
| -rw-r--r-- | src/parsers/animeAboutInfo.ts | 21 | ||||
| -rw-r--r-- | src/types/anime.ts | 13 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/parsers/animeAboutInfo.ts b/src/parsers/animeAboutInfo.ts index 7b2e422..2467aed 100644 --- a/src/parsers/animeAboutInfo.ts +++ b/src/parsers/animeAboutInfo.ts @@ -37,6 +37,7 @@ async function scrapeAnimeAboutInfo( duration: null, }, promotionalVideos: [], + charactersVoiceActors: [], }, moreInfo: {}, }, @@ -133,6 +134,26 @@ async function scrapeAnimeAboutInfo( } ); + // get characters and voice actors + $(".block_area.block_area-actors .block-actors-content .bac-list-wrap .bac-item").each( + (_, el) => { + res.anime.info.charactersVoiceActors.push({ + character: { + id: $(el).find($(".per-info.ltr .pi-avatar")).attr("href")?.split("/")[2] || "", + poster: $(el).find($(".per-info.ltr .pi-avatar img")).attr("data-src") || "", + name: $(el).find($(".per-info.ltr .pi-detail a")).text(), + cast: $(el).find($(".per-info.ltr .pi-detail .pi-cast")).text(), + }, + voiceActor: { + id: $(el).find($(".per-info.rtl .pi-avatar")).attr("href")?.split("/")[2] || "", + poster: $(el).find($(".per-info.rtl .pi-avatar img")).attr("data-src") || "", + name: $(el).find($(".per-info.rtl .pi-detail a")).text(), + cast: $(el).find($(".per-info.rtl .pi-detail .pi-cast")).text(), + }, + }); + } + ); + // more information $(`${selector} .anisc-info-wrap .anisc-info .item:not(.w-hide)`).each( (i, el) => { diff --git a/src/types/anime.ts b/src/types/anime.ts index cbb80c5..c23acaa 100644 --- a/src/types/anime.ts +++ b/src/types/anime.ts @@ -49,6 +49,7 @@ export interface AnimeGeneralAboutInfo quality: string | null; } & Pick<Anime, "duration" | "episodes" | "rating" | "type">; promotionalVideos: AnimePromotionalVideo[]; + charactersVoiceActors: AnimeCharactersAndVoiceActors[]; } export interface RecommendedAnime extends Anime {} @@ -66,6 +67,18 @@ export interface AnimePromotionalVideo { thumbnail: string | undefined; } +export interface AnimeCharactersAndVoiceActors { + character: AnimeCharacter; + voiceActor: AnimeCharacter; +} + +export interface AnimeCharacter { + id: string; + poster: string; + name: string; + cast: string; +} + export interface AnimeSearchSuggestion extends Omit<MostPopularAnime, "episodes" | "type"> { moreInfo: Array<string>; |
