From bdfebb5e320c15ae9de1a57a66b6a4602bcebf4d Mon Sep 17 00:00:00 2001 From: WBRK-dev Date: Sun, 21 Jul 2024 09:58:18 +0200 Subject: feat: added episode number to estimated anime schedule --- src/parsers/estimatedSchedule.ts | 1 + src/types/parsers/estimatedSchedule.ts | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/parsers/estimatedSchedule.ts b/src/parsers/estimatedSchedule.ts index 822102b..abfce97 100644 --- a/src/parsers/estimatedSchedule.ts +++ b/src/parsers/estimatedSchedule.ts @@ -55,6 +55,7 @@ async function scrapeEstimatedSchedule( ?.trim() || null, airingTimestamp, secondsUntilAiring: Math.floor((airingTimestamp - Date.now()) / 1000), + episode: Number($(el).find("a .fd-play button").text().trim().split(" ")[1]) }); }); diff --git a/src/types/parsers/estimatedSchedule.ts b/src/types/parsers/estimatedSchedule.ts index 6207904..881be86 100644 --- a/src/types/parsers/estimatedSchedule.ts +++ b/src/types/parsers/estimatedSchedule.ts @@ -5,6 +5,7 @@ type EstimatedSchedule = { jname: string | null; airingTimestamp: number; secondsUntilAiring: number; + episode: number; }; export type ScrapedEstimatedSchedule = { -- cgit v1.2.3 From 62fa83a56d5e5ea4cc5e7b38b478208b0c5e6a72 Mon Sep 17 00:00:00 2001 From: WBRK-dev Date: Sun, 21 Jul 2024 10:04:33 +0200 Subject: feat: added episode count to top airing anime --- src/parsers/homePage.ts | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'src') 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 { } }); - 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) { -- cgit v1.2.3 From 5d929461ce918006b9c3977e5af5f76799e820b3 Mon Sep 17 00:00:00 2001 From: WBRK-dev Date: Sun, 21 Jul 2024 10:18:05 +0200 Subject: feat: added `mostPopular`, `mostFavorite` and `latestCompleted` to the home route response --- src/parsers/homePage.ts | 6 ++++++ src/types/anime.ts | 2 ++ src/types/parsers/homePage.ts | 6 ++++++ 3 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/parsers/homePage.ts b/src/parsers/homePage.ts index b03b94e..1409a09 100644 --- a/src/parsers/homePage.ts +++ b/src/parsers/homePage.ts @@ -25,6 +25,9 @@ async function scrapeHomePage(): Promise { month: [], }, topAiringAnimes: [], + mostPopularAnimes: [], + mostFavoriteAnimes: [], + latestCompletedAnimes: [], genres: [], }; @@ -160,6 +163,9 @@ async function scrapeHomePage(): Promise { }); res.topAiringAnimes = extractMostPopularAnimes($, "#anime-featured .row div:nth-of-type(1) .anif-block-ul ul li"); + res.mostPopularAnimes = extractMostPopularAnimes($, "#anime-featured .row div:nth-of-type(2) .anif-block-ul ul li"); + res.mostFavoriteAnimes = extractMostPopularAnimes($, "#anime-featured .row div:nth-of-type(3) .anif-block-ul ul li"); + res.latestCompletedAnimes = extractMostPopularAnimes($, "#anime-featured .row div:nth-of-type(4) .anif-block-ul ul li"); return res; } catch (err: any) { diff --git a/src/types/anime.ts b/src/types/anime.ts index 52bf13a..0d32382 100644 --- a/src/types/anime.ts +++ b/src/types/anime.ts @@ -39,6 +39,8 @@ export interface LatestEpisodeAnime extends Anime {} export interface TopUpcomingAnime extends Anime {} export interface TopAiringAnime extends MostPopularAnime {} +export interface MostFavoriteAnime extends MostPopularAnime {} +export interface LatestCompletedAnime extends MostPopularAnime {} export interface AnimeGeneralAboutInfo extends Pick, diff --git a/src/types/parsers/homePage.ts b/src/types/parsers/homePage.ts index 5641a9a..23f6284 100644 --- a/src/types/parsers/homePage.ts +++ b/src/types/parsers/homePage.ts @@ -4,6 +4,9 @@ import type { TopAiringAnime, TopUpcomingAnime, LatestEpisodeAnime, + MostFavoriteAnime, + MostPopularAnime, + LatestCompletedAnime, } from "../anime.js"; import type { HttpError } from "http-errors"; import type { ScrapedAnimeCategory } from "./animeCategory.js"; @@ -15,4 +18,7 @@ export interface ScrapedHomePage latestEpisodeAnimes: Array | HttpError; topUpcomingAnimes: Array | HttpError; topAiringAnimes: Array | HttpError; + mostPopularAnimes: Array | HttpError; + mostFavoriteAnimes: Array | HttpError; + latestCompletedAnimes: Array | HttpError; } -- cgit v1.2.3 From 94664abdfdf1be8820f96afe081182f59281f4cb Mon Sep 17 00:00:00 2001 From: WBRK-dev Date: Sun, 21 Jul 2024 10:39:17 +0200 Subject: fix: added japanese anime names to all responses --- src/parsers/homePage.ts | 6 +++++- src/types/anime.ts | 2 ++ src/utils/methods.ts | 16 ++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/parsers/homePage.ts b/src/parsers/homePage.ts index 1409a09..cbdaef6 100644 --- a/src/parsers/homePage.ts +++ b/src/parsers/homePage.ts @@ -118,11 +118,15 @@ async function scrapeHomePage(): Promise { rank: parseInt( $(el).find(".item .number")?.children()?.first()?.text()?.trim() ), + id: $(el).find(".item .film-poster")?.attr("href")?.slice(1)?.trim(), name: $(el) .find(".item .number .film-title.dynamic-name") ?.text() ?.trim(), - id: $(el).find(".item .film-poster")?.attr("href")?.slice(1)?.trim(), + jname: $(el) + .find(".item .number .film-title.dynamic-name") + ?.attr("data-jname") + ?.trim(), poster: $(el) .find(".item .film-poster .film-poster-img") ?.attr("data-src") diff --git a/src/types/anime.ts b/src/types/anime.ts index 0d32382..83a3d1f 100644 --- a/src/types/anime.ts +++ b/src/types/anime.ts @@ -1,6 +1,7 @@ export interface Anime { id: string | null; name: string | null; + jname: string | null; poster: string | null; duration: string | null; type: string | null; @@ -15,6 +16,7 @@ type CommonAnimeProps = "id" | "name" | "poster"; export interface Top10Anime extends Pick { rank: number | null; + jname: string | null; } export type Top10AnimeTimePeriod = "day" | "week" | "month"; diff --git a/src/utils/methods.ts b/src/utils/methods.ts index 1ed0c88..9f57ff9 100644 --- a/src/utils/methods.ts +++ b/src/utils/methods.ts @@ -39,6 +39,10 @@ export const extractAnimes = ( .find(".film-detail .film-name .dynamic-name") ?.text() ?.trim(), + jname: $(el) + .find(".film-detail .film-name .dynamic-name") + ?.attr("data-jname") + ?.trim() || null, poster: $(el) .find(".film-poster .film-poster-img") @@ -102,6 +106,7 @@ export const extractTop10Animes = ( .trim() || null, rank: Number($(el).find(".film-number span")?.text()?.trim()) || null, name: $(el).find(".film-detail .dynamic-name")?.text()?.trim() || null, + jname: $(el).find(".film-detail .dynamic-name")?.attr("data-jname")?.trim() || null, poster: $(el) .find(".film-poster .film-poster-img") @@ -150,17 +155,16 @@ export const extractMostPopularAnimes = ( ?.slice(1) .trim() || null, name: $(el).find(".film-detail .dynamic-name")?.text()?.trim() || null, - poster: - $(el) - .find(".film-poster .film-poster-img") - ?.attr("data-src") - ?.trim() || null, jname: $(el) .find(".film-detail .film-name .dynamic-name") .attr("data-jname") ?.trim() || null, - + poster: + $(el) + .find(".film-poster .film-poster-img") + ?.attr("data-src") + ?.trim() || null, episodes: { sub: Number($(el)?.find(".fd-infor .tick .tick-sub")?.text()?.trim()) || -- cgit v1.2.3