Skip to content

Commit

Permalink
feat (anilist): added fetch trending anime method
Browse files Browse the repository at this point in the history
  • Loading branch information
riimuru committed Aug 4, 2022
1 parent 81a80e6 commit a3227ee
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 8 deletions.
1 change: 1 addition & 0 deletions dist/providers/meta/anilist.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ declare class Anilist extends AnimeParser {
fetchEpisodeServers: (episodeId: string) => Promise<IEpisodeServer[]>;
private findAnime;
private findAnimeSlug;
fetchTrendingAnime: (page?: number, perPage?: number) => Promise<ISearch<IAnimeResult>>;
private findAnimeRaw;
}
export default Anilist;
45 changes: 45 additions & 0 deletions dist/providers/meta/anilist.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/meta/anilist.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/utils/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GogoCDN, StreamSB, VidCloud, MixDrop, Kwik, RapidCloud, StreamTape, VizCloud } from './extractors';
import { USER_AGENT, splitAuthor, floorID, formatTitle, genElement, capitalizeFirstLetter, anilistSearchQuery, anilistMediaDetailQuery, kitsuSearchQuery, range } from './utils';
import { USER_AGENT, splitAuthor, floorID, formatTitle, genElement, capitalizeFirstLetter, anilistSearchQuery, anilistMediaDetailQuery, kitsuSearchQuery, range, anilistTrendingAnimeQuery } from './utils';
import { parsePostInfo } from './getComics';
import { countDivs } from './zLibrary';
export { USER_AGENT, GogoCDN, StreamSB, splitAuthor, floorID, formatTitle, parsePostInfo, genElement, capitalizeFirstLetter, countDivs, VidCloud, MixDrop, Kwik, anilistSearchQuery, anilistMediaDetailQuery, kitsuSearchQuery, range, RapidCloud, StreamTape, VizCloud, };
export { USER_AGENT, GogoCDN, StreamSB, splitAuthor, floorID, formatTitle, parsePostInfo, genElement, capitalizeFirstLetter, countDivs, VidCloud, MixDrop, Kwik, anilistSearchQuery, anilistMediaDetailQuery, kitsuSearchQuery, range, RapidCloud, StreamTape, VizCloud, anilistTrendingAnimeQuery, };
3 changes: 2 additions & 1 deletion dist/utils/index.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/utils/index.js.map

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

1 change: 1 addition & 0 deletions dist/utils/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export declare const range: ({ from, to, step, length }: {
export declare const capitalizeFirstLetter: (s: string) => string;
export declare const anilistSearchQuery: (query: string, page: number, perPage: number) => string;
export declare const anilistMediaDetailQuery: (id: string) => string;
export declare const anilistTrendingAnimeQuery: (page?: number, perPage?: number) => string;
export declare const kitsuSearchQuery: (query: string) => string;
4 changes: 3 additions & 1 deletion dist/utils/utils.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/utils/utils.js.map

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

64 changes: 64 additions & 0 deletions docs/providers/anilist.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const anilist = new META.Anilist();
<h2>Methods</h2>

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

Expand Down Expand Up @@ -66,6 +67,69 @@ output:
}
```
### fetchTrendingAnime
<h4>Parameters</h4>
| Parameter | Type | Description |
| ------------------ | -------- | --------------------------- |
| page (optional) | `number` | page number to search for. |
| perPage (optional) | `number` | number of results per page. |
```ts
anilist.fetchTrendingAnime().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:
```ts
{
currentPage: 1,
hasNextPage: true,
results: [
{
id: '153288',
malId: null,
title: {
romaji: 'Kaijuu 8-gou',
english: 'Kaiju No.8',
native: '怪獣8号',
userPreferred: 'Kaijuu 8-gou'
},
image: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx153288-INFE21hHhAUD.jpg',
trailer: {
id: '-MaTda-Ws3Y',
site: 'youtube',
thumbnail: 'https://i.ytimg.com/vi/-MaTda-Ws3Y/hqdefault.jpg'
},
cover: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx153288-INFE21hHhAUD.jpg',
rating: null,
releaseDate: null,
totalEpisodes: 0,
duration: null,
score: null,
type: null
},
{
id: '130592',
malId: 48413,
title: {...}
image: 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx130592-LAUlhx15mxQu.jpg',
trailer: {...},
cover: 'https://s4.anilist.co/file/anilistcdn/media/anime/banner/130592-WPfrW1SR4dnY.jpg',
rating: 74,
releaseDate: 2022,
totalEpisodes: 12,
duration: 24,
score: 75,
type: 'TV'
},
]
}
```
### fetchAnimeInfo
<h4>Parameters</h4>
Expand Down
Loading

0 comments on commit a3227ee

Please sign in to comment.