implemented theflix scrapers + better search component

Co-authored-by: James Hawkins <jhawki2005@gmail.com>
This commit is contained in:
Jelle van Snik 2022-02-17 18:24:21 +01:00
parent 5ddd8638ec
commit 80cad8f8f2

30
src/scrapers/wrapper.ts Normal file
View File

@ -0,0 +1,30 @@
import { MWMedia, MWMediaProvider, MWPortableMedia, MWQuery } from "./types";
export interface MWWrappedMediaProvider extends MWMediaProvider {
getMediaFromPortable(media: MWPortableMedia): Promise<MWMedia>;
searchForMedia(query: MWQuery): Promise<MWMedia[]>;
}
export function WrapProvider(
provider: MWMediaProvider
): MWWrappedMediaProvider {
return {
...provider,
async getMediaFromPortable(media: MWPortableMedia): Promise<MWMedia> {
return {
...(await provider.getMediaFromPortable(media)),
providerId: provider.id,
mediaType: media.mediaType,
};
},
async searchForMedia(query: MWQuery): Promise<MWMedia[]> {
return (await provider.searchForMedia(query)).map<MWMedia>((m) => ({
...m,
providerId: provider.id,
mediaType: query.type,
}));
},
};
}