movie-web/src/backend/helpers/provider.ts
2023-01-22 19:26:08 +01:00

37 lines
854 B
TypeScript

import { DetailedMeta } from "../metadata/getmeta";
import { MWMediaType } from "../metadata/types";
import { MWEmbed } from "./embed";
import { MWStream } from "./streams";
export type MWProviderScrapeResult = {
stream?: MWStream;
embeds: MWEmbed[];
};
type MWProviderBase = {
progress(percentage: number): void;
media: DetailedMeta;
};
type MWProviderTypeSpecific =
| {
type: MWMediaType.MOVIE | MWMediaType.ANIME;
episode?: undefined;
season?: undefined;
}
| {
type: MWMediaType.SERIES;
episode: string;
season: string;
};
export type MWProviderContext = MWProviderTypeSpecific & MWProviderBase;
export type MWProvider = {
id: string;
displayName: string;
rank: number;
disabled?: boolean;
type: MWMediaType[];
scrape(ctx: MWProviderContext): Promise<MWProviderScrapeResult>;
};