Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dub episodes returning a sub id despite not having dub episodes #84

Merged
merged 1 commit into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/providers/meta/anilist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,14 @@ class Anilist extends AnimeParser {
} else possibleAnime = await this.findAnimeRaw(slug);
} else possibleAnime = await this.findAnimeRaw(slug);

// To avoid a new request, lets match and see if the anime show found is in sub/dub

let expectedType = dub ? SubOrSub.DUB : SubOrSub.SUB;

if (possibleAnime.subOrDub != SubOrSub.BOTH && possibleAnime.subOrDub != expectedType) {
return [];
}

const possibleProviderEpisodes = possibleAnime.episodes;

const options = {
Expand Down
11 changes: 11 additions & 0 deletions test/meta/anilist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ test('returns a filled object of anime data', async () => {
expect(data.description).not.toBeNull();
});

test('returns episodes for sub and dub not available', async () => {
const anilist = new META.Anilist();
const subData = await anilist.fetchEpisodesListById('949', false);
expect(subData).not.toBeNull();
expect(subData).not.toEqual([]);

const dubData = await anilist.fetchEpisodesListById('949', true);
expect(dubData).not.toBeNull();
expect(dubData).toEqual([]);
});

test('returns a filled array of servers', async () => {
const anilist = new META.Anilist();
const data = await anilist.fetchEpisodeServers('spy-x-family-episode-9');
Expand Down