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