providers/.docs/content/4.extra-topics/0.development.md

73 lines
2.0 KiB
Markdown
Raw Normal View History

2023-12-26 22:35:58 +00:00
# Development / contributing
2023-12-29 15:59:30 +00:00
::alert{type="warning"}
This page isn't quite done yet, stay tuned!
::
<!--
TODO
2023-12-26 22:35:58 +00:00
- 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
2023-12-29 15:59:30 +00:00
-->
2023-12-29 16:22:09 +00:00
## 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.
2023-12-31 03:35:48 +00:00
But manually testing by writing an entry-point is also really annoying.
2023-12-29 16:22:09 +00:00
2023-12-31 03:35:48 +00:00
Our solution is to make a CLI that you can use to run the scrapers. For everything else there are unit tests.
2023-12-29 16:22:09 +00:00
### Setup
2023-12-31 03:35:48 +00:00
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.
2023-12-29 16:22:09 +00:00
### 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
2023-12-29 16:47:49 +00:00
# febbox mp4 - get streams from an embed (gotten from a source output)
2023-12-29 16:22:09 +00:00
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.
2023-12-29 16:51:21 +00:00
- `native`: Use the new fetch built into Node.JS (undici).
2023-12-29 16:22:09 +00:00
- `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.
::