aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/doc
diff options
context:
space:
mode:
Diffstat (limited to 'support/doc')
-rw-r--r--support/doc/api/embeds.md2
-rw-r--r--support/doc/api/openapi.yaml4
-rw-r--r--support/doc/development/lib.md2
-rw-r--r--support/doc/development/localization.md2
-rw-r--r--support/doc/development/monitoring.md4
-rw-r--r--support/doc/development/server.md66
-rw-r--r--support/doc/development/tests.md15
-rw-r--r--support/doc/plugins/guide.md43
-rw-r--r--support/doc/tools.md286
9 files changed, 171 insertions, 253 deletions
diff --git a/support/doc/api/embeds.md b/support/doc/api/embeds.md
index fd5507e38..989c8e98e 100644
--- a/support/doc/api/embeds.md
+++ b/support/doc/api/embeds.md
@@ -20,7 +20,7 @@ yarn add @peertube/embed-api
20Now just use the `PeerTubePlayer` class exported by the module: 20Now just use the `PeerTubePlayer` class exported by the module:
21 21
22```typescript 22```typescript
23import { PeerTubePlayer } from '@peertube/embed-api' 23import { PeerTubePlayer } from '@peertube/embed-api.js'
24 24
25... 25...
26``` 26```
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index 0cbc58678..5d54a7a51 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -53,7 +53,7 @@ info:
53 } 53 }
54 ``` 54 ```
55 55
56 We provide error `type` values for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/server/server-error-code.enum.ts), 56 We provide error `type` values for [a growing number of cases](https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/server/server-error-code.enum.ts),
57 but it is still optional. Types are used to disambiguate errors that bear the same status code 57 but it is still optional. Types are used to disambiguate errors that bear the same status code
58 and are non-obvious: 58 and are non-obvious:
59 59
@@ -8752,7 +8752,7 @@ components:
8752 password: 8752 password:
8753 $ref: '#/components/schemas/password' 8753 $ref: '#/components/schemas/password'
8754 UpdateMe: 8754 UpdateMe:
8755 # see shared/models/users/user-update-me.model.ts: 8755 # see packages/models/users/user-update-me.model.ts:
8756 properties: 8756 properties:
8757 password: 8757 password:
8758 $ref: '#/components/schemas/password' 8758 $ref: '#/components/schemas/password'
diff --git a/support/doc/development/lib.md b/support/doc/development/lib.md
index 25fe3068e..1ea09f2bc 100644
--- a/support/doc/development/lib.md
+++ b/support/doc/development/lib.md
@@ -18,7 +18,7 @@ The complete types package is generated via:
18 18
19``` 19```
20npm run generate-types-package 4.x.x 20npm run generate-types-package 4.x.x
21cd packages/types/dist 21cd packages/types-generator/dist
22npm publish --access=public 22npm publish --access=public
23``` 23```
24 24
diff --git a/support/doc/development/localization.md b/support/doc/development/localization.md
index a38ed6f55..4aca9b18b 100644
--- a/support/doc/development/localization.md
+++ b/support/doc/development/localization.md
@@ -26,7 +26,7 @@ Nothing to do here, Github will automatically send a webhook to Weblate that wil
26 26
27## Support a new language 27## Support a new language
28 28
29 * Add it to [/shared/models/i18n/i18n.ts](/shared/models/i18n/i18n.ts) 29 * Add it to [/packages/models/i18n/i18n.ts](/packages/models/i18n/i18n.ts)
30 * Add it to [/scripts/build/client.sh](/scripts/build/client.sh) 30 * Add it to [/scripts/build/client.sh](/scripts/build/client.sh)
31 * Add it to [/client/angular.json](/client/angular.json) 31 * Add it to [/client/angular.json](/client/angular.json)
32 * Add it to [/scripts/i18n/update.sh](/scripts/i18n/update.sh) 32 * Add it to [/scripts/i18n/update.sh](/scripts/i18n/update.sh)
diff --git a/support/doc/development/monitoring.md b/support/doc/development/monitoring.md
index 93fd1403e..023be9e92 100644
--- a/support/doc/development/monitoring.md
+++ b/support/doc/development/monitoring.md
@@ -13,11 +13,11 @@ npm run build -- --analyze-bundle && npm run client-report
13To benchmark the REST API and save result in `benchmark.json`: 13To benchmark the REST API and save result in `benchmark.json`:
14 14
15``` 15```
16node dist/scripts/benchmark.js -o benchmark.json 16npm run benchmark-server -- -o benchmark.json
17``` 17```
18 18
19You can also grep on a specific test: 19You can also grep on a specific test:
20 20
21``` 21```
22node dist/scripts/benchmark.js --grep homepage 22npm run benchmark-server -- --grep homepage
23``` 23```
diff --git a/support/doc/development/server.md b/support/doc/development/server.md
index 7a9fa571f..5c83af704 100644
--- a/support/doc/development/server.md
+++ b/support/doc/development/server.md
@@ -1,11 +1,11 @@
1# Server code 1 # Server code
2 2
3## Database model typing 3## Database model typing
4 4
5Sequelize models contain optional fields corresponding to table joins. 5Sequelize models contain optional fields corresponding to table joins.
6For example, `VideoModel` has a `VideoChannel?: VideoChannelModel` field. It can be filled if the SQL query joined with the `videoChannel` table or empty if not. 6For example, `VideoModel` has a `VideoChannel?: VideoChannelModel` field. It can be filled if the SQL query joined with the `videoChannel` table or empty if not.
7It can be difficult in TypeScript to understand if a function argument expects associations to be filled or not. 7It can be difficult in TypeScript to understand if a function argument expects associations to be filled or not.
8To improve clarity and reduce bugs, PeerTube defines multiple versions of a database model depending on its associations in `server/types/models/`. 8To improve clarity and reduce bugs, PeerTube defines multiple versions of a database model depending on its associations in `server/server/types/models/`.
9These models start with `M` and by default do not include any association. `MVideo` for example corresponds to `VideoModel` without any association, where `VideoChannel` attribute doesn't exist. On the other hand, `MVideoWithChannel` is a `MVideo` that has a `VideoChannel` field. This way, a function that accepts `video: MVideoWithChannel` argument expects a video with channel populated. Main PeerTube code should never use `...Model` (`VideoModel`) database type, but always `M...` instead (`MVideo`, `MVideoChannel` etc). 9These models start with `M` and by default do not include any association. `MVideo` for example corresponds to `VideoModel` without any association, where `VideoChannel` attribute doesn't exist. On the other hand, `MVideoWithChannel` is a `MVideo` that has a `VideoChannel` field. This way, a function that accepts `video: MVideoWithChannel` argument expects a video with channel populated. Main PeerTube code should never use `...Model` (`VideoModel`) database type, but always `M...` instead (`MVideo`, `MVideoChannel` etc).
10 10
11## Add a new feature walkthrough 11## Add a new feature walkthrough
@@ -16,67 +16,67 @@ Some of these may be optional (for example your new endpoint may not need to sen
16 * Configuration: 16 * Configuration:
17 - Add you new configuration key in `config/default.yaml` and `config/production.yaml` 17 - Add you new configuration key in `config/default.yaml` and `config/production.yaml`
18 - If you configuration needs to be different in dev or tests environments, also update `config/dev.yaml` and `config/test.yaml` 18 - If you configuration needs to be different in dev or tests environments, also update `config/dev.yaml` and `config/test.yaml`
19 - Load your configuration in `server/initializers/config.ts` 19 - Load your configuration in `server/server/initializers/config.ts`
20 - Check new configuration keys are set in `server/initializers/checker-before-init.ts` 20 - Check new configuration keys are set in `server/server/initializers/checker-before-init.ts`
21 - You can also ensure configuration consistency in `server/initializers/checker-after-init.ts` 21 - You can also ensure configuration consistency in `server/server/initializers/checker-after-init.ts`
22 - If you want your configuration to be available in the client: 22 - If you want your configuration to be available in the client:
23 + Add your field in `shared/models/server/server-config.model.ts` 23 + Add your field in `packages/models/server/server/server-config.model.ts`
24 + Update `server/lib/server-config-manager.ts` to include your new configuration 24 + Update `server/server/lib/server-config-manager.ts` to include your new configuration
25 - If you want your configuration to be updatable by the web admin in the client: 25 - If you want your configuration to be updatable by the web admin in the client:
26 + Add your field in `shared/models/server/custom-config.model.ts` 26 + Add your field in `packages/models/server/server/custom-config.model.ts`
27 + Add the configuration to the config object in the `server/controllers/api/config.ts` controller 27 + Add the configuration to the config object in the `server/server/controllers/api/config.ts` controller
28 * Controllers: 28 * Controllers:
29 - Create the controller file and fill it with your REST API routes 29 - Create the controller file and fill it with your REST API routes
30 - Import and use your controller in the parent controller 30 - Import and use your controller in the parent controller
31 * Middlewares: 31 * Middlewares:
32 - Create your validator middleware in `server/middlewares/validators` that will be used by your controllers 32 - Create your validator middleware in `server/server/middlewares/validators` that will be used by your controllers
33 - Add your new middleware file `server/middlewares/validators/index.ts` so it's easier to import 33 - Add your new middleware file `server/server/middlewares/validators/index.ts` so it's easier to import
34 - Create the entry in `server/types/express.d.ts` to attach the database model loaded by your middleware to the express response 34 - Create the entry in `server/server/types/express.d.ts` to attach the database model loaded by your middleware to the express response
35 * Validators: 35 * Validators:
36 - Create your validators that will be used by your middlewares in `server/helpers/custom-validators` 36 - Create your validators that will be used by your middlewares in `server/server/helpers/custom-validators`
37 * Typescript models: 37 * Typescript models:
38 - Create the API models (request parameters or response) in `shared/models` 38 - Create the API models (request parameters or response) in `packages/models`
39 - Add your models in `index.ts` of current directory to facilitate the imports 39 - Add your models in `index.ts` of current directory to facilitate the imports
40 * Sequelize model (BDD): 40 * Sequelize model (BDD):
41 - If you need to create a new table: 41 - If you need to create a new table:
42 + Create the Sequelize model in `server/models/`: 42 + Create the Sequelize model in `server/server/models/`:
43 * Create the `@Column` 43 * Create the `@Column`
44 * Add some indexes if you need 44 * Add some indexes if you need
45 * Create static methods to load a specific from the database `loadBy...` 45 * Create static methods to load a specific from the database `loadBy...`
46 * Create static methods to load a list of models from the database `listBy...` 46 * Create static methods to load a list of models from the database `listBy...`
47 * Create the instance method `toFormattedJSON` that creates the JSON to send to the REST API from the model 47 * Create the instance method `toFormattedJSON` that creates the JSON to send to the REST API from the model
48 + Add your new Sequelize model to `server/initializers/database.ts` 48 + Add your new Sequelize model to `server/server/initializers/database.ts`
49 + Create a new file in `server/types` to define multiple versions of your Sequelize model depending on database associations 49 + Create a new file in `server/server/types` to define multiple versions of your Sequelize model depending on database associations
50 + Add this new file to `server/types/*/index.ts` to facilitate the imports 50 + Add this new file to `server/server/types/*/index.ts` to facilitate the imports
51 + Create database migrations: 51 + Create database migrations:
52 * Create the migration file in `server/initializers/migrations` using raw SQL (copy the same SQL query as at PeerTube startup) 52 * Create the migration file in `server/server/initializers/migrations` using raw SQL (copy the same SQL query as at PeerTube startup)
53 * Update `LAST_MIGRATION_VERSION` in `server/initializers/constants.ts` 53 * Update `LAST_MIGRATION_VERSION` in `server/server/initializers/constants.ts`
54 - If updating database schema (adding/removing/renaming a column): 54 - If updating database schema (adding/removing/renaming a column):
55 + Update the sequelize models in `server/models/` 55 + Update the sequelize models in `server/server/models/`
56 + Add migrations: 56 + Add migrations:
57 * Create the migration file in `initializers/migrations` using Sequelize Query Interface (`.addColumn`, `.dropTable`, `.changeColumn`) 57 * Create the migration file in `initializers/migrations` using Sequelize Query Interface (`.addColumn`, `.dropTable`, `.changeColumn`)
58 * Update `LAST_MIGRATION_VERSION` in `server/initializers/constants.ts` 58 * Update `LAST_MIGRATION_VERSION` in `server/server/initializers/constants.ts`
59 * Notifications: 59 * Notifications:
60 - Create the new notification model in `shared/models/users/user-notification.model.ts` 60 - Create the new notification model in `packages/models/users/user-notification.model.ts`
61 - Create the notification logic in `server/lib/notifier/shared`: 61 - Create the notification logic in `server/server/lib/notifier/shared`:
62 + Email subject has a common prefix (defined by the admin in PeerTube configuration) 62 + Email subject has a common prefix (defined by the admin in PeerTube configuration)
63 - Add your notification to `server/lib/notifier/notifier.ts` 63 - Add your notification to `server/server/lib/notifier/notifier.ts`
64 - Create the email template in `server/lib/emails`: 64 - Create the email template in `server/server/lib/emails`:
65 + A text version is automatically generated from the HTML 65 + A text version is automatically generated from the HTML
66 + The template usually extends `../common/grettings` that already says "Hi" and "Cheers". You just have to write the title and the content blocks that will be inserted in the appropriate places in the HTML template 66 + The template usually extends `../common/grettings` that already says "Hi" and "Cheers". You just have to write the title and the content blocks that will be inserted in the appropriate places in the HTML template
67 - If you need to associate a new table with `userNotification`: 67 - If you need to associate a new table with `userNotification`:
68 + Associate the new table in `UserNotificationModel` (don't forget the index) 68 + Associate the new table in `UserNotificationModel` (don't forget the index)
69 + Add the object property in the API model definition (`shared/models/users/user-notification.model.ts`) 69 + Add the object property in the API model definition (`packages/models/users/user-notification.model.ts`)
70 + Add the object in `UserNotificationModel.toFormattedJSON` 70 + Add the object in `UserNotificationModel.toFormattedJSON`
71 + Handle this new notification type in client (`UserNotificationsComponent`) 71 + Handle this new notification type in client (`UserNotificationsComponent`)
72 + Handle the new object property in client model (`UserNotification`) 72 + Handle the new object property in client model (`UserNotification`)
73 * Tests: 73 * Tests:
74 - Create your command class in `shared/server-commands/` that will wrap HTTP requests to your new endpoint 74 - Create your command class in `packages/server-commands/` that will wrap HTTP requests to your new endpoint
75 - Add your command file in `index.ts` of current directory 75 - Add your command file in `index.ts` of current directory
76 - Instantiate your command class in `shared/server-commands/server/server.ts` 76 - Instantiate your command class in `packages/server-commands/server/server/server.ts`
77 - Create your test file in `server/tests/api/check-params` to test middleware validators/authentification/user rights (offensive tests) 77 - Create your test file in `server/server/tests/api/check-params` to test middleware validators/authentification/user rights (offensive tests)
78 - Add it to `server/tests/api/check-params/index.ts` 78 - Add it to `server/server/tests/api/check-params/index.ts`
79 - Create your test file in `server/tests/api` to test your new endpoints 79 - Create your test file in `server/server/tests/api` to test your new endpoints
80 - Add it to `index.ts` of current directory 80 - Add it to `index.ts` of current directory
81 - Add your notification test in `server/tests/api/notifications` 81 - Add your notification test in `server/server/tests/api/notifications`
82 * Update REST API documentation in `support/doc/api/openapi.yaml` 82 * Update REST API documentation in `support/doc/api/openapi.yaml`
diff --git a/support/doc/development/tests.md b/support/doc/development/tests.md
index 1c2589c8a..2e4c6ff6a 100644
--- a/support/doc/development/tests.md
+++ b/support/doc/development/tests.md
@@ -8,7 +8,7 @@ Prepare PostgreSQL user so PeerTube can delete/create the test databases:
8sudo -u postgres createuser you_username --createdb --superuser 8sudo -u postgres createuser you_username --createdb --superuser
9``` 9```
10 10
11Prepare databases: 11Prepare the databases:
12 12
13```bash 13```bash
14npm run clean:server:test 14npm run clean:server:test
@@ -45,22 +45,19 @@ sudo apt-get install parallel libimage-exiftool-perl
45 45
46### Test 46### Test
47 47
48To run all test suites: 48To run all test suites (can be long!):
49 49
50```bash 50```bash
51npm run test # See scripts/test.sh to run a particular suite 51npm run test # See scripts/test.sh to run a particular suite
52``` 52```
53 53
54Most of tests can be run using: 54To run a specific test:
55 55
56```bash 56```bash
57TS_NODE_TRANSPILE_ONLY=true npm run mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/videos/video-transcoder.ts 57npm run mocha -- --exit --bail packages/tests/src/your-test.ts
58```
59
60`server/tests/api/activitypub` tests will need different options:
61 58
62``` 59# For example
63TS_NODE_FILES=true mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/activitypub/security.ts 60npm run mocha -- --exit --bail packages/tests/src/api/videos/single-server.ts
64``` 61```
65 62
66### Configuration 63### Configuration
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index ff08ce8c4..07f484934 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -387,7 +387,7 @@ function register (...) {
387 displayName: 'User display name', 387 displayName: 'User display name',
388 388
389 // Custom admin flags (bypass video auto moderation etc.) 389 // Custom admin flags (bypass video auto moderation etc.)
390 // https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/users/user-flag.model.ts 390 // https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/users/user-flag.model.ts
391 // PeerTube >= 5.1 391 // PeerTube >= 5.1
392 adminFlags: 0, 392 adminFlags: 0,
393 // Quota in bytes 393 // Quota in bytes
@@ -977,7 +977,7 @@ npm install --save-dev @peertube/peertube-types
977 977
978This package exposes *server* definition files by default: 978This package exposes *server* definition files by default:
979```ts 979```ts
980import { RegisterServerOptions } from '@peertube/peertube-types' 980import { RegisterServerOptions } from '@peertube/peertube-types.js'
981 981
982export async function register ({ registerHook }: RegisterServerOptions) { 982export async function register ({ registerHook }: RegisterServerOptions) {
983 registerHook({ 983 registerHook({
@@ -989,8 +989,8 @@ export async function register ({ registerHook }: RegisterServerOptions) {
989 989
990But it also exposes client types and various models used in __PeerTube__: 990But it also exposes client types and various models used in __PeerTube__:
991```ts 991```ts
992import { Video } from '@peertube/peertube-types'; 992import { Video } from '@peertube/peertube-types.js';
993import { RegisterClientOptions } from '@peertube/peertube-types/client'; 993import { RegisterClientOptions } from '@peertube/peertube-types/client.js';
994 994
995function register({ registerHook, peertubeHelpers }: RegisterClientOptions) { 995function register({ registerHook, peertubeHelpers }: RegisterClientOptions) {
996 registerHook({ 996 registerHook({
@@ -1032,7 +1032,7 @@ If you want to translate strings of your plugin (like labels of your registered
1032} 1032}
1033``` 1033```
1034 1034
1035The key should be one of the locales defined in [i18n.ts](https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/i18n/i18n.ts). 1035The key should be one of the locales defined in [i18n.ts](https://github.com/Chocobozzz/PeerTube/blob/develop/packages/models/i18n/i18n.ts).
1036 1036
1037Translation files are just objects, with the english sentence as the key and the translation as the value. 1037Translation files are just objects, with the english sentence as the key and the translation as the value.
1038`fr.json` could contain for example: 1038`fr.json` could contain for example:
@@ -1070,40 +1070,25 @@ You built files are in the `dist/` directory. Check `package.json` to correctly
1070 1070
1071### Test your plugin/theme 1071### Test your plugin/theme
1072 1072
1073PeerTube dev server (ran with `npm run dev` on `localhost:3000`) can't inject plugin CSS. 1073You need to have a running PeerTube instance with an administrator account.
1074It's the reason why we don't use the dev mode but build PeerTube instead. 1074If you're using dev server on your local computer, test your plugin on `localhost:9000` using `npm run dev` because plugin CSS is not injected in Angular webserver (`localhost:3000`).
1075 1075
1076You'll need to have a local PeerTube instance: 1076Install PeerTube CLI (can be installed on another computer/server than the PeerTube instance):
1077 * Follow the [dev prerequisites](https://github.com/Chocobozzz/PeerTube/blob/develop/.github/CONTRIBUTING.md#prerequisites)
1078 (to clone the repository, install dependencies and prepare the database)
1079 * Build PeerTube:
1080 1077
1081```sh 1078```bash
1082npm run build 1079npm install -g @peertube/peertube-cli
1083```
1084
1085 * Build the CLI:
1086
1087```sh
1088npm run setup:cli
1089```
1090
1091 * Run PeerTube (you can access to your instance on `localhost:9000`):
1092
1093```sh
1094NODE_ENV=dev npm start
1095``` 1080```
1096 1081
1097 * Register the instance via the CLI: 1082Register the PeerTube instance via the CLI:
1098 1083
1099```sh 1084```sh
1100node ./dist/server/tools/peertube.js auth add -u 'http://localhost:9000' -U 'root' --password 'test' 1085peertube-cli auth add -u 'https://peertube.example.com' -U 'root' --password 'test'
1101``` 1086```
1102 1087
1103Then, you can install or reinstall your local plugin/theme by running: 1088Then, you can install your local plugin/theme by running:
1104 1089
1105```sh 1090```sh
1106node ./dist/server/tools/peertube.js plugins install --path /your/absolute/plugin-or-theme/path 1091peertube-cli plugins install --path /your/absolute/plugin-or-theme/path
1107``` 1092```
1108 1093
1109### Publish 1094### Publish
diff --git a/support/doc/tools.md b/support/doc/tools.md
index 2b3ebf159..40d9ec66a 100644
--- a/support/doc/tools.md
+++ b/support/doc/tools.md
@@ -4,59 +4,48 @@
4 4
5## Remote PeerTube CLI 5## Remote PeerTube CLI
6 6
7You need at least 512MB RAM to run the script. 7`peertube-cli` is a tool that communicates with a PeerTube instance using its [REST API](https://docs.joinpeertube.org/api-rest-reference.html).
8Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC. 8It can be launched from a remote server/computer to easily upload videos, manage plugins, redundancies etc.
9You need to follow all the following steps even if you are on a PeerTube server (including cloning the git repository in a different directory than your production installation because the scripts utilize non-production dependencies).
10
11### Dependencies
12
13Install the [PeerTube dependencies](/support/doc/dependencies.md) except PostgreSQL and Redis.
14 9
15### Installation 10### Installation
16 11
17Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server): 12Ensure you have `node` installed on your system:
18 13
19```bash 14```bash
20git clone https://github.com/Chocobozzz/PeerTube.git 15node --version # Should be >= 16.x
21CLONE="$(pwd)/PeerTube"
22cd ${CLONE}
23``` 16```
24 17
25Install dependencies and build CLI tools: 18Then install the CLI:
26 19
27```bash 20```bash
28NOCLIENT=1 yarn install --pure-lockfile 21sudo npm install -g @peertube/peertube-cli
29npm run setup:cli
30``` 22```
31 23
32### CLI wrapper 24### CLI wrapper
33 25
34The wrapper provides a convenient interface to the following scripts. 26The wrapper provides a convenient interface to the following sub-commands.
35You can access it as `peertube` via an alias in your `.bashrc` like `alias peertube="cd /your/peertube/directory/ && node ./dist/server/tools/peertube.js"` (you have to keep the `cd` command):
36 27
37``` 28```
38 Usage: peertube [command] [options] 29Usage: peertube-cli [command] [options]
39
40 Options:
41 30
42 -v, --version output the version number 31Options:
43 -h, --help output usage information 32 -v, --version output the version number
33 -h, --help display help for command
44 34
45 Commands: 35Commands:
46 36 auth Register your accounts on remote instances to use them with other commands
47 auth [action] register your accounts on remote instances to use them with other commands 37 upload|up [options] Upload a video on a PeerTube instance
48 upload|up upload a video 38 redundancy|r Manage instance redundancies
49 import-videos|import import a video from a streaming platform 39 plugins|p Manage instance plugins/themes
50 plugins|p [action] manage instance plugins 40 get-access-token|token [options] Get a peertube access token
51 redundancy|r [action] manage video redundancies 41 help [command] display help for command
52 help [cmd] display help for [cmd]
53``` 42```
54 43
55The wrapper can keep track of instances you have an account on. We limit to one account per instance for now. 44The wrapper can keep track of instances you have an account on. We limit to one account per instance for now.
56 45
57```bash 46```bash
58peertube auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD' 47peertube-cli auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD'
59peertube auth list 48peertube-cli auth list
60┌──────────────────────────────┬──────────────────────────────┐ 49┌──────────────────────────────┬──────────────────────────────┐
61│ instance │ login │ 50│ instance │ login │
62├──────────────────────────────┼──────────────────────────────┤ 51├──────────────────────────────┼──────────────────────────────┤
@@ -64,124 +53,142 @@ peertube auth list
64└──────────────────────────────┴──────────────────────────────┘ 53└──────────────────────────────┴──────────────────────────────┘
65``` 54```
66 55
67You can now use that account to upload videos without feeding the same parameters again. 56You can now use that account to execute sub-commands without feeding the `--url`, `--username` and `--password` parameters:
68 57
69```bash 58```bash
70peertube up <videoFile> 59peertube-cli upload <videoFile>
60peertube-cli plugins list
61...
71``` 62```
72 63
73To list, install, uninstall dynamically plugins/themes of an instance: 64#### peertube-cli upload
65
66You can use this script to upload videos directly from the CLI.
67
68Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
74 69
75```bash 70```bash
76peertube plugins list 71cd ${CLONE}
77peertube plugins install --path /local/plugin/path 72peertube-cli upload --help
78peertube plugins install --npm-name peertube-plugin-myplugin
79peertube plugins uninstall --npm-name peertube-plugin-myplugin
80``` 73```
81 74
82#### peertube-import-videos.js 75#### peertube-cli plugins
76
77Install/update/uninstall or list local or NPM PeerTube plugins:
83 78
84You can use this script to import videos from all [supported sites of youtube-dl](https://rg3.github.io/youtube-dl/supportedsites.html) into PeerTube. 79```bash
85Be sure you own the videos or have the author's authorization to do so. 80cd ${CLONE}
81peertube-cli plugins --help
82peertube-cli plugins list --help
83peertube-cli plugins install --help
84peertube-cli plugins update --help
85peertube-cli plugins uninstall --help
86 86
87```sh 87peertube-cli plugins install --path /my/plugin/path
88node dist/server/tools/peertube-import-videos.js \ 88peertube-cli plugins install --npm-name peertube-theme-example
89 -u 'PEERTUBE_URL' \
90 -U 'PEERTUBE_USER' \
91 --password 'PEERTUBE_PASSWORD' \
92 --target-url 'TARGET_URL'
93``` 89```
94 90
95* `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re 91#### peertube-cli redundancy
96* `PEERTUBE_USER` : your PeerTube account where videos will be uploaded
97* `PEERTUBE_PASSWORD` : password of your PeerTube account (if `--password PEERTUBE_PASSWORD` is omitted, you will be prompted for it)
98* `TARGET_URL` : the target url you want to import. Examples:
99 * YouTube:
100 * Channel: https://www.youtube.com/channel/ChannelId
101 * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName
102 * Video https://www.youtube.com/watch?v=blabla
103 * Vimeo: https://vimeo.com/xxxxxx
104 * Dailymotion: https://www.dailymotion.com/xxxxx
105 92
106The script will get all public videos from Youtube, download them and upload to PeerTube. 93Manage (list/add/remove) video redundancies:
107Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection...
108 94
109Videos will be publicly available after transcoding (you can see them before that in your account on the web interface). 95To list your videos that are duplicated by remote instances:
96
97```bash
98peertube-cli redundancy list-remote-redundancies
99```
110 100
111**NB**: If you want to synchronize a Youtube channel to your PeerTube instance (ensure you have the agreement from the author), 101To list remote videos that your instance duplicated:
112you can add a [crontab rule](https://help.ubuntu.com/community/CronHowto) (or an equivalent of your OS) and insert
113these rules (ensure to customize them to your needs):
114 102
103```bash
104peertube-cli redundancy list-my-redundancies
105```
106
107To duplicate a specific video in your redundancy system:
108
109```bash
110peertube-cli redundancy add --video 823
115``` 111```
116# Update youtube-dl every day at midnight
1170 0 * * * /usr/bin/npm rebuild youtube-dl --prefix /PATH/TO/PEERTUBE/
118 112
119# Synchronize the YT channel every sunday at 22:00 all the videos published since last monday included 113To remove a video redundancy:
1200 22 * * 0 /usr/bin/node /PATH/TO/PEERTUBE/dist/server/tools/peertube-import-videos.js -u '__PEERTUBE_URL__' -U '__USER__' --password '__PASSWORD__' --target-url 'https://www.youtube.com/channel/___CHANNEL__' --since $(date --date="-6 days" +\%Y-\%m-\%d) 114
115```bash
116peertube-cli redundancy remove --video 823
121``` 117```
122 118
123Also you may want to subscribe to the PeerTube channel in order to manually check the synchronization is successful.
124 119
125#### peertube-upload.js 120## PeerTube runner
126 121
127You can use this script to import videos directly from the CLI. 122PeerTube >= 5.2 supports VOD or Live transcoding by a remote PeerTube runner.
128 123
129Videos will be publicly available after transcoding (you can see them before that in your account on the web interface). 124### Installation
125
126Ensure you have `node`, `ffmpeg` and `ffprobe` installed on your system:
130 127
131```bash 128```bash
132cd ${CLONE} 129node --version # Should be >= 16.x
133node dist/server/tools/peertube-upload.js --help 130ffprobe -version # Should be >= 4.3
131ffmpeg -version # Should be >= 4.3
134``` 132```
135 133
136#### peertube-plugins.js 134Then install the CLI:
137
138Install/update/uninstall or list local or NPM PeerTube plugins:
139 135
140```bash 136```bash
141cd ${CLONE} 137sudo npm install -g @peertube/peertube-runner
142node dist/server/tools/peertube-plugins.js --help 138```
143node dist/server/tools/peertube-plugins.js list --help 139
144node dist/server/tools/peertube-plugins.js install --help 140### Configuration
145node dist/server/tools/peertube-plugins.js update --help 141
146node dist/server/tools/peertube-plugins.js uninstall --help 142The runner uses env paths like `~/.config`, `~/.cache` and `~/.local/share` directories to store runner configuration or temporary files.
143
144Multiple PeerTube runners can run on the same OS by using the `--id` CLI option (each runner uses its own config/tmp directories):
147 145
148node dist/server/tools/peertube-plugins.js install --path /my/plugin/path 146```bash
149node dist/server/tools/peertube-plugins.js install --npm-name peertube-theme-example 147peertube-runner [commands] --id instance-1
148peertube-runner [commands] --id instance-2
149peertube-runner [commands] --id instance-3
150``` 150```
151 151
152#### peertube-redundancy.js 152You can change the runner configuration (jobs concurrency, ffmpeg threads/nice etc) by editing `~/.config/peertube-runner-nodejs/[id]/config.toml`.
153 153
154Manage (list/add/remove) video redundancies: 154### Run the server
155 155
156To list your videos that are duplicated by remote instances: 156You need to run the runner in server mode first so it can run transcoding jobs of registered PeerTube instances:
157 157
158```bash 158```bash
159node dist/server/tools/peertube.js redundancy list-remote-redundancies 159peertube-runner server
160``` 160```
161 161
162To list remote videos that your instance duplicated: 162### Register
163
164Then, you can register the runner to process transcoding job of a remote PeerTube instance:
163 165
164```bash 166```bash
165node dist/server/tools/peertube.js redundancy list-my-redundancies 167peertube-runner register --url http://peertube.example.com --registration-token ptrrt-... --runner-name my-runner-name
166``` 168```
167 169
168To duplicate a specific video in your redundancy system: 170The runner will then use a websocket connection with the PeerTube instance to be notified about new available transcoding jobs.
171
172### Unregister
173
174To unregister a PeerTube instance:
169 175
170```bash 176```bash
171node dist/server/tools/peertube.js redundancy add --video 823 177peertube-runner unregister --url http://peertube.example.com --runner-name my-runner-name
172``` 178```
173 179
174To remove a video redundancy: 180### List registered instances
175 181
176```bash 182```bash
177node dist/server/tools/peertube.js redundancy remove --video 823 183peertube-runner list-registered
178``` 184```
179 185
180## Server tools 186## Server tools
181 187
182These scripts should be run on the server, in `peertube-latest` directory. 188Server tools are scripts that interect directly with the code of your PeerTube instance.
189They must be run on the server, in `peertube-latest` directory.
183 190
184### parse-log 191### Parse logs
185 192
186To parse PeerTube last log file: 193To parse PeerTube last log file:
187 194
@@ -209,9 +216,7 @@ cd /var/www/peertube-docker
209docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql 216docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql
210``` 217```
211 218
212### regenerate-thumbnails.js 219### Regenerate video thumbnails
213
214**PeerTube >= 3.2**
215 220
216Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes: 221Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes:
217 222
@@ -225,7 +230,7 @@ cd /var/www/peertube-docker
225docker-compose exec -u peertube peertube npm run regenerate-thumbnails 230docker-compose exec -u peertube peertube npm run regenerate-thumbnails
226``` 231```
227 232
228### create-import-video-file-job.js 233### Add or replace specific video file
229 234
230You can use this script to import a video file to replace an already uploaded file or to add a new web compatible resolution to a video. PeerTube needs to be running. 235You can use this script to import a video file to replace an already uploaded file or to add a new web compatible resolution to a video. PeerTube needs to be running.
231You can then create a transcoding job using the web interface if you need to optimize your file or create an HLS version of it. 236You can then create a transcoding job using the web interface if you need to optimize your file or create an HLS version of it.
@@ -240,9 +245,7 @@ cd /var/www/peertube-docker
240docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile] 245docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
241``` 246```
242 247
243### create-move-video-storage-job.js 248### Move video files to object storage
244
245**PeerTube >= 4.0**
246 249
247Use this script to move all video files or a specific video file to object storage. 250Use this script to move all video files or a specific video file to object storage.
248 251
@@ -269,7 +272,7 @@ docker-compose exec -u peertube peertube npm run create-move-video-storage-job -
269``` 272```
270 273
271<!-- TODO: uncomment when PeerTube 6 is released 274<!-- TODO: uncomment when PeerTube 6 is released
272### create-generate-storyboard-job 275### Generate storyboard
273 276
274**PeerTube >= 6.0** 277**PeerTube >= 6.0**
275 278
@@ -298,7 +301,7 @@ docker-compose exec -u peertube peertube npm run create-generate-storyboard-job
298``` 301```
299--> 302-->
300 303
301### prune-storage.js 304### Prune filesystem storage
302 305
303Some transcoded videos or shutdown at a bad time can leave some unused files on your storage. 306Some transcoded videos or shutdown at a bad time can leave some unused files on your storage.
304Stop PeerTube and delete these files (a confirmation will be demanded first): 307Stop PeerTube and delete these files (a confirmation will be demanded first):
@@ -308,8 +311,7 @@ cd /var/www/peertube/peertube-latest
308sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage 311sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
309``` 312```
310 313
311 314### Update PeerTube instance domain name
312### update-host.js
313 315
314**Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.** 316**Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.**
315If you started PeerTube with a domain, and then changed it you will have 317If you started PeerTube with a domain, and then changed it you will have
@@ -326,7 +328,7 @@ cd /var/www/peertube-docker
326docker-compose exec -u peertube peertube npm run update-host 328docker-compose exec -u peertube peertube npm run update-host
327``` 329```
328 330
329### reset-password.js 331### Reset user password
330 332
331To reset a user password from CLI, run: 333To reset a user password from CLI, run:
332 334
@@ -341,7 +343,7 @@ docker-compose exec -u peertube peertube npm run reset-password -- -u target_use
341``` 343```
342 344
343 345
344### plugin install/uninstall 346### Install or uninstall plugins
345 347
346The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running. 348The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running.
347If PeerTube is running, you need to restart it for the changes to take effect (whereas with `peertube plugins` CLI, plugins/themes are dynamically loaded on the server). 349If PeerTube is running, you need to restart it for the changes to take effect (whereas with `peertube plugins` CLI, plugins/themes are dynamically loaded on the server).
@@ -378,69 +380,3 @@ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production np
378cd /var/www/peertube-docker 380cd /var/www/peertube-docker
379docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin 381docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
380``` 382```
381
382## PeerTube runner
383
384PeerTube >= 5.2 supports VOD or Live transcoding by a remote PeerTube runner.
385
386
387### Installation
388
389Ensure you have `ffmpeg` and `ffprobe` installed on your system:
390
391```bash
392ffprobe -version # Should be >= 4.3
393ffmpeg -version # Should be >= 4.3
394```
395
396Then install the CLI:
397
398```bash
399sudo npm install -g @peertube/peertube-runner
400```
401
402### Configuration
403
404The runner uses env paths like `~/.config`, `~/.cache` and `~/.local/share` directories to store runner configuration or temporary files.
405
406Multiple PeerTube runners can run on the same OS by using the `--id` CLI option (each runner uses its own config/tmp directories):
407
408```bash
409peertube-runner [commands] --id instance-1
410peertube-runner [commands] --id instance-2
411peertube-runner [commands] --id instance-3
412```
413
414You can change the runner configuration (jobs concurrency, ffmpeg threads/nice etc) by editing `~/.config/peertube-runner-nodejs/[id]/config.toml`.
415
416### Run the server
417
418You need to run the runner in server mode first so it can run transcoding jobs of registered PeerTube instances:
419
420```bash
421peertube-runner server
422```
423
424### Register
425
426Then, you can register the runner to process transcoding job of a remote PeerTube instance:
427
428```bash
429peertube-runner register --url http://peertube.example.com --registration-token ptrrt-... --runner-name my-runner-name
430```
431
432The runner will then use a websocket connection with the PeerTube instance to be notified about new available transcoding jobs.
433
434### Unregister
435
436To unregister a PeerTube instance:
437
438```bash
439peertube-runner unregister --url http://peertube.example.com --runner-name my-runner-name
440```
441
442### List registered instances
443
444```bash
445peertube-runner list-registered
446```