providers/.docs/content/1.Get Started/1.quick-start.md

1.2 KiB

Quick start

  • Prerequisites
  • Install
  • Scrape first item

Let's get started with @movie-web/providers. First lets install the package.

::code-group

npm install @movie-web/providers
yarn add @movie-web/providers
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.

import { makeProviders, makeDefaultFetcher, targets } from '@movie-web/providers';

// 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,

  // will be played on a native video player
  target: targets.NATIVE
})

Perfect, now we can start scraping a stream:

// 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}`)