Skip to content

Commit

Permalink
feat(zoro): added relatedAnime to fetchAnimeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
jasanpreetn9 committed Mar 18, 2024
1 parent 40f85a0 commit a157c1a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
18 changes: 18 additions & 0 deletions dist/providers/anime/zoro.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/providers/anime/zoro.js.map

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/providers/anime/zoro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,23 @@ class Zoro extends AnimeParser {
info.type = $('span.item').last().prev().prev().text().toUpperCase() as MediaFormat;
info.url = `${this.baseUrl}/${id}`;
info.recommendations = await this.scrapeCard($);
info.relatedAnime = [];
$("#main-sidebar section:nth-child(1) div.anif-block-ul li").each((i, ele) => {
const card = $(ele);
const aTag = card.find('.film-name a');
const id = aTag.attr('href')?.split('/')[1].split('?')[0];
info.relatedAnime.push({
id: id!,
title: aTag.text(),
url: `${this.baseUrl}${aTag.attr('href')}`,
image: card.find('img')?.attr('data-src'),
japaneseTitle: aTag.attr('data-jname'),
type: card.find(".tick").contents().last()?.text()?.trim() as MediaFormat,
sub: parseInt(card.find('.tick-item.tick-sub')?.text()) || 0,
dub: parseInt(card.find('.tick-item.tick-dub')?.text()) || 0,
episodes: parseInt(card.find('.tick-item.tick-eps')?.text()) || 0,
});
});
const hasSub: boolean = $('div.film-stats div.tick div.tick-item.tick-sub').length > 0;
const hasDub: boolean = $('div.film-stats div.tick div.tick-item.tick-dub').length > 0;

Expand Down
2 changes: 1 addition & 1 deletion test/anime/zoro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test('returns a filled array of anime list', async () => {

test('returns a filled object of anime data', async () => {
const res = await zoro.search('Overlord IV');
const data = await zoro.fetchAnimeInfo(res.results[3].id); // Overlord IV id
const data = await zoro.fetchAnimeInfo("one-piece-100"); // Overlord IV id
expect(data).not.toBeNull();
expect(data.description).not.toBeNull();
expect(data.episodes).not.toEqual([]);
Expand Down

0 comments on commit a157c1a

Please sign in to comment.