Skip to content

Commit

Permalink
feat(anime): added animepahe provider
Browse files Browse the repository at this point in the history
- Added animepahe provider
- Added kwik extractor
- refactored some code
- added tests for animepahe & fixed gogoanime tests
  • Loading branch information
riimuru authored Jul 10, 2022
2 parents 3e18328 + 8bcdbd1 commit 19fd07d
Show file tree
Hide file tree
Showing 23 changed files with 671 additions and 86 deletions.
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center"><img src="https://raw.githubusercontent.com/consumet/extensions/5c3bc399fd12ebdaa915dc69b7bdf82cbdf4201c/assets/images/consumetlogo.png" width="175"/></p>

<h1 align="center"> Consumet Extentions </h1>
<h1 align="center"> Consumet Extensions </h1>

Consumet Extensions is a Node library which provides high-level APIs to get information about several entertainment mediums like books, movies, comics, anime, manga, etc.

Expand Down Expand Up @@ -32,6 +32,7 @@ Consumet Extensions is a Node library which provides high-level APIs to get info
- [Provider Request](#provider-request)
- [Contributing](#contributing)
- [Support](#support)
- [Contributors](#contributors)
- [License](#license)

## Quick Start
Expand All @@ -50,33 +51,26 @@ yarn add @consumet/extensions
```ts
import { BOOKS } from "@consumet/extensions"


const main = async () => {
// Create a new instance of the Libgen provider
const books = new BOOKS.Libgen();
// Search for a book. In this case, "Pride and Prejudice"
const data = await books.search('pride and prejudice');
// loop through the results and print the title
for (let v of data) {
console.log(v.title);
}
};

main();
// Create a new instance of the Libgen provider
const books = new BOOKS.Libgen();
// Search for a book. In this case, "Pride and Prejudice"
const data = books.search('pride and prejudice').then(data => {
// print results
console.log(data)
})
```

**Exmaple** - searching for anime using the gogoanime provider.
```ts
import { ANIME } from "@consumet/extensions"

const main = async () => {
// Create a new instance of the Gogoanime provider
const gogoanime = new ANIME.Gogoanime();
// Search for an anime. In this case, "One Piece"
const results = await gogoanime.search("One Piece");
// print the results
console.log(results);
}
// Create a new instance of the Gogoanime provider
const gogoanime = new ANIME.Gogoanime();
// Search for an anime. In this case, "One Piece"
const results = gogoanime.search("One Piece").then(data => {
// print results
console.log(data);
})
```

Do you want to know more? Head to the [`Getting Started`](https://github.com/consumet/extensions/tree/master/docs/guides/getting-started.md).
Expand All @@ -99,13 +93,18 @@ Do you want to know more? Head to the [`Getting Started`](https://github.com/con
- [Discord Server](https://discord.gg/qTPfvMxzNH) - Join our discord server and chat with the maintainers.

## Provider Request
Make a new [issue](https://github.com/consumet/extensions/issues/new?assignees=&labels=Provider+Request&template=provider-request.yml) with the name of the provider on the title, as well as a link to the provider in the body paragraph.
Make a new [issue](https://github.com/consumet/extensions/issues/new?assignees=&labels=provider+request&template=provider-request.yml) with the name of the provider on the title, as well as a link to the provider in the body paragraph.

## Contributing
Check out [contributing guide](https://github.com/consumet/extensions/blob/master/docs/guides/contributing.md) to get an overview of Consumet Extensions development.

## Support
Please join the [discord server](https://discord.gg/qTPfvMxzNH) to ask questions, get help, or report issues.

## Contributors
Thanks to the following people who have contributed to this repo:

[![](https://avatars.githubusercontent.com/u/57333995?s=50)](https://github.com/riimuru) [![](https://avatars.githubusercontent.com/u/80477926?s=50)](https://github.com/prince-ao)

## License
Licensed under [MIT](./LICENSE).
9 changes: 2 additions & 7 deletions docs/guides/anime.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<h2>ANIME</h2>

`ANIME` is a category provider, which provides a list of anime providers. Each anime provider must be a subclass of the [`AnimeParser`](https://github.com/consumet/extensions/blob/master/src/models/anime-parser.ts) class.

By using `ANIME` category you can interact with the anime providers. And have access to the anime providers methods.
By using `ANIME` category you can interact with the anime providers. And get access to the anime providers methods. Which allows you to search for anime, get the anime information, get the anime episodes with streaming links.

```ts
// ESM
Expand All @@ -17,10 +15,7 @@ const animeProvider = ANIME.<providerName>();
## Anime Providers List
This list is in alphabetical order. (except the sub bullet points)

- [AnimePahe](../providers/animepahe.md)
- [Gogoanime](../providers/gogoanime.md)
- [search](../providers/gogoanime.md#search)
- [fetchAnimeInfo](../providers/gogoanime.md#fetchanimeinfo)
- [fetchEpisodeSources](../providers/gogoanime.md#fetchepisodesources)
- [fetchEpisodeServers](../providers/gogoanime.md#fetchepisodeservers)

<p align="end">(<a href="https://github.com/consumet/extensions/blob/master/docs">back to table of contents</a>)</p>
4 changes: 1 addition & 3 deletions docs/guides/books.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<h2>BOOKS</h2>

`BOOKS` is a category provider, which provides a list of anime providers. Each anime provider must be a subclass of the [`BookParser`](https://github.com/consumet/extensions/blob/master/src/models/book-parsers.ts) class.

By using `BOOKS` category you can interact with the book providers. And have access to the book providers methods.
By using `BOOKS` category you can interact with the book providers. And have access to the book providers methods. Which allows you to search for books, get the book information, get the book pdf/epub links.

```ts
// ESM
Expand Down
4 changes: 1 addition & 3 deletions docs/guides/comics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<h2>COMICS</h2>

`COMICS` is a category provider, which provides a list of anime providers. Each anime provider must be a subclass of the [`ComicParser`](https://github.com/consumet/extensions/blob/master/src/models/comic-parsers.ts) class.

By using `COMICS` category you can interact with the book providers. And have access to the comic providers methods.
By using `COMICS` category you can interact with the book providers. And have access to the comic providers methods. Which allows you to search for comics, get the comic information, get the comic chapters with images to read.

```ts
// ESM
Expand Down
7 changes: 1 addition & 6 deletions docs/guides/light-novels.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<h2>LIGHT_NOVELS</h2>

`LIGHT_NOVELS` is a category provider, which provides a list of light novels providers. Each light novel provider must be a subclass of the [`LightNovelParser`](https://github.com/consumet/extensions/blob/master/src/models/lightnovel-parser.ts) class.

By using `LIGHT_NOVELS` category you can interact with the light novel providers. And have access to the light novel providers methods.
By using `LIGHT_NOVELS` category you can interact with the light novel providers. And have access to the light novel providers methods. Which allows you to search for light novels, get the light novel information, get the light novel chapters with text content to read.

```ts
// ESM
Expand All @@ -19,9 +17,6 @@ const lightnovelProvider = LIGHT_NOVELS.<providerName>();
This list is in alphabetical order. (except the sub bullet points)

- [ReadLightNovels](../providers/readlightnovels.md)
- [search](../providers/readlightnovels.md#search)
- [fetchLightNovelInfo](../providers/readlightnovels.md#fetchlightnovelinfo)
- [fetchChapterContent](../providers/readlightnovels.md#fetchchaptercontent)


<p align="end">(<a href="https://github.com/consumet/extensions/blob/master/docs">back to table of contents</a>)</p>
7 changes: 1 addition & 6 deletions docs/guides/manga.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<h2>MANGA</h2>

`MANGA` is a category provider, which provides a list of manga providers. Each manga provider must be a subclass of the [`MangaParser`](https://github.com/consumet/extensions/blob/master/src/models/manga-parser.ts) class.

By using `MANGA` category you can interact with the manga providers. And have access to the manga providers methods.
By using `MANGA` category you can interact with the manga providers. And have access to the manga providers methods. Which allows you to search for manga, get the manga information, get the manga chapters with images to read.

```ts
// ESM
Expand All @@ -18,9 +16,6 @@ const mangaProvider = MANGA.<providerName>();
This list is in alphabetical order. (except the sub bullet points)

- [MangaDex](../providers/mangadex.md)
- [search](../providers/mangadex.md#search)
- [fetchMangaInfo](../providers/mangadex.md#fetchmangainfo)
- [fetchChapterPages](../providers/mangadex.md#fetchchapterpages)


<p align="end">(<a href="https://github.com/consumet/extensions/blob/master/docs">back to table of contents</a>)</p>
8 changes: 1 addition & 7 deletions docs/guides/movies.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

<h2>MOVIES</h2>

`MOVIES` is a category provider, which provides a list of movies/tv series providers. Each movie/tv series provider must be a subclass of the [`MovieParser`](https://github.com/consumet/extensions/blob/master/src/models/movie-parser.ts) class.

By using `MOVIES` category you can interact with the movie providers. And have access to the movie providers methods.
By using `MOVIES` category you can interact with the movie providers. And have access to the movie providers methods. Which allows you to search for movies and shows, get the movie/tv series information, get the movie/tv series episodes with streaming links.

```ts
// ESM
Expand All @@ -18,9 +16,5 @@ const movieProvider = MOVIES.<providerName>();
This list is in alphabetical order. (except the sub bullet points)

- [FlixHQ](../providers/flixhq.md)
- [search](../providers/flixhq.md#search)
- [fetchMediaInfo](../providers/flixhq.md#fetchmediainfo)
- [fetchEpisodeSources](../providers/flixhq.md#fetchepisodesources)
- [fetchEpisodeServers](../providers/flixhq.md#fetchepisodeservers)

<p align="end">(<a href="https://github.com/consumet/extensions/blob/master/docs">back to table of contents</a>)</p>
147 changes: 147 additions & 0 deletions docs/providers/animepahe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
<h1>AnimePahe</h1>

```ts
const animepahe = new ANIME.AnimePahe();
```

<h2>Methods</h2>

- [search](#search)
- [fetchAnimeInfo](#fetchanimeinfo)
- [fetchEpisodeSources](#fetchepisodesources)

### search
> Note: This method is a subclass of the [`BaseParser`](https://github.com/consumet/extensions/blob/master/src/models/base-parser.ts) class. meaning it is available across most categories.

<h4>Parameters</h4>

| Parameter | Type | Description |
| --------- | -------- | ------------------------------------------------------------------------ |
| query | `string` | query to search for. (*In this case, We're searching for `Overlord IV`*) |

```ts
animepahe.search("Overlord IV").then(data => {
console.log(data);
}
```
returns a promise which resolves into an array of anime. (*[`Promise<ISearch<IAnimeResult[]>>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L13-L26)*)\
output:
```js
{
results: [
{
id: 'adb84358-8fec-fe80-1dc5-ad6218421dc1',
title: 'Overlord IV',
image: 'https://i.animepahe.com/posters/cb77e1e2a76b985a7c9d9b90a497fee65d89fa9c41d0e9e6fab4608d10313ddf.jpg',
rating: 8.3,
releaseDate: 2022,
type: 'TV'
},
{
id: 'a0d776d3-48d2-5487-971d-f5d8dada5c42',
title: 'Overlord',
image: 'https://i.animepahe.com/posters/e78bf21dfd4e382dbc985501edb0f57bda7d5305b87863fe8991a5e658c9c1a8.jpg',
rating: 7.92,
releaseDate: 2015,
type: 'TV'
},
{...}
...
]
}
```
### fetchAnimeInfo
<h4>Parameters</h4>
| Parameter | Type | Description |
| ---------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| id | `string` | takes anime id as a parameter. (*anime id can be found in the anime search results or anime info object*) |
| episodePage (optional) | `number` | takes episode page number as a parameter. default: -1 to get all episodes at once (*episodePages can be found in the anime info object*) |
```ts
animepahe.fetchAnimeInfo("adb84358-8fec-fe80-1dc5-ad6218421dc1").then(data => {
console.log(data);
}
```
returns a promise which resolves into an anime info object (including the episodes). (*[`Promise<IAnimeInfo>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L28-L42)*)\
output:
```js
{
id: 'adb84358-8fec-fe80-1dc5-ad6218421dc1',
title: 'Overlord IV',
image: 'https://i.animepahe.com/posters/cb77e1e2a76b985a7c9d9b90a497fee65d89fa9c41d0e9e6fab4608d10313ddf.jpg',
cover: 'https://i.animepahe.com/covers/cover_default3.jpg',
description: 'Fourth season of Overlord.',
genres: [ 'Action', 'Fantasy', 'Supernatural' ],
status: 'Ongoing',
type: 'TV',
releaseDate: 'Jul 05, 2022',
aired: 'Jul 05, 2022 to ?',
studios: [ 'Madhouse' ],
totalEpisodes: NaN, // NaN means that the anime is ongoing.
episodes: [
{
id: 'c673b4d6cedf5e4cd1900d30d61ee2130e23a74e58f4401a85f21a4e95c94f73',
number: 1,
title: '',
image: 'https://i.animepahe.com/snapshots/8b3499c66e59e4c266485b54b78ad8469a520d9957dbe5a117f8d0934a93817a.jpg',
duration: '00:23:40'
}
],
episodePages: 1 // 1 means that there is only one page of episodes.
}
```
### fetchEpisodeSources
<h4>Parameters</h4>
| Parameter | Type | Description |
| --------- | -------- | ------------------------------------------------------------------------------------- |
| episodeId | `string` | takes episode id as a parameter. (*episode id can be found in the anime info object*) |
In this example, we're getting the sources for the first episode of Overlord IV.
```ts
animepahe.fetchEpisodeSources("c673b4d6cedf5e4cd1900d30d61ee2130e23a74e58f4401a85f21a4e95c94f73").then(data => {
console.log(data);
}
```
returns a promise which resolves into an array of episode sources. (*[`Promise<ISource>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L210-L214)*)\
output:
```js
{
headers: { Referer: 'https://kwik.cx/' },
sources: [
{
url: 'https://na-191.files.nextcdn.org/hls/01/b49063a1225cf4350deb46d79b42a7572e323274d1c9d63f3b067cc4df09986a/uwu.m3u8',
isM3U8: true,
quality: '360',
size: 44617958
},
{
url: 'https://na-191.files.nextcdn.org/hls/01/c32da1b1975a5106dcee7e7182219f9b4dbef836fb782d7939003a8cde8f057f/uwu.m3u8',
isM3U8: true,
quality: '720',
size: 78630133
},
{
url: 'https://na-191.files.nextcdn.org/hls/01/b85d4450908232aa32b71bc67c80e8aedcc4f32a282e5df9ad82e4662786e9d8/uwu.m3u8',
isM3U8: true,
quality: '1080',
size: 118025148
}
]
}
```
Make sure to check the `headers` property of the returned object. It contains the referer header, which is needed to bypass the 403 error and allow you to stream the video without any issues.
<p align="end">(<a href="https://github.com/consumet/extensions/blob/master/docs/guides/anime.md#">back to anime providers list</a>)</p>
8 changes: 4 additions & 4 deletions docs/providers/flixhq.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ flixhq.search("Vincenzo").then(data => {
}
```
returns a promise which resolves into an array of movies/tv series. (*[`Promise<ISearch<IMovieResult[]>>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L233-L241)*)
returns a promise which resolves into an array of movies/tv series. (*[`Promise<ISearch<IMovieResult[]>>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L233-L241)*)\
output:
```js
{
Expand Down Expand Up @@ -62,7 +62,7 @@ flixhq.fetchMediaInfo("tv/watch-vincenzo-67955").then(data => {
}
```
returns a promise which resolves into an anime info object (including the episodes). (*[`Promise<IMovieInfo>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L243-L254)*)
returns a promise which resolves into an anime info object (including the episodes). (*[`Promise<IMovieInfo>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L243-L254)*)\
output:
```js
{
Expand Down Expand Up @@ -119,7 +119,7 @@ flixhq.fetchEpisodeSources("1167571", "tv/watch-vincenzo-67955").then(data => {
console.log(data);
}
```
returns a promise which resolves into an array of episode sources and subtitles. (*[`Promise<ISource>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L210-L214)*)
returns a promise which resolves into an array of episode sources and subtitles. (*[`Promise<ISource>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L210-L214)*)\
output:
```js
{
Expand Down Expand Up @@ -159,7 +159,7 @@ flixhq.fetchEpisodeServers('1167571', 'tv/watch-vincenzo-67955').then(data => {
console.log(data);
}
```
returns a promise which resolves into an array of episode servers. (*[`Promise<IEpisodeServer[]>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L54-L57)*)
returns a promise which resolves into an array of episode servers. (*[`Promise<IEpisodeServer[]>`](https://github.com/consumet/extensions/blob/master/src/models/types.ts#L54-L57)*)\
output:
```js
[
Expand Down
Loading

0 comments on commit 19fd07d

Please sign in to comment.