Add development CLI to docs
This commit is contained in:
parent
2d68d443ec
commit
17662b01b9
|
@ -10,5 +10,63 @@ TODO
|
|||
- 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 of contributions
|
||||
-->
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
### 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
|
||||
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 -
|
||||
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 nodejs (undici).
|
||||
- `browser`: Start up headless chrome, and run the library in that context using a proxied fetcher.
|
||||
|
||||
::alert{type="warning"}
|
||||
The browser fetcher will require you to run `npm run build` before running the CLI. Otherwise you will get outdated results.
|
||||
::
|
||||
|
|
Loading…
Reference in New Issue