This commit is contained in:
mrjvs
2023-09-27 19:00:40 +02:00
parent 78507a24c8
commit de63979e4d
17 changed files with 428 additions and 45 deletions

View File

@@ -18,44 +18,36 @@ Let's get started with `@movie-web/providers`. First lets install the package.
To get started with scraping on the **server**, first you have to make an instance of the providers.
::code-group
```ts [index.ts (server)]
import { makeProviders, makeDefaultFetcher, targets } from '@movie-web/providers';
```ts
import { makeProviders, makeDefaultFetcher, targets } from '@movie-web/providers';
// this is how the library will make http requests
const myFetcher = makeDefaultFetcher(fetch);
// this is how the library will make http requests
const myFetcher = makeDefaultFetcher(fetch);
// make an instance of the providers library
const providers = makeProviders({
fetcher: myFetcher,
// make an instance of the providers library
const providers = makeProviders({
fetcher: myFetcher,
// will be played on a native video player
target: targets.NATIVE
})
```
::
// will be played on a native video player
target: targets.NATIVE
})
```
Perfect, now we can start scraping a stream:
::code-group
```ts [index.ts (server)]
// fetch some data from TMDB
const media = {
type: 'movie',
title: "Hamilton",
releaseYear: 2020,
tmdbId: "556574"
}
const output = await providers.runAll({
media: media
})
```ts [index.ts (server)]
// fetch some data from TMDB
const media = {
type: 'movie',
title: "Hamilton",
releaseYear: 2020,
tmdbId: "556574"
}
const output = await providers.runAll({
media: media
})
if (!output) console.log("No stream found")
console.log(`stream url: ${output.stream.playlist}`)
```
::
::alert{type="info"}
Thats it! Next up: [check out some examples](/examples).
::
if (!output) console.log("No stream found")
console.log(`stream url: ${output.stream.playlist}`)
```