]>
Commit | Line | Data |
---|---|---|
358770db | 1 | # CLI tools guide |
8704acf4 | 2 | - [CLI wrapper](#cli-wrapper) |
54a3a12e | 3 | - [Remote tools](#remote-tools) |
8704acf4 RK |
4 | - [peertube-import-videos.js](#peertube-import-videosjs) |
5 | - [peertube-upload.js](#peertube-uploadjs) | |
6 | - [peertube-watch.js](#peertube-watch) | |
54a3a12e | 7 | - [Server tools](#server-tools) |
11b8762f | 8 | - [parse-log](#parse-log) |
a5f0521f RK |
9 | - [create-transcoding-job.js](#create-transcoding-jobjs) |
10 | - [create-import-video-file-job.js](#create-import-video-file-jobjs) | |
54a3a12e | 11 | - [prune-storage.js](#prune-storagejs) |
2519d9fe | 12 | |
8704acf4 RK |
13 | ## CLI wrapper |
14 | ||
15 | The wrapper provides a convenient interface to most scripts, and requires the [same dependencies](#dependencies). You can access it as `peertube` via an alias in your `.bashrc` like `alias peertube="node ${PEERTUBE_PATH}/dist/server/tools/peertube.js"`: | |
16 | ||
17 | ``` | |
18 | Usage: peertube [command] [options] | |
19 | ||
20 | Options: | |
21 | ||
22 | -v, --version output the version number | |
23 | -h, --help output usage information | |
24 | ||
25 | Commands: | |
26 | ||
27 | auth [action] register your accounts on remote instances to use them with other commands | |
28 | upload|up upload a video | |
29 | import-videos|import import a video from a streaming platform | |
30 | watch|w watch a video in the terminal ✩°。⋆ | |
31 | help [cmd] display help for [cmd] | |
32 | ``` | |
33 | ||
34 | The wrapper can keep track of instances you have an account on. We limit to one account per instance for now. | |
35 | ||
36 | ```bash | |
37 | $ peertube auth add -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD" | |
38 | $ peertube auth list | |
39 | ┌──────────────────────────────┬──────────────────────────────┐ | |
40 | │ instance │ login │ | |
41 | ├──────────────────────────────┼──────────────────────────────┤ | |
42 | │ "PEERTUBE_URL" │ "PEERTUBE_USER" │ | |
43 | └──────────────────────────────┴──────────────────────────────┘ | |
44 | ``` | |
45 | ||
46 | You can now use that account to upload videos without feeding the same parameters again. | |
47 | ||
48 | ```bash | |
49 | $ peertube up <videoFile> | |
50 | ``` | |
51 | ||
52 | And now that your video is online, you can watch it from the confort of your terminal (use `peertube watch --help` to see the supported players): | |
53 | ||
54 | ```bash | |
55 | $ peertube watch https://peertube.cpy.re/videos/watch/e8a1af4e-414a-4d58-bfe6-2146eed06d10 | |
56 | ``` | |
57 | ||
54a3a12e | 58 | ## Remote Tools |
2519d9fe | 59 | |
99402413 C |
60 | You need at least 512MB RAM to run the script. |
61 | Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC. | |
ecf06378 | 62 | You 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). |
2519d9fe L |
63 | |
64 | ### Dependencies | |
65 | ||
358770db | 66 | Install the [PeerTube dependencies](dependencies.md). |
2519d9fe L |
67 | |
68 | ### Installation | |
69 | ||
99402413 | 70 | Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server): |
2519d9fe L |
71 | |
72 | ``` | |
05e67d62 C |
73 | $ git clone https://github.com/Chocobozzz/PeerTube.git |
74 | $ CLONE="$(pwd)/PeerTube" | |
2519d9fe L |
75 | ``` |
76 | ||
77 | Run ``yarn install`` | |
78 | ``` | |
05e67d62 C |
79 | $ cd ${CLONE} |
80 | $ yarn install | |
2519d9fe L |
81 | ``` |
82 | ||
83 | Build server tools: | |
84 | ``` | |
05e67d62 C |
85 | $ cd ${CLONE} |
86 | $ npm run build:server | |
2519d9fe L |
87 | ``` |
88 | ||
8704acf4 | 89 | ### peertube-import-videos.js |
358770db C |
90 | |
91 | You can use this script to import videos from all [supported sites of youtube-dl](https://rg3.github.io/youtube-dl/supportedsites.html) into PeerTube. | |
92 | Be sure you own the videos or have the author's authorization to do so. | |
2519d9fe | 93 | |
a5f0521f | 94 | ```sh |
8704acf4 | 95 | $ node dist/server/tools/peertube-import-videos.js \ |
a5f0521f RK |
96 | -u "PEERTUBE_URL" \ |
97 | -U "PEERTUBE_USER" \ | |
98 | --password "PEERTUBE_PASSWORD" \ | |
99 | -t "TARGET_URL" | |
2519d9fe L |
100 | ``` |
101 | ||
a5f0521f RK |
102 | * `PEERTUBE_URL` : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re |
103 | * `PEERTUBE_USER` : your PeerTube account where videos will be uploaded | |
104 | * `PEERTUBE_PASSWORD` : password of your PeerTube account (if omitted, you will be prompted for it) | |
105 | * `TARGET_URL` : the target url you want to import. Examples: | |
106 | * YouTube: | |
107 | * Channel: https://www.youtube.com/channel/ChannelId | |
108 | * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName | |
109 | * Video https://www.youtube.com/watch?v=blabla | |
110 | * Vimeo: https://vimeo.com/xxxxxx | |
111 | * Dailymotion: https://www.dailymotion.com/xxxxx | |
2519d9fe | 112 | |
2186386c C |
113 | The script will get all public videos from Youtube, download them and upload to PeerTube. |
114 | Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection... | |
115 | ||
116 | Videos will be publicly available after transcoding (you can see them before that in your account on the web interface). | |
117 | ||
358770db | 118 | |
8704acf4 | 119 | ### peertube-upload.js |
358770db C |
120 | |
121 | You can use this script to import videos directly from the CLI. | |
122 | ||
2186386c C |
123 | Videos will be publicly available after transcoding (you can see them before that in your account on the web interface). |
124 | ||
358770db | 125 | ``` |
05e67d62 | 126 | $ cd ${CLONE} |
8704acf4 | 127 | $ node dist/server/tools/peertube-upload.js --help |
358770db | 128 | ``` |
a5f0521f | 129 | |
8704acf4 RK |
130 | ### peertube-watch.js |
131 | ||
132 | You can use this script to play videos directly from the CLI. | |
133 | ||
134 | It provides support for different players: | |
135 | ||
136 | - ascii (default ; plays in ascii art in your terminal!) | |
137 | - mpv | |
138 | - mplayer | |
139 | - vlc | |
140 | - stdout | |
141 | - xbmc | |
142 | - airplay | |
143 | - chromecast | |
144 | ||
54a3a12e C |
145 | |
146 | ## Server tools | |
147 | ||
148 | These scripts should be run on the server, in `peertube-latest` directory. | |
a5f0521f | 149 | |
0ee02734 C |
150 | ### parse-log |
151 | ||
152 | To parse PeerTube last log file: | |
153 | ||
154 | ``` | |
155 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run parse-log -- --level info | |
156 | ``` | |
157 | ||
158 | `--level` is optional and could be `info`/`warn`/`error` | |
159 | ||
a5f0521f RK |
160 | ### create-transcoding-job.js |
161 | ||
162 | You can use this script to force transcoding of an existing video. | |
163 | ||
164 | ``` | |
54a3a12e | 165 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] |
a5f0521f | 166 | ``` |
05623b90 F |
167 | |
168 | Or to transcode to a specific resolution: | |
169 | ``` | |
170 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution] | |
171 | ``` | |
a5f0521f RK |
172 | |
173 | ### create-import-video-file-job.js | |
174 | ||
175 | You can use this script to import a video file to replace an already uploaded file or to add a new resolution to a video. | |
176 | ||
177 | ``` | |
54a3a12e C |
178 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile] |
179 | ``` | |
180 | ||
181 | ### prune-storage.js | |
182 | ||
183 | Some transcoded videos or shutdown at a bad time can leave some unused files on your storage. | |
184 | To delete them (a confirmation will be demanded first): | |
185 | ||
a5f0521f | 186 | ``` |
54a3a12e | 187 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage |
23687332 C |
188 | ``` |
189 | ||
edb4ffc7 FA |
190 | ### optimize-old-videos.js |
191 | ||
192 | Before version v1.0.0-beta.16, Peertube did not specify a bitrate for the transcoding of uploaded videos. | |
193 | This means that videos might be encoded into very large files that are too large for streaming. This script | |
194 | re-transcodes these videos so that they can be watched properly, even on slow connections. | |
195 | ||
196 | ``` | |
197 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run optimize-old-videos | |
198 | ``` | |
199 | ||
200 | ||
23687332 C |
201 | ### update-host.js |
202 | ||
203 | If you started PeerTube with a domain, and then changed it you will have invalid torrent files and invalid URLs in your database. | |
204 | To fix this, you have to run: | |
205 | ||
206 | ``` | |
207 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host | |
ecf06378 | 208 | ``` |