Skip to content

Commit

Permalink
feat: bug fixes (#99)
Browse files Browse the repository at this point in the history
* improved Crunchyroll mapping
* fallback to enime on search
  • Loading branch information
riimuru authored Nov 5, 2022
1 parent 61a997b commit 1d4b00c
Show file tree
Hide file tree
Showing 2 changed files with 241 additions and 118 deletions.
19 changes: 18 additions & 1 deletion src/providers/anime/enime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ class Enime extends AnimeParser {

private readonly enimeApi = 'https://api.enime.moe';

/**
* @param query Search query
* @param page Page number (optional)
*/
rawSearch = async (query: string, page: number = 1, perPage: number = 15): Promise<any> => {
const { data } = await axios.get(`${this.enimeApi}/search/${query}?page=${page}&perPage=${perPage}`);

return data;
};
/**
* @param query Search query
* @param page Page number (optional)
Expand Down Expand Up @@ -103,6 +112,14 @@ class Enime extends AnimeParser {
return animeInfo;
};

fetchAnimeInfoByIdRaw = async (id: string): Promise<any> => {
const { data } = await axios.get(`${this.enimeApi}/mapping/anilist/${id}`).catch(err => {
throw new Error("Backup api seems to be down! Can't fetch anime info");
});

return data;
};

/**
* @param id anilist id
*/
Expand Down Expand Up @@ -157,7 +174,7 @@ class Enime extends AnimeParser {
?.target.split('/')
.pop()
.replace('?ep=', '$episode$')
?.concat(useType === 'zoro' ? "$sub" : "")!,
?.concat(useType === 'zoro' ? '$sub' : '')!,
description: episode.description,
number: episode.number,
title: episode.title,
Expand Down
Loading

0 comments on commit 1d4b00c

Please sign in to comment.