movie-web/src/backend/helpers/provider.ts

37 lines
854 B
TypeScript
Raw Normal View History

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