]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - support/doc/tools.md
Merge branch 'release/v1.0.0' into develop
[github/Chocobozzz/PeerTube.git] / support / doc / tools.md
1 # CLI tools guide
2 - [CLI wrapper](#cli-wrapper)
3 - [Remote tools](#remote-tools)
4 - [peertube-import-videos.js](#peertube-import-videosjs)
5 - [peertube-upload.js](#peertube-uploadjs)
6 - [peertube-watch.js](#peertube-watch)
7 - [Server tools](#server-tools)
8 - [parse-log](#parse-log)
9 - [create-transcoding-job.js](#create-transcoding-jobjs)
10 - [create-import-video-file-job.js](#create-import-video-file-jobjs)
11 - [prune-storage.js](#prune-storagejs)
12
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
58 ## Remote Tools
59
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.
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).
63
64 ### Dependencies
65
66 Install the [PeerTube dependencies](dependencies.md).
67
68 ### Installation
69
70 Clone the PeerTube repo to get the latest version (even if you are on your PeerTube server):
71
72 ```
73 $ git clone https://github.com/Chocobozzz/PeerTube.git
74 $ CLONE="$(pwd)/PeerTube"
75 ```
76
77 Run ``yarn install``
78 ```
79 $ cd ${CLONE}
80 $ yarn install
81 ```
82
83 Build server tools:
84 ```
85 $ cd ${CLONE}
86 $ npm run build:server
87 ```
88
89 ### peertube-import-videos.js
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.
93
94 ```sh
95 $ node dist/server/tools/peertube-import-videos.js \
96 -u "PEERTUBE_URL" \
97 -U "PEERTUBE_USER" \
98 --password "PEERTUBE_PASSWORD" \
99 -t "TARGET_URL"
100 ```
101
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
112
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
118
119 ### peertube-upload.js
120
121 You can use this script to import videos directly from the CLI.
122
123 Videos will be publicly available after transcoding (you can see them before that in your account on the web interface).
124
125 ```
126 $ cd ${CLONE}
127 $ node dist/server/tools/peertube-upload.js --help
128 ```
129
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
145
146 ## Server tools
147
148 These scripts should be run on the server, in `peertube-latest` directory.
149
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
160 ### create-transcoding-job.js
161
162 You can use this script to force transcoding of an existing video.
163
164 ```
165 $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID]
166 ```
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 ```
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 ```
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
186 ```
187 $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage
188 ```
189
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
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
208 ```