]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - support/doc/tools.md
Remove unmaintained help script
[github/Chocobozzz/PeerTube.git] / support / doc / tools.md
CommitLineData
c141f68b
RK
1# CLI tools guide
2
12b119c0
RK
3<!-- START doctoc generated TOC please keep comment here to allow auto update -->
4<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1f8ac024 5**Table of Contents**
c141f68b 6
c141f68b
RK
7- [Remote Tools](#remote-tools)
8 - [Dependencies](#dependencies)
9 - [Installation](#installation)
d639c3bf
C
10 - [CLI wrapper](#cli-wrapper)
11 - [peertube-import-videos.js](#peertube-import-videosjs)
12 - [peertube-upload.js](#peertube-uploadjs)
8dd2d050 13 - [peertube-plugins.js](#peertube-pluginsjs)
e669ff58 14 - [peertube-redundancy.js](#peertube-redundancyjs)
c141f68b
RK
15- [Server tools](#server-tools)
16 - [parse-log](#parse-log)
c2bd7a6f 17 - [regenerate-thumbnails.js](#regenerate-thumbnailsjs)
c141f68b
RK
18 - [create-transcoding-job.js](#create-transcoding-jobjs)
19 - [create-import-video-file-job.js](#create-import-video-file-jobjs)
e1ab52d7 20 - [create-move-video-storage-job.js](#create-move-video-storage-jobjs)
c141f68b 21 - [prune-storage.js](#prune-storagejs)
c141f68b 22 - [update-host.js](#update-hostjs)
31b48aad 23 - [reset-password.js](#reset-passwordjs)
13126d99 24 - [plugin install/uninstall](#plugin-installuninstall)
12b119c0
RK
25
26<!-- END doctoc generated TOC please keep comment here to allow auto update -->
27
d639c3bf
C
28## Remote Tools
29
30You need at least 512MB RAM to run the script.
31Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC.
32You 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).
33
34### Dependencies
35
1ab94472 36Install the [PeerTube dependencies](/support/doc/dependencies.md) except PostgreSQL and Redis.
d639c3bf
C
37
38### Installation
39
40Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server):
41
c83af8f9 42```bash
00ee545c
C
43git clone https://github.com/Chocobozzz/PeerTube.git
44CLONE="$(pwd)/PeerTube"
45cd ${CLONE}
d639c3bf
C
46```
47
7e9d3f25
C
48Install dependencies and build CLI tools:
49
c83af8f9 50```bash
00ee545c
C
51NOCLIENT=1 yarn install --pure-lockfile
52npm run setup:cli
d639c3bf
C
53```
54
55### CLI wrapper
8704acf4 56
bb8f7872
C
57The wrapper provides a convenient interface to the following scripts.
58You 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):
8704acf4
RK
59
60```
61 Usage: peertube [command] [options]
62
63 Options:
64
65 -v, --version output the version number
66 -h, --help output usage information
67
68 Commands:
69
70 auth [action] register your accounts on remote instances to use them with other commands
71 upload|up upload a video
72 import-videos|import import a video from a streaming platform
e669ff58
C
73 plugins|p [action] manage instance plugins
74 redundancy|r [action] manage video redundancies
8704acf4
RK
75 help [cmd] display help for [cmd]
76```
77
78The wrapper can keep track of instances you have an account on. We limit to one account per instance for now.
79
80```bash
00ee545c
C
81peertube auth add -u 'PEERTUBE_URL' -U 'PEERTUBE_USER' --password 'PEERTUBE_PASSWORD'
82peertube auth list
8704acf4
RK
83┌──────────────────────────────┬──────────────────────────────┐
84│ instance │ login │
85├──────────────────────────────┼──────────────────────────────┤
5b036b8e 86│ 'PEERTUBE_URL' │ 'PEERTUBE_USER' │
8704acf4
RK
87└──────────────────────────────┴──────────────────────────────┘
88```
89
90You can now use that account to upload videos without feeding the same parameters again.
91
92```bash
00ee545c 93peertube up <videoFile>
8704acf4
RK
94```
95
9b474844
C
96To list, install, uninstall dynamically plugins/themes of an instance:
97
98```bash
00ee545c
C
99peertube plugins list
100peertube plugins install --path /local/plugin/path
101peertube plugins install --npm-name peertube-plugin-myplugin
102peertube plugins uninstall --npm-name peertube-plugin-myplugin
9b474844
C
103```
104
d639c3bf 105#### peertube-import-videos.js
358770db 106
1f8ac024 107You can use this script to import videos from all [supported sites of youtube-dl](https://rg3.github.io/youtube-dl/supportedsites.html) into PeerTube.
358770db 108Be sure you own the videos or have the author's authorization to do so.
2519d9fe 109
a5f0521f 110```sh
00ee545c 111node dist/server/tools/peertube-import-videos.js \
5b036b8e
C
112 -u 'PEERTUBE_URL' \
113 -U 'PEERTUBE_USER' \
9024bece 114 --password 'PEERTUBE_PASSWORD' \
8a08bc1e 115 --target-url 'TARGET_URL'
2519d9fe
L
116```
117
a5f0521f
RK
118* `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re
119* `PEERTUBE_USER` : your PeerTube account where videos will be uploaded
e8a739e8 120* `PEERTUBE_PASSWORD` : password of your PeerTube account (if `--password PEERTUBE_PASSWORD` is omitted, you will be prompted for it)
a5f0521f
RK
121* `TARGET_URL` : the target url you want to import. Examples:
122 * YouTube:
123 * Channel: https://www.youtube.com/channel/ChannelId
124 * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName
125 * Video https://www.youtube.com/watch?v=blabla
126 * Vimeo: https://vimeo.com/xxxxxx
127 * Dailymotion: https://www.dailymotion.com/xxxxx
2519d9fe 128
2186386c
C
129The script will get all public videos from Youtube, download them and upload to PeerTube.
130Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection...
131
132Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
133
1f8ac024
F
134**NB**: If you want to synchronize a Youtube channel to your PeerTube instance (ensure you have the agreement from the author),
135you can add a [crontab rule](https://help.ubuntu.com/community/CronHowto) (or an equivalent of your OS) and insert
136these rules (ensure to customize them to your needs):
137
138```
139# Update youtube-dl every day at midnight
1400 0 * * * /usr/bin/npm rebuild youtube-dl --prefix /PATH/TO/PEERTUBE/
141
142# Synchronize the YT channel every sunday at 22:00 all the videos published since last monday included
927d14bd 1430 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)
1f8ac024
F
144```
145
146Also you may want to subscribe to the PeerTube channel in order to manually check the synchronization is successful.
358770db 147
d639c3bf 148#### peertube-upload.js
358770db
C
149
150You can use this script to import videos directly from the CLI.
151
2186386c
C
152Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
153
c83af8f9 154```bash
00ee545c
C
155cd ${CLONE}
156node dist/server/tools/peertube-upload.js --help
358770db 157```
a5f0521f 158
8dd2d050
C
159#### peertube-plugins.js
160
161Install/update/uninstall or list local or NPM PeerTube plugins:
162
c83af8f9 163```bash
00ee545c
C
164cd ${CLONE}
165node dist/server/tools/peertube-plugins.js --help
166node dist/server/tools/peertube-plugins.js list --help
167node dist/server/tools/peertube-plugins.js install --help
168node dist/server/tools/peertube-plugins.js update --help
169node dist/server/tools/peertube-plugins.js uninstall --help
170
171node dist/server/tools/peertube-plugins.js install --path /my/plugin/path
172node dist/server/tools/peertube-plugins.js install --npm-name peertube-theme-example
8dd2d050
C
173```
174
e669ff58
C
175#### peertube-redundancy.js
176
177Manage (list/add/remove) video redundancies:
178
179To list your videos that are duplicated by remote instances:
180
c83af8f9 181```bash
00ee545c 182node dist/server/tools/peertube.js redundancy list-remote-redundancies
e669ff58
C
183```
184
185To list remote videos that your instance duplicated:
186
c83af8f9 187```bash
00ee545c 188node dist/server/tools/peertube.js redundancy list-my-redundancies
e669ff58
C
189```
190
191To duplicate a specific video in your redundancy system:
192
c83af8f9 193```bash
00ee545c 194node dist/server/tools/peertube.js redundancy add --video 823
e669ff58
C
195```
196
197To remove a video redundancy:
198
c83af8f9 199```bash
00ee545c 200node dist/server/tools/peertube.js redundancy remove --video 823
e669ff58
C
201```
202
54a3a12e
C
203## Server tools
204
205These scripts should be run on the server, in `peertube-latest` directory.
a5f0521f 206
0ee02734
C
207### parse-log
208
209To parse PeerTube last log file:
210
c83af8f9 211```bash
00ee545c
C
212# Basic installation
213cd /var/www/peertube/peertube-latest
214sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info
cb6a78c2 215
00ee545c
C
216# Docker installation
217cd /var/www/peertube-docker
218docker-compose exec -u peertube peertube npm run parse-log -- --level info
0ee02734
C
219```
220
221`--level` is optional and could be `info`/`warn`/`error`
222
cb6a78c2 223You can also remove SQL or HTTP logs using `--not-tags` (PeerTube >= 3.2):
7992c9e1 224
cb6a78c2 225```bash
00ee545c
C
226# Basic installation
227cd /var/www/peertube/peertube-latest
228sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level debug --not-tags http sql
cb6a78c2 229
00ee545c
C
230# Docker installation
231cd /var/www/peertube-docker
232docker-compose exec -u peertube peertube npm run parse-log -- --level debug --not-tags http sql
7992c9e1
C
233```
234
c2bd7a6f
C
235### regenerate-thumbnails.js
236
cb6a78c2
C
237**PeerTube >= 3.2**
238
c2bd7a6f
C
239Regenerating local video thumbnails could be useful because new PeerTube releases may increase thumbnail sizes:
240
cb6a78c2 241```bash
00ee545c
C
242# Basic installation
243cd /var/www/peertube/peertube-latest
244sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run regenerate-thumbnails
cb6a78c2 245
00ee545c
C
246# Docker installation
247cd /var/www/peertube-docker
248docker-compose exec -u peertube peertube npm run regenerate-thumbnails
c2bd7a6f
C
249```
250
a5f0521f
RK
251### create-transcoding-job.js
252
12b119c0 253You can use this script to force transcoding of an existing video. PeerTube needs to be running.
a5f0521f 254
c83af8f9 255To generate transcoding jobs depending on the instance configuration:
cb6a78c2 256
c83af8f9 257```bash
00ee545c
C
258# Basic installation
259cd /var/www/peertube/peertube-latest
260sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID]
cb6a78c2 261
00ee545c
C
262# Docker installation
263cd /var/www/peertube-docker
264docker-compose exec -u peertube peertube npm run create-transcoding-job -- -v [videoUUID]
a5f0521f 265```
05623b90
F
266
267Or to transcode to a specific resolution:
cb6a78c2 268
c83af8f9 269```bash
00ee545c
C
270# Basic installation
271cd /var/www/peertube/peertube-latest
272sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
cb6a78c2 273
00ee545c
C
274# Docker installation
275cd /var/www/peertube-docker
276docker-compose exec -u peertube peertube npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
05623b90 277```
cb6a78c2 278
1c5c31a1 279The resolution should be an integer (`1080`, `720`, `480`, etc.)
1f8ac024 280
8b7bd166
C
281To generate an HLS playlist for a video:
282
c83af8f9 283```bash
00ee545c
C
284# Basic installation
285cd /var/www/peertube/peertube-latest
286sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- --generate-hls -v [videoUUID]
cb6a78c2 287
00ee545c
C
288# Docker installation
289cd /var/www/peertube-docker
290docker-compose exec -u peertube peertube npm run create-transcoding-job -- --generate-hls -v [videoUUID]
8b7bd166
C
291```
292
a5f0521f
RK
293### create-import-video-file-job.js
294
221ee1ad
C
295You can use this script to import a video file to replace an already uploaded file or to add a new webtorrent resolution to a video. PeerTube needs to be running.
296You can then create a transcoding job using `npm run create-transcoding-job` if you need to optimize your file or create an HLS version of it.
a5f0521f 297
c83af8f9 298```bash
00ee545c
C
299# Basic installation
300cd /var/www/peertube/peertube-latest
301sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
cb6a78c2 302
00ee545c
C
303# Docker installation
304cd /var/www/peertube-docker
305docker-compose exec -u peertube peertube npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
54a3a12e
C
306```
307
e1ab52d7 308### create-move-video-storage-job.js
309
9c391612
C
310**PeerTube >= 4.0**
311
e1ab52d7 312Use this script to move all video files or a specific video file to object storage.
313
314```bash
00ee545c
C
315# Basic installation
316cd /var/www/peertube/peertube-latest
317sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
e1ab52d7 318
00ee545c
C
319# Docker installation
320cd /var/www/peertube-docker
321docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage -v [videoUUID]
e1ab52d7 322```
323
324The script can also move all video files that are not already in object storage:
325
326```bash
00ee545c
C
327# Basic installation
328cd /var/www/peertube/peertube-latest
329sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-move-video-storage-job -- --to-object-storage --all-videos
e1ab52d7 330
00ee545c
C
331# Docker installation
332cd /var/www/peertube-docker
333docker-compose exec -u peertube peertube npm run create-move-video-storage-job -- --to-object-storage --all-videos
e1ab52d7 334```
335
336
54a3a12e
C
337### prune-storage.js
338
339Some transcoded videos or shutdown at a bad time can leave some unused files on your storage.
7089e7b4 340Stop PeerTube and delete these files (a confirmation will be demanded first):
54a3a12e 341
c83af8f9 342```bash
00ee545c
C
343cd /var/www/peertube/peertube-latest
344sudo systemctl stop peertube && sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
23687332
C
345```
346
edb4ffc7 347
23687332
C
348### update-host.js
349
fffc7c08 350**Changing the hostname is unsupported and may be a risky operation, especially if you have already federated.**
12b119c0
RK
351If you started PeerTube with a domain, and then changed it you will have
352invalid torrent files and invalid URLs in your database. To fix this, you have
fffc7c08 353to run the command below (keep in mind your follower instances will NOT update their URLs).
23687332 354
c83af8f9 355```bash
00ee545c
C
356# Basic installation
357cd /var/www/peertube/peertube-latest
358sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
cb6a78c2 359
00ee545c
C
360# Docker installation
361cd /var/www/peertube-docker
362docker-compose exec -u peertube peertube npm run update-host
ecf06378 363```
1e59ca3b 364
31b48aad
C
365### reset-password.js
366
367To reset a user password from CLI, run:
368
c83af8f9 369```bash
00ee545c
C
370# Basic installation
371cd /var/www/peertube/peertube-latest
372sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u target_username
cb6a78c2 373
00ee545c
C
374# Docker installation
375cd /var/www/peertube-docker
376docker-compose exec -u peertube peertube npm run reset-password -- -u target_username
31b48aad
C
377```
378
9b474844
C
379
380### plugin install/uninstall
381
382The difference with `peertube plugins` CLI is that these scripts can be used even if PeerTube is not running.
383If 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).
384
8dd2d050 385To install/update a plugin or a theme from the disk:
9b474844 386
c83af8f9 387```bash
00ee545c
C
388cd /var/www/peertube/peertube-latest
389sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --plugin-path /local/plugin/path
cb6a78c2 390
00ee545c
C
391# Docker installation
392cd /var/www/peertube-docker
393docker-compose exec -u peertube peertube npm run plugin:install -- --plugin-path /local/plugin/path
9b474844
C
394```
395
396From NPM:
397
c83af8f9 398```bash
00ee545c
C
399cd /var/www/peertube/peertube-latest
400sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:install -- --npm-name peertube-plugin-myplugin
cb6a78c2 401
00ee545c
C
402# Docker installation
403cd /var/www/peertube-docker
404docker-compose exec -u peertube peertube npm run plugin:install -- --npm-name peertube-plugin-myplugin
9b474844
C
405```
406
407To uninstall a plugin or a theme:
408
c83af8f9 409```bash
00ee545c
C
410cd /var/www/peertube/peertube-latest
411sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
cb6a78c2 412
00ee545c
C
413# Docker installation
414cd /var/www/peertube-docker
415docker-compose exec -u peertube peertube npm run plugin:uninstall -- --npm-name peertube-plugin-myplugin
9b474844 416```