]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - support/doc/tools.md
replace fs by fs-extra to prevent EMFILE error
[github/Chocobozzz/PeerTube.git] / support / doc / tools.md
CommitLineData
358770db 1# CLI tools guide
2519d9fe 2
54a3a12e 3 - [Remote tools](#remote-tools)
635a5686
C
4 - [import-videos.js](#import-videosjs)
5 - [upload.js](#uploadjs)
54a3a12e 6 - [Server tools](#server-tools)
a5f0521f
RK
7 - [create-transcoding-job.js](#create-transcoding-jobjs)
8 - [create-import-video-file-job.js](#create-import-video-file-jobjs)
54a3a12e 9 - [prune-storage.js](#prune-storagejs)
2519d9fe 10
54a3a12e 11## Remote Tools
2519d9fe 12
99402413
C
13You need at least 512MB RAM to run the script.
14Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC.
05e67d62 15You need to follow all the following steps even if you are on a PeerTube server.
2519d9fe
L
16
17### Dependencies
18
358770db 19Install the [PeerTube dependencies](dependencies.md).
2519d9fe
L
20
21### Installation
22
99402413 23Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server):
2519d9fe
L
24
25```
05e67d62
C
26$ git clone https://github.com/Chocobozzz/PeerTube.git
27$ CLONE="$(pwd)/PeerTube"
2519d9fe
L
28```
29
30Run ``yarn install``
31```
05e67d62
C
32$ cd ${CLONE}
33$ yarn install
2519d9fe
L
34```
35
36Build server tools:
37```
05e67d62
C
38$ cd ${CLONE}
39$ npm run build:server
2519d9fe
L
40```
41
358770db
C
42### import-videos.js
43
44You can use this script to import videos from all [supported sites of youtube-dl](https://rg3.github.io/youtube-dl/supportedsites.html) into PeerTube.
45Be sure you own the videos or have the author's authorization to do so.
2519d9fe 46
a5f0521f
RK
47```sh
48$ node dist/server/tools/import-videos.js \
49 -u "PEERTUBE_URL" \
50 -U "PEERTUBE_USER" \
51 --password "PEERTUBE_PASSWORD" \
52 -t "TARGET_URL"
2519d9fe
L
53```
54
a5f0521f
RK
55* `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re
56* `PEERTUBE_USER` : your PeerTube account where videos will be uploaded
57* `PEERTUBE_PASSWORD` : password of your PeerTube account (if omitted, you will be prompted for it)
58* `TARGET_URL` : the target url you want to import. Examples:
59 * YouTube:
60 * Channel: https://www.youtube.com/channel/ChannelId
61 * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName
62 * Video https://www.youtube.com/watch?v=blabla
63 * Vimeo: https://vimeo.com/xxxxxx
64 * Dailymotion: https://www.dailymotion.com/xxxxx
2519d9fe 65
2186386c
C
66The script will get all public videos from Youtube, download them and upload to PeerTube.
67Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection...
68
69Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
70
358770db
C
71
72### upload.js
73
74You can use this script to import videos directly from the CLI.
75
2186386c
C
76Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
77
358770db 78```
05e67d62
C
79$ cd ${CLONE}
80$ node dist/server/tools/upload.js --help
358770db 81```
a5f0521f 82
54a3a12e
C
83
84## Server tools
85
86These scripts should be run on the server, in `peertube-latest` directory.
a5f0521f 87
0ee02734
C
88### parse-log
89
90To parse PeerTube last log file:
91
92```
93$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info
94```
95
96`--level` is optional and could be `info`/`warn`/`error`
97
a5f0521f
RK
98### create-transcoding-job.js
99
100You can use this script to force transcoding of an existing video.
101
102```
54a3a12e 103$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID]
a5f0521f 104```
05623b90
F
105
106Or to transcode to a specific resolution:
107```
108$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
109```
a5f0521f
RK
110
111### create-import-video-file-job.js
112
113You can use this script to import a video file to replace an already uploaded file or to add a new resolution to a video.
114
115```
54a3a12e
C
116$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile]
117```
118
119### prune-storage.js
120
121Some transcoded videos or shutdown at a bad time can leave some unused files on your storage.
122To delete them (a confirmation will be demanded first):
123
a5f0521f 124```
54a3a12e 125$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
23687332
C
126```
127
128### update-host.js
129
130If you started PeerTube with a domain, and then changed it you will have invalid torrent files and invalid URLs in your database.
131To fix this, you have to run:
132
133```
134$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host
54a3a12e 135```