spelling/grammar

This commit is contained in:
Paul Dee 2023-12-31 03:35:48 +00:00
parent ac3dfb98e1
commit 1296915a42
17 changed files with 63 additions and 63 deletions

View File

@ -21,7 +21,7 @@ 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.
::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).
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)]
@ -39,8 +39,8 @@ const providers = makeProviders({
})
```
Perfect, this instance of the providers you can reuse everywhere where you need to.
Now lets actually scrape an item:
Perfect. You now have an instance of the providers you can reuse everywhere.
Now let's scrape an item:
```ts [index.ts (server)]
// fetch some data from TMDB

View File

@ -22,7 +22,7 @@ There are breaking changes in this list, make sure to read them thoroughly if yo
- 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.
- 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.

View File

@ -2,12 +2,12 @@
The library can run in many environments, so it can be tricky to figure out how to set it up.
So here is a checklist, for more specific environments, keep reading below:
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 it will be streamed on (Not compatible with proxied fetcher). Set `consistentIpForRequests: true`.
- 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, You check check out the following pages:
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)

View File

@ -3,7 +3,7 @@
When creating provider controls, you will immediately be required to choose a target.
::alert{type="warning"}
A target is the device where the stream will be played on.
A target is the device on which the stream will be played.
**Where the scraping is run has nothing to do with the target**, only where the stream is finally played in the end is significant in choosing a target.
::

View File

@ -1,7 +1,7 @@
# Fetchers
When creating provider controls, it will need you to configure a fetcher.
This comes with some considerations depending on the environment youre running.
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.
@ -19,7 +19,7 @@ const fetcher = makeStandardFetcher(fetch);
```
## Using fetchers on the browser
When using this library on a browser, you will need a proxy. Browsers come with many restrictions on when a web request can be made, and to bypass those restrictions, you will need a cors proxy.
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:
@ -31,13 +31,13 @@ If you aren't able to use this specific proxy and need to use a different one, y
## Making a derived fetcher
In some rare cases, a custom fetcher will need to be made. This can be quite difficult to do from scratch so it's recommended to base it off an existing fetcher and building your own functionality around it.
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
// Do something with the options and URL here
return fetcher(url, ops);
};
@ -45,19 +45,19 @@ export function makeCustomFetcher(): Fetcher {
}
```
If you need to make your own fetcher for a proxy. Make sure 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.
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 even rare cases, you need to make one completely 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
- get final destination URL
It's not recommended to do this at all, but if you have to. You can base your code on the original implementation of `makeStandardFetcher`. Check the out [source code for it here](https://github.com/movie-web/providers/blob/dev/src/fetchers/standardFetch.ts).
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:

View File

@ -1,6 +1,6 @@
# Customize providers
You make a provider controls in two ways. Either with `makeProviders()` (the simpler option) or with `buildProviders()` (more elaborate and extensive option).
You make the provider controls in two ways. Either with `makeProviders()` (the simpler option) or with `buildProviders()` (more elaborate and extensive option).
## `makeProviders()` (simple)
@ -41,7 +41,7 @@ const providers = buildProviders()
### Adding only select few providers
Not all providers are great quality, so you can make a instance of the controls with only the providers you want.
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()
@ -55,7 +55,7 @@ const providers = buildProviders()
### Adding your own scrapers to the providers
If you have your own scraper and still want to use the nice utils of the provider library or just want to add on to the builtin providers. You can add your own custom source.
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()

View File

@ -12,11 +12,11 @@ All streams have the same common parameters:
- `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 actually watch these streams!
Now let's delve deeper into how to watch these streams!
## Streams with type `hls`
HLS streams can be tough to watch, it's not a normal file you can just use.
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
@ -39,17 +39,17 @@ Here is a code sample of how to use HLS streams in web context using hls.js
## Streams with type `file`
File streams are quite easy to use, it just returns 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 there is no quality like that.
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 garuanteed to always have one quality.
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 the video in a browser:
Here is a code sample of how to watch a file based stream in a browser:
```html
<video id="video"></video>
@ -66,9 +66,9 @@ Here is a code sample of how to watch a file based stream the video in a browser
## 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 other for the stream to work. While the other one is optional, and can only enhance the quality or performance.
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`. There will never be required headers, as it's not possible to do.
If your target is set to `BROWSER`, headers will never be required, as it's not possible to do.
## Using captions/subtitles
@ -77,7 +77,7 @@ All streams have a list of captions at `Stream.captions`. The structure looks li
type Caption = {
type: CaptionType; // Language type, either "srt" or "vtt"
id: string; // Unique per stream
url: string; // The url pointing to the subtitle file
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

@ -1,10 +1,10 @@
# Flags
Flags is the primary way the library seperates 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.
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.
- `IP_LOCKED`: The streams are locked by IP: requester and watcher must be the same.

View File

@ -15,13 +15,13 @@ TODO
## 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 entrypoint is also really annoying.
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.
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 ran `npm i` to get all the dependencies.
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

View File

@ -1,7 +1,7 @@
# `makeProviders`
Make an instance of provider controls with configuration.
This is the main entrypoint of the library. It is recommended to make one instance globally and reuse it throughout your application.
This is the main entry-point of the library. It is recommended to make one instance globally and reuse it throughout your application.
## Example
@ -23,9 +23,9 @@ 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.
// instance of a fetcher, in case the request has CORS restrictions.
// this fetcher will be called instead of normal fetcher.
// if your environment doesnt have cors restrictions (like Node.JS), there is no need to set this.
// 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

View File

@ -1,7 +1,7 @@
# `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 its processing.
You can attach events if you need to know what is going on while it is processing.
## Example
@ -20,7 +20,7 @@ const stream = await providers.runAll({
})
// scrape a stream, but prioritize flixhq above all
// (other scrapers are stil ran if flixhq fails, it just has priority)
// (other scrapers are still run if flixhq fails, it just has priority)
const flixhqStream = await providers.runAll({
media: media,
sourceOrder: ['flixhq']
@ -33,12 +33,12 @@ const flixhqStream = await providers.runAll({
function runAll(runnerOps: RunnerOptions): Promise<RunOutput | null>;
interface RunnerOptions {
// overwrite the order of sources to run. list of ids
// any omitted ids are in added to the end in order of rank (highest first)
// 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 in added to the end in order of rank (highest first)
// 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
@ -49,13 +49,13 @@ interface RunnerOptions {
}
type RunOutput = {
// source scraper id
// source scraper ID
sourceId: string;
// if from an embed, this is the embed scraper id
// if from an embed, this is the embed scraper ID
embedId?: string;
// the outputed stream
// the emitted stream
stream: Stream;
};
```

View File

@ -1,6 +1,6 @@
# `ProviderControls.runSourceScraper`
Run a specific source scraper and get its outputted streams.
Run a specific source scraper and get its emitted streams.
## Example
@ -24,7 +24,7 @@ try {
})
} catch (err) {
if (err instanceof NotFoundError) {
console.log('source doesnt have this media');
console.log('source does not have this media');
} else {
console.log('failed to scrape')
}
@ -48,13 +48,13 @@ interface SourceRunnerOptions {
// the media you want to see sources from
media: ScrapeMedia;
// id of the source scraper you want to scrape from
// 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
// embed ID is a reference to an embed scraper
embeds: {
embedId: string;
url: string;

View File

@ -1,6 +1,6 @@
# `ProviderControls.runEmbedScraper`
Run a specific embed scraper and get its outputted streams.
Run a specific embed scraper and get its emitted streams.
## Example
@ -31,10 +31,10 @@ interface EmbedRunnerOptions {
// object of event functions
events?: IndividualScraperEvents;
// the embed url
// the embed URL
url: string;
// id of the embed scraper you want to scrape from
// ID of the embed scraper you want to scrape from
id: string;
}

View File

@ -1,13 +1,13 @@
# `ProviderControls.listSources`
List all source scrapers that applicable for the target.
They are sorted by rank, highest first
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 type: 'source'
// Guaranteed to only return the type: 'source'
```
## Type

View File

@ -1,13 +1,13 @@
# `ProviderControls.listEmbeds`
List all embed scrapers that applicable for the target.
They are sorted by rank, highest first
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 type: 'embed'
// Guaranteed to only return the type: 'embed'
```
## Type

View File

@ -1,7 +1,7 @@
# `ProviderControls.getMetadata`
Get meta data for a scraper, can be either source or embed scraper.
Returns null if the `id` is not recognized.
Returns `null` if the `id` is not recognized.
## Example

View File

@ -1,6 +1,6 @@
# `makeStandardFetcher`
Make a fetcher from a `fetch()` API. It is used for making a instance of provider controls.
Make a fetcher from a `fetch()` API. It is used for making an instance of provider controls.
## Example