mirror of
https://github.com/sussy-code/smov.git
synced 2025-01-01 16:37:39 +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
1 changed files with 30 additions and 0 deletions
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 a new issue