providers/.docs/content/5.api-reference/1.ProviderControlsRunAll.md

62 lines
1.3 KiB
Markdown
Raw Normal View History

2023-09-27 17:00:40 +00:00
# `ProviderControls.runAll`
2023-09-27 18:51:54 +00:00
Run all providers one by one in order of their built-in ranking.
2023-12-31 03:35:48 +00:00
You can attach events if you need to know what is going on while it is processing.
2023-09-27 17:00:40 +00:00
## Example
```ts
// media from TMDB
const media = {
type: 'movie',
2023-12-29 16:47:49 +00:00
title: 'Hamilton',
2023-09-27 17:00:40 +00:00
releaseYear: 2020,
2023-12-29 16:47:49 +00:00
tmdbId: '556574'
2023-09-27 17:00:40 +00:00
}
// scrape a stream
const stream = await providers.runAll({
media: media,
})
// scrape a stream, but prioritize flixhq above all
2023-12-31 03:35:48 +00:00
// (other scrapers are still run if flixhq fails, it just has priority)
2023-09-27 17:00:40 +00:00
const flixhqStream = await providers.runAll({
media: media,
sourceOrder: ['flixhq']
})
```
## Type
```ts
function runAll(runnerOps: RunnerOptions): Promise<RunOutput | null>;
interface RunnerOptions {
2023-12-31 03:35:48 +00:00
// overwrite the order of sources to run. List of IDs
// any omitted IDs are added to the end in order of rank (highest first)
2023-09-27 17:00:40 +00:00
sourceOrder?: string[];
2023-12-31 03:35:48 +00:00
// overwrite the order of embeds to run. List of IDs
// any omitted IDs are added to the end in order of rank (highest first)
2023-09-27 17:00:40 +00:00
embedOrder?: string[];
// object of event functions
events?: FullScraperEvents;
// the media you want to see sources from
media: ScrapeMedia;
}
type RunOutput = {
2023-12-31 03:35:48 +00:00
// source scraper ID
2023-09-27 17:00:40 +00:00
sourceId: string;
2023-12-31 03:35:48 +00:00
// if from an embed, this is the embed scraper ID
2023-09-27 17:00:40 +00:00
embedId?: string;
2023-12-31 03:35:48 +00:00
// the emitted stream
2023-09-27 17:00:40 +00:00
stream: Stream;
};
```