switched to guider

This commit is contained in:
mohitbkl
2024-04-15 12:07:48 +03:00
parent 89a78e4ae9
commit bd65ca0a9f
69 changed files with 2947 additions and 7912 deletions

3
.docs/pages/404.tsx Normal file
View File

@@ -0,0 +1,3 @@
import { createNotFoundPage } from '@neato/guider/client';
export default createNotFoundPage();

4
.docs/pages/_app.tsx Normal file
View File

@@ -0,0 +1,4 @@
import '@neato/guider/style.css';
import { createGuiderApp } from '@neato/guider/client';
export default createGuiderApp();

View File

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

View File

@@ -0,0 +1,24 @@
# `ProviderControls.getMetadata`
Get meta data for a scraper, can be either source or embed scraper.
Returns `null` if the `id` is not recognized.
## Example
```ts
const flixhqSource = providers.getMetadata('flixhq');
```
## Type
```ts
function getMetadata(id: string): MetaOutput | null;
type MetaOutput = {
type: 'embed' | 'source';
id: string;
rank: number;
name: string;
mediaTypes?: Array<MediaTypes>;
};
```

View File

@@ -0,0 +1,25 @@
# `ProviderControls.listEmbeds`
List all embed scrapers that are applicable for the target.
They are sorted by rank; highest first
## Example
```ts
const embedScrapers = providers.listEmbeds();
// Guaranteed to only return the type: 'embed'
```
## Type
```ts
function listEmbeds(): MetaOutput[];
type MetaOutput = {
type: 'embed' | 'source';
id: string;
rank: number;
name: string;
mediaTypes?: Array<MediaTypes>;
};
```

View File

@@ -0,0 +1,25 @@
# `ProviderControls.listSources`
List all source scrapers that are applicable for the target.
They are sorted by rank; highest first
## Example
```ts
const sourceScrapers = providers.listSources();
// Guaranteed to only return the type: 'source'
```
## Type
```ts
function listSources(): MetaOutput[];
type MetaOutput = {
type: 'embed' | 'source';
id: string;
rank: number;
name: string;
mediaTypes?: Array<MediaTypes>;
};
```

View File

@@ -0,0 +1,44 @@
# `ProviderControls.runEmbedScraper`
Run a specific embed scraper and get its emitted streams.
## Example
```ts
import { SourcererOutput } from '@movie-web/providers';
// scrape a stream from upcloud
let output: EmbedOutput;
try {
output = await providers.runEmbedScraper({
id: 'upcloud',
url: 'https://example.com/123',
})
} catch (err) {
console.log('failed to scrape')
return;
}
// output.stream now has your stream
```
## Type
```ts
function runEmbedScraper(runnerOps: SourceRunnerOptions): Promise<EmbedOutput>;
interface EmbedRunnerOptions {
// object of event functions
events?: IndividualScraperEvents;
// the embed URL
url: string;
// ID of the embed scraper you want to scrape from
id: string;
}
type EmbedOutput = {
stream: Stream;
};
```

View File

@@ -0,0 +1,66 @@
# `ProviderControls.runSourceScraper`
Run a specific source scraper and get its emitted streams.
## Example
```ts
import { ScrapeMedia , SourcererOutput, NotFoundError } from '@movie-web/providers';
// media from TMDB
const media : ScrapeMedia = {
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 does not 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;
};
```

View File

@@ -0,0 +1,3 @@
icon: ph:code-simple-fill
navigation.redirect: /api/makeproviders
navigation.title: "Api reference"

View File

@@ -0,0 +1,3 @@
import { createRedirect } from '@neato/guider/client';
export default createRedirect({ to: '/api-reference/makeProviders' });

View File

@@ -0,0 +1,34 @@
# `makeProviders`
Make an instance of provider controls with configuration.
This is the main entry-point of the library. It is recommended to make one instance globally and reuse it throughout your application.
## Example
```ts
import { targets, makeProviders, makeDefaultFetcher } from '@movie-web/providers';
const providers = makeProviders({
fetcher: makeDefaultFetcher(fetch),
target: targets.NATIVE, // target native app streams
});
```
## Type
```ts
function makeProviders(ops: ProviderBuilderOptions): ProviderControls;
interface ProviderBuilderOptions {
// instance of a fetcher, all webrequests are made with the fetcher.
fetcher: Fetcher;
// instance of a fetcher, in case the request has CORS restrictions.
// this fetcher will be called instead of normal fetcher.
// if your environment doesn't have CORS restrictions (like Node.JS), there is no need to set this.
proxiedFetcher?: Fetcher;
// target to get streams for
target: Targets;
}
```

View File

@@ -0,0 +1,23 @@
# `makeSimpleProxyFetcher`
Make a fetcher to use with [movie-web/simple-proxy](https://github.com/movie-web/simple-proxy). This is for making a proxiedFetcher, so you can run this library in the browser.
## Example
```ts
import { targets, makeProviders, makeDefaultFetcher, makeSimpleProxyFetcher } from '@movie-web/providers';
const proxyUrl = 'https://your.proxy.workers.dev/'
const providers = makeProviders({
fetcher: makeDefaultFetcher(fetch),
proxiedFetcher: makeSimpleProxyFetcher(proxyUrl, fetch),
target: targets.BROWSER,
});
```
## Type
```ts
function makeSimpleProxyFetcher(proxyUrl: string, fetchApi: typeof fetch): Fetcher;
```

View File

@@ -0,0 +1,20 @@
# `makeStandardFetcher`
Make a fetcher from a `fetch()` API. It is used for making an instance of provider controls.
## Example
```ts
import { targets, makeProviders, makeDefaultFetcher } from '@movie-web/providers';
const providers = makeProviders({
fetcher: makeStandardFetcher(fetch),
target: targets.ANY,
});
```
## Type
```ts
function makeStandardFetcher(fetchApi: typeof fetch): Fetcher;
```

View File

@@ -0,0 +1,74 @@
# Customize providers
You make the provider controls in two ways. Either with `makeProviders()` (the simpler option) or with `buildProviders()` (more elaborate and extensive option).
## `makeProviders()` (simple)
To know what to set the configuration to, you can read [How to use on X](./0.usage-on-x.md) for a detailed guide on how to configure your controls.
```ts
const providers = makeProviders({
// fetcher, every web request gets called through here
fetcher: makeStandardFetcher(fetch),
// proxied fetcher, if the scraper needs to access a CORS proxy. this fetcher will be called instead
// of the normal fetcher. Defaults to the normal fetcher.
proxiedFetcher: undefined;
// target of where the streams will be used
target: targets.NATIVE;
// Set this to true, if the requests will have the same IP as
// the device that the stream will be played on.
consistentIpForRequests: false;
})
```
## `buildProviders()` (advanced)
To know what to set the configuration to, you can read [How to use on X](./0.usage-on-x.md) for a detailed guide on how to configure your controls.
### Standard setup
```ts
const providers = buildProviders()
.setTarget(targets.NATIVE) // target of where the streams will be used
.setFetcher(makeStandardFetcher(fetch)) // fetcher, every web request gets called through here
.addBuiltinProviders() // add all builtin providers, if this is not called, no providers will be added to the controls
.build();
```
### Adding only select few providers
Not all providers are great quality, so you can make an instance of the controls with only the providers you want.
```ts
const providers = buildProviders()
.setTarget(targets.NATIVE) // target of where the streams will be used
.setFetcher(makeStandardFetcher(fetch)) // fetcher, every web request gets called through here
.addSource('showbox') // only add showbox source
.addEmbed('febbox-hls') // add febbox-hls embed, which is returned by showbox
.build();
```
### Adding your own scrapers to the providers
If you have your own scraper and still want to use the nice utilities of the provider library or just want to add on to the built-in providers, you can add your own custom source.
```ts
const providers = buildProviders()
.setTarget(targets.NATIVE) // target of where the streams will be used
.setFetcher(makeStandardFetcher(fetch)) // fetcher, every web request gets called through here
.addSource({ // add your own source
id: 'my-scraper',
name: 'My scraper',
rank: 800,
flags: [],
scrapeMovie(ctx) {
throw new Error('Not implemented');
}
})
.build();
```

View File

@@ -0,0 +1,74 @@
# Fetchers
When creating provider controls, a fetcher will need to be configured.
Depending on your environment, this can come with some considerations:
## Using `fetch()`
In most cases, you can use the `fetch()` API. This will work in newer versions of Node.js (18 and above) and on the browser.
```ts
const fetcher = makeStandardFetcher(fetch);
```
If you using older version of Node.js. You can use the npm package `node-fetch` to polyfill fetch:
```ts
import fetch from "node-fetch";
const fetcher = makeStandardFetcher(fetch);
```
## Using fetchers on the browser
When using this library on a browser, you will need a proxy. Browsers restrict when a web request can be made. To bypass those restrictions, you will need a CORS proxy.
The movie-web team has a proxy pre-made and pre-configured for you to use. For more information, check out [movie-web/simple-proxy](https://github.com/movie-web/simple-proxy). After installing, you can use this proxy like so:
```ts
const fetcher = makeSimpleProxyFetcher("https://your.proxy.workers.dev/", fetch);
```
If you aren't able to use this specific proxy and need to use a different one, you can make your own fetcher in the next section.
## Making a derived fetcher
In some rare cases, a custom fetcher is necessary. This can be quite difficult to make from scratch so it's recommended to base it off of an existing fetcher and building your own functionality around it.
```ts
export function makeCustomFetcher(): Fetcher {
const fetcher = makeStandardFetcher(f);
const customFetcher: Fetcher = (url, ops) => {
// Do something with the options and URL here
return fetcher(url, ops);
};
return customFetcher;
}
```
If you need to make your own fetcher for a proxy, ensure you make it compatible with the following headers: `Set-Cookie`, `Cookie`, `Referer`, `Origin`. Proxied fetchers need to be able to write/read those headers when making a request.
## Making a fetcher from scratch
In some rare cases, you need to make a fetcher from scratch.
This is the list of features it needs:
- Send/read every header
- Parse JSON, otherwise parse as text
- Send JSON, Formdata or normal strings
- get final destination URL
It's not recommended to do this at all. If you have to, you can base your code on the original implementation of `makeStandardFetcher`. Check out the [source code for it here](https://github.com/movie-web/providers/blob/dev/src/fetchers/standardFetch.ts).
Here is a basic template on how to make your own custom fetcher:
```ts
const myFetcher: Fetcher = (url, ops) => {
// Do some fetching
return {
body: {},
finalUrl: '',
headers: new Headers(), // should only contain headers from ops.readHeaders
statusCode: 200,
};
}
```

View File

@@ -0,0 +1,3 @@
import { createRedirect } from '@neato/guider/client';
export default createRedirect({ to: '/essentials/usage-on-x' });

View File

@@ -0,0 +1,14 @@
# Targets
When creating provider controls, you will immediately be required to choose a target.
<Warning>
A target is the device on which the stream will be played.
**Where the scraping is being run has nothing to do with the target**, only where the stream is finally played in the end is significant in choosing a target.
</Warning>
#### Possible targets
- **`targets.BROWSER`** Stream will be played in a browser with CORS
- **`targets.BROWSER_EXTENSION`** Stream will be played in a browser using the movie-web extension (WIP)
- **`targets.NATIVE`** Stream will be played on a native video player
- **`targets.ANY`** No restrictions for selecting streams, will just give all of them

View File

@@ -0,0 +1,72 @@
# How to use on X
The library can run in many environments, so it can be tricky to figure out how to set it up.
Here is a checklist. For more specific environments, keep reading below:
- When requests are very restricted (like browser client-side). Configure a proxied fetcher.
- When your requests come from the same device on which it will be streamed (not compatible with proxied fetcher). Set `consistentIpForRequests: true`.
- To set a target. Consult [Targets](./1.targets.md).
To make use of the examples below, check out the following pages:
- [Quick start](../1.get-started/1.quick-start.md)
- [Using streams](../2.essentials/4.using-streams.md)
## NodeJs server
```ts
import { makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
const providers = makeProviders({
fetcher: makeStandardFetcher(fetch),
target: chooseYourself, // check out https://movie-web.github.io/providers/essentials/targets
})
```
## Browser client-side
Using the provider package client-side requires a hosted version of simple-proxy.
Read more [about proxy fetchers](/essentials/fetchers#using-fetchers-on-the-browser).
```ts
import { makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
const proxyUrl = "https://your.proxy.workers.dev/";
const providers = makeProviders({
fetcher: makeStandardFetcher(fetch),
proxiedFetcher: makeSimpleProxyFetcher(proxyUrl, fetch),
target: target.BROWSER,
})
```
## React native
To use the library in a react native app, you would also need a couple of polyfills to polyfill crypto and base64.
<Steps>
<Steps.Step>
### First install the polyfills:
```sh npm2yarn
npm install @react-native-anywhere/polyfill-base64 react-native-quick-crypto
```
</Steps.Step>
<Steps.Step>
### Add the polyfills to your app:
```ts
// Import in your entry file
import '@react-native-anywhere/polyfill-base64';
```
And follow the [react-native-quick-crypto documentation](https://github.com/margelo/react-native-quick-crypto) to set up the crypto polyfill.
</Steps.Step>
<Steps.Step>
### Then you can use the library like this:
```ts
import { makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
const providers = makeProviders({
fetcher: makeStandardFetcher(fetch),
target: target.NATIVE,
consistentIpForRequests: true,
})
```
</Steps.Step>
</Steps>

View File

@@ -0,0 +1,84 @@
# Using streams
Streams can sometimes be quite picky on how they can be used. So here is a guide on how to use them.
## Essentials
All streams have the same common parameters :
- `Stream.type` : The type of stream. Either `hls` or `file`
- `Stream.id` : The id of this stream, unique per scraper output.
- `Stream.flags` : A list of flags that apply to this stream. Most people won't need to use it.
- `Stream.captions` : A list of captions/subtitles for this stream.
- `Stream.headers` : Either undefined or a key value object of headers you must set to use the stream.
- `Stream.preferredHeaders` : Either undefined or a key value object of headers you may want to set if you want optimal playback - but not required.
Now let's delve deeper into how to watch these streams!
## Streams with type `hls`
HLS streams can be tough to watch. They're not normal files you can just use.
These streams have an extra property `Stream.playlist` which contains the m3u8 playlist.
Here is a code sample of how to use HLS streams in web context using hls.js
```html
<script src="https ://cdn.jsdelivr.net/npm/hls.js@1"></script>
<video id="video"></video>
<script>
const stream = null; // add your stream here
if (Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource(stream.playlist);
hls.attachMedia(video);
}
</script>
```
## Streams with type `file`
File streams are quite easy to use, they just return a new property : `Stream.qualities`.
This property is a map of quality and a stream file. So if you want to get 1080p quality you do `stream["1080"]` to get your stream file. It will return undefined if that quality is absent.
The possibly qualities are : `unknown`, `360`, `480`, `720`, `1080`, `4k`.
File based streams are always guaranteed to have one quality.
Once you get a streamfile, you have the following parameters :
- `StreamFile.type` : Right now it can only be `mp4`.
- `StreamFile.url` : The URL linking to the video file.
Here is a code sample of how to watch a file based stream in a browser :
```html
<video id="video"></video>
<script>
const stream = null; // add your stream here
const video = document.getElementById('video');
const qualityEntries = Object.keys(stream.qualities);
const firstQuality = qualityEntries[0];
video.src = firstQuality.url;
</script>
```
## Streams with headers
Streams have both a `Stream.headers` and a `Stream.preferredHeaders`.
The difference between the two is that `Stream.headers` **must** be set in order for the stream to work. While the other is optional, and enhances the quality or performance.
If your target is set to `BROWSER`, headers will never be required, as it's not possible to do.
## Using captions/subtitles
All streams have a list of captions at `Stream.captions`. The structure looks like this :
```ts
type Caption = {
type : CaptionType; // Language type, either "srt" or "vtt"
id : string; // Unique per stream
url : string; // The URL pointing to the subtitle file
hasCorsRestrictions : boolean; // If true, you will need to proxy it if you're running in a browser
language : string; // Language code of the caption
};
```

View File

@@ -0,0 +1,72 @@
# Development / contributing
<Warning>
This page isn't quite done yet, stay tuned!
</Warning>
{/*
TODO
- Development setup
- How to make new sources/embeds (link to the page)
- How to use the fetchers, when to use proxiedFetcher
- How to use the context
*/}
## Testing using the CLI
Testing can be quite difficult for this library, unit tests can't really be made because of the unreliable nature of scrapers.
But manually testing by writing an entry-point is also really annoying.
Our solution is to make a CLI that you can use to run the scrapers. For everything else there are unit tests.
### Setup
Make a `.env` file in the root of the repository and add a TMDB API key: `MOVIE_WEB_TMDB_API_KEY=KEY_HERE`.
Then make sure you've run `npm i` to get all the dependencies.
### Mode 1 - interactive
To run the CLI without needing to learn all the arguments, simply run the following command and go with the flow.
```sh npm2yarn
npm run cli
```
### Mode 2 - arguments
For repeatability, it can be useful to specify the arguments one by one.
To see all the arguments, you can run the help command:
```sh
npm run cli -- -h
```
Then just run it with your arguments, for example:
```sh
npm run cli -- -sid showbox -tid 556574
```
### Examples
```sh
# Spirited away - showbox
npm run cli -- -sid showbox -tid 129
# Hamilton - flixhq
npm run cli -- -sid flixhq -tid 556574
# Arcane S1E1 - showbox
npm run cli -- -sid zoechip -tid 94605 -s 1 -e 1
# febbox mp4 - get streams from an embed (gotten from a source output)
npm run cli -- -sid febbox-mp4 -u URL_HERE
```
### Fetcher options
The CLI comes with a few built-in fetchers:
- `node-fetch` : Fetch using the "node-fetch" library.
- `native` : Use the new fetch built into Node.JS (undici).
- `browser` : Start up headless chrome, and run the library in that context using a proxied fetcher.
<Warning>
The browser fetcher will require you to run `npm run build` before running the CLI. Otherwise you will get outdated results.
</Warning>

View File

@@ -0,0 +1,3 @@
import { createRedirect } from '@neato/guider/client';
export default createRedirect({ to: '/in-depth/sources-vs-embeds' });

View File

@@ -0,0 +1,128 @@
---
title: 'Changelog'
---
# Version 2.3.0
- Fixed RidoMovies search results
- Added Insertunit, SoaperTV, and WarezCDN providers
- Disabled Showbox and VidSrc
# Version 2.2.9
- Fixed VidSrcTo (both Vidplay and Filemoon embeds)
- Added dropload, filelions and vtube embeds to Primewire
- Fixed and enabled Smashystream
- Improved RidoMovies search results
# Version 2.2.8
- Fix package exports for CJS and ESM
- Fixed Mixdrop embed
- Added thumbnailTrack to Vidplay embed
# Version 2.2.7
- Fix showbox
# Version 2.2.6
- Fix febbox
- Validate if a stream is actually playable. Streams that are not responding are no longer returned.
# Version 2.2.5
- Add Primewire provider
- Improve VidSrcTo search results
- Fixed Filemoon embeds
- Fixed febbox
- Disabled non-working providers
- Reordered providers in ranking
# Version 2.2.4
- Hotfix for HDRezka provider
# Version 2.2.3
- Fix VidSrcTo
- Add HDRezka provider
- Fix Goojara causing a crash
- Improve react-native URLSearchParams implementation
- Cover an edge case where the title contains 'the movie' or 'the show'
# Version 2.2.2
- Fix subtitles not appearing if the name of the subtitle is in its native tongue.
- Remove references to the old domain
- Fixed ridomovies not working for some shows and movies
- Fixed Showbox not working in react-native.
# Version 2.2.1
- Fixed Closeload scraper
# Version 2.2.0
- Fixed vidsrc.me URL decoding.
- Added ridomovies with Ridoo and Closeload embed.
- Added Goojara.to source.
- Fixed VidSrcTo crashing if no subtitles are found.
- Added Nepu Provider.
- Added vidcloud to flixhq and zoechip.
- Add thumbnail track option to response (Not supported by any providers yet).
- Disabled Lookmovie and swapped Showbox and VidSrcTo in ranking.
# Version 2.1.1
- Fixed vidplay decryption keys being wrong and switched the domain to one that works
# Version 2.1.0
- Add preferedHeaders to most sources
- Add CF_BLOCKED flag to sources that have blocked cloudflare API's
- Fix vidsrc sometimes having an equal sign where it shouldnt
- Increase ranking of lookmovie
- Re-enabled subtitles for febbox-mp4
# Version 2.0.5
- Disable subtitles for febbox-mp4. As their endpoint doesn't work anymore.
# Version 2.0.4
- Added providers:
- Add VidSrcTo provider with Vidplay and Filemoon embeds
- Add VidSrc provider with StreamBucket embeds
- Fixed providers:
- RemoteStream
- LookMovie - Fixed captions
- ShowBox
- Updated documentation to fix spelling + grammar
- User-agent header fix
- Needs the latest simple-proxy update
- Added utility to not return multiple subs for the same language - Applies to Lookmovie and Showbox
# Version 2.0.3
- Actually remove Febbox HLS
# Version 2.0.2
- Added Lookmovie caption support
- Fix Febbox duplicate subtitle languages
- Remove Febbox HLS
# Version 2.0.1
- Fixed issue where febbox-mp4 would not show all qualities
- Fixed issue where discoverEmbeds event would not show the embeds in the right order
# Version 2.0.0
<Warning>
There are breaking changes in this list, make sure to read them thoroughly if you plan on updating.
</Warning>
**Development tooling:**
- Added integration test for browser. To make sure the package keeps working in the browser
- Add type checking when building, previously it ignored them
- Refactored the main folder, now called entrypoint.
- Dev-cli code has been split up a bit more, a bit cleaner to navigate
- Dev-cli is now moved to `npm run cli`
- Dev-cli has now has support for running in a headless browser using a proxy URL.
- Fetchers can now return a full response with headers and everything
**New features:**
- Added system to allow scraping IP locked sources through the consistentIpforRequests option.
- There is now a `buildProviders()` function that gives a builder for the `ProviderControls`. It's an alternative to `makeProviders()`.
- Streams can now return a headers object and a `preferredHeaders` object. which is required and optional headers for when using the stream.
**Notable changes:**
- Renamed the NO_CORS flag to CORS_ALLOWED (meaning that resource sharing is allowed)
- Export Fetcher and Stream types with all types related to it
- Providers can now return a list of streams instead of just one.
- Captions now have identifiers returned with them. Just generally useful to have
- New targets and some of them renamed

View File

@@ -0,0 +1,7 @@
---
title: 'Examples'
---
<Note>
Coming soon
</Note>

View File

@@ -0,0 +1,3 @@
import { createRedirect } from '@neato/guider/client';
export default createRedirect({ to: '/get-started/introduction' });

View File

@@ -0,0 +1,16 @@
---
title: 'Introduction'
---
## What is `@movie-web/providers` ?
`@movie-web/providers` is the soul of [movie-web](https://github.com/movie-web/movie-web). It's a collection of scrapers of various streaming sites. It extracts the raw streams from those sites, so you can watch them without any extra fluff from the original sites.
## What can I use this on?
We support many different environments, here are a few examples:
- In browser, watch streams without needing a server to scrape (does need a proxy)
- In a native app, scrape in the app itself
- In a backend server, scrape on the server and give the streams to the client to watch.
To find out how to configure the library for your environment, You can read [How to use on X](/essentials/usage-on-x).

View File

@@ -0,0 +1,71 @@
---
title: 'Quick Start'
---
## Installation
Let's get started with `@movie-web/providers`. First lets install the package.
```sh npm2yarn
npm 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.
<Important>
This snippet will only work on a **server**. For other environments, check out [Usage on X](/essentials/usage-on-x).
</Important>
```ts title="index.ts (server)" showLineNumbers
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. You now have an instance of the providers you can reuse everywhere.
Now let's scrape an item:
```ts title="index.ts (server)" showLineNumbers
import { ScrapeMedia, makeProviders, makeStandardFetcher, targets } from '@movie-web/providers';
const myFetcher = makeStandardFetcher(fetch);
const providers = makeProviders({
fetcher: myFetcher,
target: targets.NATIVE
});
const media: ScrapeMedia = {
type: 'movie',
title: "Oppenheimer",
releaseYear: 2023,
tmdbId: "872585"
};
async function fetchData() {
try {
const output = await providers.runAll({
media: media,
});
console.log("Output:",output)
} catch (error) {
console.error('Error occurred:', error);
}
}
fetchData();
```
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](/essentials/using-streams).

View File

@@ -0,0 +1,10 @@
# Flags
Flags is the primary way the library separates entities between different environments.
For example, some sources only give back content that has the CORS headers set to allow anyone, so that source gets the flag `CORS_ALLOWED`. Now if you set your target to `BROWSER`, sources without that flag won't even get listed.
This concept is applied in multiple away across the library.
## Flag options
- `CORS_ALLOWED` : Headers from the output streams are set to allow any origin.
- `IP_LOCKED` : The streams are locked by IP: requester and watcher must be the same.

View File

@@ -0,0 +1,3 @@
import { createRedirect } from '@neato/guider/client';
export default createRedirect({ to: '/in-depth/sources-vs-embeds' });

View File

@@ -0,0 +1,12 @@
# New providers
<Warning>
This page isn't quite done yet, stay tuned!
</Warning>
{/*
TODO
- How to make new sources or embeds
- Ranking
- Link to flags
*/}

View File

@@ -0,0 +1,11 @@
# Sources vs embeds
<Warning>
This page isn't quite done yet, stay tuned!
</Warning>
{/*
TODO
- How do sources and embeds differ
- How do sources and embeds interact
*/}

42
.docs/pages/index.tsx Normal file
View File

@@ -0,0 +1,42 @@
import {
Button,
Card,
CardGrid,
GuiderLayout,
Hero,
} from '@neato/guider/client';
export default function LandingPage() {
return (
<GuiderLayout meta={{ layout: 'page' }}>
<Hero>
<Hero.Badge title="V2.3.0" to="/get-started/changelog">
See changelog for more
</Hero.Badge>
<Hero.Title>@movie-web/providers</Hero.Title>
<Hero.Subtitle>
Easily scrape all sorts of media sites for content.
</Hero.Subtitle>
<Hero.Actions>
<Button to="/get-started/introduction">Get Started</Button>
<Button to="https://github.com/movie-web/providers" type="secondary">
Open on GitHub
</Button>
</Hero.Actions>
</Hero>
<CardGrid>
<Card icon="mdi:code-json" title="Scrape popular streaming websites.">
Don&apos;t settle for just one media site for you content, use
everything that&apos;s available.
</Card>
<Card icon="mdi:git" title="Multi-platform.">
Scrape from browser or server, whichever you prefer.
</Card>
<Card icon="mdi:language-typescript" title="Easy to use.">
Get started with scraping your favourite media sites with just 5 lines
of code. Fully typed of course.
</Card>
</CardGrid>
</GuiderLayout>
);
}