mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 15:03:26 +00:00
Redo folder structure
This commit is contained in:
60
.docs/content/1.get-started/1.quick-start.md
Normal file
60
.docs/content/1.get-started/1.quick-start.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Quick start
|
||||
|
||||
## Installation
|
||||
|
||||
Let's get started with `@movie-web/providers`. First lets install the package.
|
||||
|
||||
::code-group
|
||||
```bash [NPM]
|
||||
npm install @movie-web/providers
|
||||
```
|
||||
```bash [Yarn]
|
||||
yarn add @movie-web/providers
|
||||
```
|
||||
```bash [PNPM]
|
||||
pnpm install @movie-web/providers
|
||||
```
|
||||
::
|
||||
|
||||
## Scrape your first item
|
||||
|
||||
To get started with scraping on the **server**, first you have to make an instance of the providers.
|
||||
|
||||
::alert{type="warning"}
|
||||
This snippet will only work on a **server**, for other environments, check out [Usage on X](../2.essentials/0.usage-on-x.md).
|
||||
::
|
||||
|
||||
```ts [index.ts (server)]
|
||||
import { makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
|
||||
|
||||
// this is how the library will make http requests
|
||||
const myFetcher = makeStandardFetcher(fetch);
|
||||
|
||||
// make an instance of the providers library
|
||||
const providers = makeProviders({
|
||||
fetcher: myFetcher,
|
||||
|
||||
// will be played on a native video player
|
||||
target: targets.NATIVE
|
||||
})
|
||||
```
|
||||
|
||||
Perfect, this instance of the providers you can reuse everywhere where you need to.
|
||||
Now lets actually scrape an item:
|
||||
|
||||
```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
|
||||
})
|
||||
```
|
||||
|
||||
Now we have our stream in the output variable. (If the output is `null` then nothing could be found.)
|
||||
To find out how to use the streams, check out [Using streams](../2.essentials/4.using-streams.md).
|
Reference in New Issue
Block a user