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

feat: new meta provider #14

Merged
merged 4 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ANIME, BOOKS, COMICS, LIGHT_NOVELS, MANGA, MOVIES } from './providers';
import { ANIME, BOOKS, COMICS, LIGHT_NOVELS, MANGA, MOVIES, META } from './providers';
import { PROVIDERS_LIST } from './utils/providers-list';

export { ANIME, BOOKS, COMICS, MANGA, LIGHT_NOVELS, MOVIES };
export { ANIME, BOOKS, COMICS, MANGA, LIGHT_NOVELS, MOVIES, META };
export { PROVIDERS_LIST };
12 changes: 6 additions & 6 deletions src/models/anime-parser.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { BaseParser } from '.';
import { BaseParser, IAnimeInfo, ISource, IEpisodeServer } from '.';

abstract class AnimeParser extends BaseParser {
/**
* takes anime link or id
* takes anime id
*
* returns anime info
* returns anime info (including episodes)
*/
protected abstract fetchAnimeInfo(animeUrl: string): Promise<unknown>;
abstract fetchAnimeInfo(animeid: string, ...args: any): Promise<IAnimeInfo>;

/**
* takes episode id
*
* returns episode sources (video links)
*/
protected abstract fetchEpisodeSources(episodeId: string, ...args: any): Promise<unknown>;
abstract fetchEpisodeSources(episodeId: string, ...args: any): Promise<ISource>;

/**
* takes episode link
*
* returns episode servers (video links) available
*/
protected abstract fetchEpisodeServers(episodeLink: string): Promise<unknown>;
abstract fetchEpisodeServers(episodeLink: string): Promise<IEpisodeServer[]>;
}

export default AnimeParser;
2 changes: 1 addition & 1 deletion src/models/base-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abstract class BaseParser extends BaseProvider {
*
* returns a promise resolving to a data object
*/
protected abstract search(query: string, ...args: any[]): Promise<unknown>;
abstract search(query: string, ...args: any[]): Promise<unknown>;
}

export default BaseParser;
2 changes: 1 addition & 1 deletion src/models/lightnovel-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ abstract class LightNovelParser extends BaseParser {
/**
* takes light novel link or id
*
* returns lightNovel info
* returns lightNovel info (including chapters)
*/
protected abstract fetchLightNovelInfo(lightNovelUrl: string, ...args: any): Promise<unknown>;

Expand Down
2 changes: 1 addition & 1 deletion src/models/movie-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class MovieParser extends BaseParser {
/**
* takes media link or id
*
* returns media info
* returns media info (including episodes)
*/
protected abstract fetchMediaInfo(mediaUrl: string): Promise<unknown>;

Expand Down
25 changes: 13 additions & 12 deletions src/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ export interface IProviderStats {
isWorking: boolean;
}

export interface ITitle {
romaji?: string;
english?: string;
native?: string;
userPreferred?: string;
}

export interface IAnimeResult {
id: string;
title: string;
url: string;
title: string | ITitle;
url?: string;
image?: string;
releaseDate?: string;
[x: string]: unknown; // other fields
Expand All @@ -25,20 +32,14 @@ export interface ISearch<T> {
results: T[];
}

export interface IAnimeInfo {
id: string;
title: string;
url?: string;
image?: string;
releaseDate?: string;
export interface IAnimeInfo extends IAnimeResult {
genres?: string[];
description?: string;
type?: string;
status?: MediaStatus;
totalEpisodes?: number;
subOrDub?: SubOrSub;
episodes?: IAnimeEpisode[];
[x: string]: unknown; // other fields
}

export interface IAnimeEpisode {
Expand Down Expand Up @@ -100,7 +101,7 @@ export enum SubOrSub {

export interface IMangaResult {
id: string;
title: string | [lang: string][];
title: string | [lang: string][] | ITitle;
altTitles?: string | [lang: string][];
image?: string;
description?: string | [lang: string][] | { [lang: string]: string };
Expand Down Expand Up @@ -131,7 +132,7 @@ export interface IMangaChapterPage {

export interface ILightNovelResult {
id: string;
title: string;
title: string | ITitle;
url: string;
image?: string;
[x: string]: unknown; // other fields
Expand Down Expand Up @@ -238,7 +239,7 @@ export interface IMovieEpisode {

export interface IMovieResult {
id: string;
title: string;
title: string | ITitle;
url: string;
image?: string;
releaseDate?: string;
Expand Down
6 changes: 4 additions & 2 deletions src/providers/anime/9anime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
MediaStatus,
SubOrSub,
IAnimeResult,
IEpisodeServer,
ISource,
} from '../../models';

/**
Expand Down Expand Up @@ -186,11 +188,11 @@ class NineAnime extends AnimeParser {
}
}

override async fetchEpisodeSources(episodeLink: string): Promise<void> {
override async fetchEpisodeSources(episodeLink: string): Promise<ISource> {
throw new Error('Method not implemented.');
}

override async fetchEpisodeServers(episodeLink: string): Promise<void> {
override async fetchEpisodeServers(episodeLink: string): Promise<IEpisodeServer[]> {
throw new Error('Method not implemented.');
}

Expand Down
5 changes: 3 additions & 2 deletions src/providers/anime/animepahe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
IAnimeResult,
ISource,
IAnimeEpisode,
IEpisodeServer,
} from '../../models';
import { Kwik } from '../../utils';

class AnimePahe extends AnimeParser {
override readonly name = 'AnimePahe';
protected override baseUrl = 'https://animepahe.com';
protected override logo = 'hhttps://animepahe.com/pikacon.ico';
protected override logo = 'https://animepahe.com/pikacon.ico';
protected override classPath = 'ANIME.AnimePahe';

/**
Expand Down Expand Up @@ -192,7 +193,7 @@ class AnimePahe extends AnimeParser {
* @deprecated
* @attention AnimePahe doesn't support this method
*/
override fetchEpisodeServers = (episodeLink: string): Promise<unknown> => {
override fetchEpisodeServers = (episodeLink: string): Promise<IEpisodeServer[]> => {
throw new Error('Method not implemented.');
};
}
Expand Down
1 change: 1 addition & 0 deletions src/providers/anime/gogoanime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class Gogoanime extends AnimeParser {
url: `${this.baseUrl}/${$(el).find(`a`).attr('href')?.trim()}`,
});
});
animeInfo.episodes = animeInfo.episodes.reverse();

animeInfo.totalEpisodes = parseInt(ep_end ?? '0');

Expand Down
3 changes: 2 additions & 1 deletion src/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ import LIGHT_NOVELS from './light-novels';
import BOOKS from './books';
import COMICS from './comics';
import MOVIES from './movies';
import META from './meta';

export { ANIME, MANGA, BOOKS, COMICS, LIGHT_NOVELS, MOVIES };
export { ANIME, MANGA, BOOKS, COMICS, LIGHT_NOVELS, MOVIES, META };
Loading