mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 18:13:25 +00:00
remove dots from filenames
This commit is contained in:
66
.docs/content/2.Api/2.ProviderControlsrunSourceScraper.md
Normal file
66
.docs/content/2.Api/2.ProviderControlsrunSourceScraper.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# `ProviderControls.runSourceScraper`
|
||||
|
||||
Run a specific source scraper and get its outputted streams.
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import { SourcererOutput, NotFoundError } from "@movie-web/providers";
|
||||
|
||||
// media from TMDB
|
||||
const media = {
|
||||
type: 'movie',
|
||||
title: "Hamilton",
|
||||
releaseYear: 2020,
|
||||
tmdbId: "556574"
|
||||
}
|
||||
|
||||
// scrape a stream from flixhq
|
||||
let output: SourcererOutput;
|
||||
try {
|
||||
output = await providers.runSourceScraper({
|
||||
id: 'flixhq',
|
||||
media: media,
|
||||
})
|
||||
} catch (err) {
|
||||
if (err instanceof NotFoundError) {
|
||||
console.log("source doesnt have this media");
|
||||
} else {
|
||||
console.log("failed to scrape")
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!output.stream && output.embeds.length === 0) {
|
||||
console.log("no streams found");
|
||||
}
|
||||
```
|
||||
|
||||
## Type
|
||||
|
||||
```ts
|
||||
function runSourceScraper(runnerOps: SourceRunnerOptions): Promise<SourcererOutput>;
|
||||
|
||||
interface SourceRunnerOptions {
|
||||
// object of event functions
|
||||
events?: IndividualScraperEvents;
|
||||
|
||||
// the media you want to see sources from
|
||||
media: ScrapeMedia;
|
||||
|
||||
// id of the source scraper you want to scrape from
|
||||
id: string;
|
||||
}
|
||||
|
||||
type SourcererOutput = {
|
||||
// list of embeds that the source scraper found.
|
||||
// embed id is a reference to an embed scraper
|
||||
embeds: {
|
||||
embedId: string;
|
||||
url: string;
|
||||
}[];
|
||||
|
||||
// the stream that the scraper found
|
||||
stream?: Stream;
|
||||
};
|
||||
```
|
Reference in New Issue
Block a user