Skip to content

Commit

Permalink
fix(gogoanime): recent episodes & genreslist
Browse files Browse the repository at this point in the history
  • Loading branch information
riimuru committed Nov 25, 2023
1 parent d420bb8 commit 244dd32
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions dist/providers/anime/gogoanime.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/gogoanime.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lint": "prettier --write .",
"prepare": "husky install",
"test": "jest",
"test:gogoanime": "jest ./test/anime/gogoanime.test.ts",
"test:anime": "jest ./test/anime",
"test:books": "jest ./test/books/libgen.test.ts",
"test:comics": "jest ./test/comics",
Expand Down
13 changes: 7 additions & 6 deletions src/providers/anime/gogoanime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Gogoanime extends AnimeParser {
};
try {
const res = await this.client.get(
`${this.baseUrl}/search.html?keyword=${encodeURIComponent(query)}&page=${page}`
`${this.baseUrl}/filter.html?keyword=${encodeURIComponent(query)}&page=${page}`
);

const $ = load(res.data);
Expand Down Expand Up @@ -140,7 +140,8 @@ class Gogoanime extends AnimeParser {
const alias = $('#alias_anime').attr('value');

const html = await this.client.get(
`${this.ajaxUrl
`${
this.ajaxUrl
}/load-list-episode?ep_start=${ep_start}&ep_end=${ep_end}&id=${movie_id}&default_ep=${0}&alias=${alias}`
);
const $$ = load(html.data);
Expand Down Expand Up @@ -383,21 +384,21 @@ class Gogoanime extends AnimeParser {

fetchGenreList = async (): Promise<string[]> => {
try {
const res = await this.client.get(`${this.baseUrl}/`);
const res = await this.client.get(`${this.baseUrl}/home.html`);

const $ = load(res.data);

const genres: string[] = [];

$('nav.menu_series.genre.right > ul > li').each((_index, element) => {
genres.push($(element).find('a').attr('title')!)
})
genres.push($(element).find('a').attr('title')!);
});

return genres;
} catch (err) {
throw new Error('Something went wrong. Please try again later.');
}
}
};
}

// (async () => {
Expand Down
7 changes: 6 additions & 1 deletion test/anime/gogoanime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ test('returns a filled object of episode sources', async () => {
test('returns a filled array of available genres', async () => {
const data = await gogoanime.fetchGenreList();
expect(data).not.toEqual([]);
});
});

test('returns a filled array of recent episodes', async () => {
const data = await gogoanime.fetchRecentEpisodes();
expect(data).not.toEqual([]);
});

0 comments on commit 244dd32

Please sign in to comment.