mirror of
https://github.com/p-stream/providers.git
synced 2026-01-11 20:10:33 +00:00
Delete mal.ts
This commit is contained in:
parent
c6f259bd3d
commit
86eba4b5bd
1 changed files with 0 additions and 48 deletions
|
|
@ -1,48 +0,0 @@
|
|||
import { flags } from '@/entrypoint/utils/targets';
|
||||
import { Sourcerer, SourcererEmbed, makeSourcerer } from '@/providers/base';
|
||||
import { MovieScrapeContext, ShowScrapeContext } from '@/utils/context';
|
||||
import { getMalIdFromMedia } from '@/utils/mal';
|
||||
|
||||
export type MalSourceOptions = {
|
||||
id: string;
|
||||
name: string;
|
||||
rank: number;
|
||||
embedIds: string[];
|
||||
flags?: Array<(typeof flags)[keyof typeof flags]>;
|
||||
};
|
||||
|
||||
export function makeMalSource(opts: MalSourceOptions): Sourcerer {
|
||||
async function comboScraper(ctx: ShowScrapeContext | MovieScrapeContext) {
|
||||
const malId = await getMalIdFromMedia(ctx, ctx.media);
|
||||
|
||||
const query: any = {
|
||||
type: ctx.media.type,
|
||||
title: ctx.media.title,
|
||||
tmdbId: ctx.media.tmdbId,
|
||||
imdbId: ctx.media.imdbId,
|
||||
malId,
|
||||
...(ctx.media.type === 'show' && {
|
||||
season: ctx.media.season.number,
|
||||
episode: ctx.media.episode.number,
|
||||
}),
|
||||
...(ctx.media.type === 'movie' && { episode: 1 }),
|
||||
releaseYear: ctx.media.releaseYear,
|
||||
};
|
||||
|
||||
const embeds: SourcererEmbed[] = opts.embedIds.map((embedId) => ({
|
||||
embedId,
|
||||
url: JSON.stringify(query),
|
||||
}));
|
||||
|
||||
return { embeds };
|
||||
}
|
||||
|
||||
return makeSourcerer({
|
||||
id: opts.id,
|
||||
name: opts.name,
|
||||
rank: opts.rank,
|
||||
flags: (opts.flags ?? [flags.CORS_ALLOWED]) as Array<(typeof flags)[keyof typeof flags]>,
|
||||
scrapeMovie: comboScraper,
|
||||
scrapeShow: comboScraper,
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue