mirror of
https://github.com/movie-web/movie-web.git
synced 2024-11-13 08:15:06 +01:00
implemented theflix scrapers + better search component
Co-authored-by: James Hawkins <jhawki2005@gmail.com>
This commit is contained in:
parent
5ddd8638ec
commit
80cad8f8f2
30
src/scrapers/wrapper.ts
Normal file
30
src/scrapers/wrapper.ts
Normal 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,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user