mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 18:13:25 +00:00
Start building a provider scrape system
This commit is contained in:
@@ -1,5 +1 @@
|
|||||||
import { LOG } from '@/testing/oof';
|
export { ProviderBuilderOptions, Providers, makeProviders } from '@/main/builder';
|
||||||
|
|
||||||
export function test() {
|
|
||||||
console.log(LOG);
|
|
||||||
}
|
|
||||||
|
16
src/main/builder.ts
Normal file
16
src/main/builder.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { Fetcher } from '@/utils/fetcher';
|
||||||
|
|
||||||
|
export interface ProviderBuilderOptions {
|
||||||
|
// fetcher, every web request gets called through here
|
||||||
|
fetcher: Fetcher;
|
||||||
|
|
||||||
|
// proxied fetcher, if the scraper needs to access a CORS proxy. this fetcher will be called instead
|
||||||
|
// of the normal fetcher. Defaults to the normal fetcher.
|
||||||
|
proxiedFetcher?: Fetcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Providers {}
|
||||||
|
|
||||||
|
export function makeProviders(ops: ProviderBuilderOptions): Providers {
|
||||||
|
return {};
|
||||||
|
}
|
3
src/providers/all.ts
Normal file
3
src/providers/all.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { Sourcerer } from '@/providers/base';
|
||||||
|
|
||||||
|
export const sources: Array<Sourcerer | null> = [];
|
14
src/providers/base.ts
Normal file
14
src/providers/base.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { ScrapeContext } from '@/utils/context';
|
||||||
|
|
||||||
|
export type Sourcerer = {
|
||||||
|
id: string;
|
||||||
|
name: string; // displayed in the UI
|
||||||
|
rank: number; // the higher the number, the earlier it gets put on the queue
|
||||||
|
disabled?: boolean;
|
||||||
|
scrape: (input: ScrapeContext) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function makeSourcerer(state: Sourcerer): Sourcerer | null {
|
||||||
|
if (state.disabled) return null;
|
||||||
|
return state;
|
||||||
|
}
|
0
src/providers/embeds/.gitkeep
Normal file
0
src/providers/embeds/.gitkeep
Normal file
0
src/providers/sources/.gitkeep
Normal file
0
src/providers/sources/.gitkeep
Normal file
18
src/providers/streams.ts
Normal file
18
src/providers/streams.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export type StreamFile = {
|
||||||
|
type: 'mp4';
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Qualities = '360' | '480' | '720' | '1080';
|
||||||
|
|
||||||
|
export type FileBasedStream = {
|
||||||
|
type: 'file';
|
||||||
|
qualities: Record<Qualities, StreamFile>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type HlsBasedStream = {
|
||||||
|
type: 'hls';
|
||||||
|
playlist: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Stream = FileBasedStream | HlsBasedStream;
|
@@ -1 +0,0 @@
|
|||||||
export const LOG = 'hello world';
|
|
6
src/utils/context.ts
Normal file
6
src/utils/context.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { Fetcher } from '@/utils/fetcher';
|
||||||
|
|
||||||
|
export interface ScrapeContext {
|
||||||
|
proxiedFetcher: Fetcher;
|
||||||
|
fetcher: Fetcher;
|
||||||
|
}
|
11
src/utils/fetcher.ts
Normal file
11
src/utils/fetcher.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export type FetcherOptions = {
|
||||||
|
baseUrl?: string;
|
||||||
|
headers?: Record<string, string>;
|
||||||
|
query?: Record<string, string>;
|
||||||
|
method?: 'GET' | 'POST';
|
||||||
|
body?: Record<string, any> | string | FormData;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Fetcher<T = any> = {
|
||||||
|
(url: string, ops?: FetcherOptions): T;
|
||||||
|
};
|
Reference in New Issue
Block a user