]>
Commit | Line | Data |
---|---|---|
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 |
13 | You need at least 512MB RAM to run the script. |
14 | Scripts can be launched directly from a PeerTube server, or from a separate server, even a desktop PC. | |
05e67d62 | 15 | You need to follow all the following steps even if you are on a PeerTube server. |
2519d9fe L |
16 | |
17 | ### Dependencies | |
18 | ||
358770db | 19 | Install the [PeerTube dependencies](dependencies.md). |
2519d9fe L |
20 | |
21 | ### Installation | |
22 | ||
99402413 | 23 | Clone 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 | ||
30 | Run ``yarn install`` | |
31 | ``` | |
05e67d62 C |
32 | $ cd ${CLONE} |
33 | $ yarn install | |
2519d9fe L |
34 | ``` |
35 | ||
36 | Build server tools: | |
37 | ``` | |
05e67d62 C |
38 | $ cd ${CLONE} |
39 | $ npm run build:server | |
2519d9fe L |
40 | ``` |
41 | ||
358770db C |
42 | ### import-videos.js |
43 | ||
44 | 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. | |
45 | Be 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 |
66 | The script will get all public videos from Youtube, download them and upload to PeerTube. |
67 | Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection... | |
68 | ||
69 | Videos 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 | ||
74 | You can use this script to import videos directly from the CLI. | |
75 | ||
2186386c C |
76 | Videos 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 | ||
86 | These scripts should be run on the server, in `peertube-latest` directory. | |
a5f0521f RK |
87 | |
88 | ### create-transcoding-job.js | |
89 | ||
90 | You can use this script to force transcoding of an existing video. | |
91 | ||
92 | ``` | |
54a3a12e | 93 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] |
a5f0521f | 94 | ``` |
05623b90 F |
95 | |
96 | Or to transcode to a specific resolution: | |
97 | ``` | |
98 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution] | |
99 | ``` | |
a5f0521f RK |
100 | |
101 | ### create-import-video-file-job.js | |
102 | ||
103 | 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. | |
104 | ||
105 | ``` | |
54a3a12e C |
106 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-import-video-file-job -- -v [videoUUID] -i [videoFile] |
107 | ``` | |
108 | ||
109 | ### prune-storage.js | |
110 | ||
111 | Some transcoded videos or shutdown at a bad time can leave some unused files on your storage. | |
112 | To delete them (a confirmation will be demanded first): | |
113 | ||
a5f0521f | 114 | ``` |
54a3a12e | 115 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run prune-storage |
23687332 C |
116 | ``` |
117 | ||
118 | ### update-host.js | |
119 | ||
120 | If you started PeerTube with a domain, and then changed it you will have invalid torrent files and invalid URLs in your database. | |
121 | To fix this, you have to run: | |
122 | ||
123 | ``` | |
124 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run update-host | |
54a3a12e | 125 | ``` |