Skip to content

Commit

Permalink
feat: added episode count to top airing anime
Browse files Browse the repository at this point in the history
  • Loading branch information
WBRK-dev committed Jul 21, 2024
1 parent bdfebb5 commit 62fa83a
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions src/parsers/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -158,35 +159,7 @@ async function scrapeHomePage(): Promise<ScrapedHomePage | HttpError> {
}
});

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) {
Expand Down

0 comments on commit 62fa83a

Please sign in to comment.