mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 13:43:25 +00:00
spelling/grammar
This commit is contained in:
@@ -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)
|
||||
|
||||
|
@@ -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.
|
||||
::
|
||||
|
||||
|
@@ -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:
|
||||
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
};
|
||||
|
Reference in New Issue
Block a user