diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | server/tools/import-youtube.ts | 10 | ||||
-rw-r--r-- | support/doc/dependencies.md | 4 | ||||
-rw-r--r-- | support/doc/import-youtube.md | 24 |
4 files changed, 30 insertions, 16 deletions
@@ -147,11 +147,11 @@ See the [docker guide](/support/doc/docker.md) | |||
147 | 147 | ||
148 | See the [production guide](/support/doc/production.md). | 148 | See the [production guide](/support/doc/production.md). |
149 | 149 | ||
150 | ## Contributing | 150 | ## Contributing/Test |
151 | 151 | ||
152 | See the [contributing | 152 | See the [contributing |
153 | guide](/.github/CONTRIBUTING.md) | 153 | guide](/.github/CONTRIBUTING.md) |
154 | to see how to contribute to PeerTube. Spoiler alert: you don't need to be a | 154 | to see how to test or contribute to PeerTube. Spoiler alert: you don't need to be a |
155 | coder to help! | 155 | coder to help! |
156 | 156 | ||
157 | ## API REST documentation | 157 | ## API REST documentation |
@@ -161,6 +161,10 @@ For now only on Github: | |||
161 | * HTML version: [/support/doc/api/html/index.html](/support/doc/api/html/index.html) | 161 | * HTML version: [/support/doc/api/html/index.html](/support/doc/api/html/index.html) |
162 | * Swagger/OpenAPI schema: [/support/doc/api/openapi.yaml](/support/doc/api/openapi.yaml) | 162 | * Swagger/OpenAPI schema: [/support/doc/api/openapi.yaml](/support/doc/api/openapi.yaml) |
163 | 163 | ||
164 | ## Tools | ||
165 | |||
166 | * [YouTube import](/support/doc/import-youtube.md) | ||
167 | |||
164 | ## Architecture | 168 | ## Architecture |
165 | 169 | ||
166 | See [ARCHITECTURE.md](/ARCHITECTURE.md) for a more detailed explanation. | 170 | See [ARCHITECTURE.md](/ARCHITECTURE.md) for a more detailed explanation. |
diff --git a/server/tools/import-youtube.ts b/server/tools/import-youtube.ts index 68893306f..e51a66e5f 100644 --- a/server/tools/import-youtube.ts +++ b/server/tools/import-youtube.ts | |||
@@ -52,10 +52,16 @@ async function run () { | |||
52 | youtubeDL.getInfo(program['youtubeUrl'], options, processOptions, async (err, info) => { | 52 | youtubeDL.getInfo(program['youtubeUrl'], options, processOptions, async (err, info) => { |
53 | if (err) throw err | 53 | if (err) throw err |
54 | 54 | ||
55 | let infoArray: any[] | ||
56 | |||
55 | // Normalize utf8 fields | 57 | // Normalize utf8 fields |
56 | info = info.map(i => normalizeObject(i)) | 58 | if (Array.isArray(info) === true) { |
59 | infoArray = info.map(i => normalizeObject(i)) | ||
60 | } else { | ||
61 | infoArray = [ normalizeObject(info) ] | ||
62 | } | ||
57 | 63 | ||
58 | const videos = info.map(i => { | 64 | const videos = infoArray.map(i => { |
59 | return { url: 'https://www.youtube.com/watch?v=' + i.id, name: i.title } | 65 | return { url: 'https://www.youtube.com/watch?v=' + i.id, name: i.title } |
60 | }) | 66 | }) |
61 | 67 | ||
diff --git a/support/doc/dependencies.md b/support/doc/dependencies.md index a4a30374c..4ced42b8b 100644 --- a/support/doc/dependencies.md +++ b/support/doc/dependencies.md | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | ``` | 11 | ``` |
12 | $ sudo apt update | 12 | $ sudo apt update |
13 | $ sudo apt install nginx ffmpeg postgresql openssl g++ make redis-server git | 13 | $ sudo apt install nginx ffmpeg postgresql openssl g++ make redis-server |
14 | ``` | 14 | ``` |
15 | 15 | ||
16 | ## Arch Linux | 16 | ## Arch Linux |
@@ -36,7 +36,7 @@ $ sudo pacman -S nodejs yarn ffmpeg postgresql openssl redis | |||
36 | $ sudo yum update | 36 | $ sudo yum update |
37 | $ sudo yum install epel-release | 37 | $ sudo yum install epel-release |
38 | $ sudo yum update | 38 | $ sudo yum update |
39 | $ sudo yum install nginx postgresql postgresql-server openssl gcc make redis git | 39 | $ sudo yum install nginx postgresql postgresql-server openssl gcc make redis |
40 | ``` | 40 | ``` |
41 | 41 | ||
42 | ## Other distributions | 42 | ## Other distributions |
diff --git a/support/doc/import-youtube.md b/support/doc/import-youtube.md index 3b8b515a7..39f01b85b 100644 --- a/support/doc/import-youtube.md +++ b/support/doc/import-youtube.md | |||
@@ -11,19 +11,20 @@ Be sure you own the videos or have the author's authorization to do so. | |||
11 | ## Prerequisites | 11 | ## Prerequisites |
12 | 12 | ||
13 | You need at least 512MB RAM to run the script. | 13 | You need at least 512MB RAM to run the script. |
14 | Importation can be launched directly from a peertube server (in this case you already have dependencies installed :+1:) or from a separate server, even a dekstop PC. | 14 | Importation can be launched directly from a PeerTube server (in this case you already have dependencies installed :+1:) or from a separate server, even a dekstop PC. |
15 | 15 | ||
16 | ### Dependencies | 16 | ### Dependencies |
17 | 17 | ||
18 | If you do not run the script from a Peertube server, you need to follow the steps of the [dependencies guide](dependencies.md). | 18 | * [PeerTube dependencies](dependencies.md) |
19 | * git | ||
19 | 20 | ||
20 | ### Installation | 21 | ### Installation |
21 | 22 | ||
22 | Clone the Peertube repo to get the latest version inside your server: | 23 | Clone the PeerTube repo to get the latest version: |
23 | 24 | ||
24 | ``` | 25 | ``` |
25 | git clone https://github.com/Chocobozzz/PeerTube.git | 26 | git clone https://github.com/Chocobozzz/PeerTube.git |
26 | CLONE="$(pwd)/Peertube" | 27 | CLONE="$(pwd)/PeerTube" |
27 | ``` | 28 | ``` |
28 | 29 | ||
29 | Run ``yarn install`` | 30 | Run ``yarn install`` |
@@ -48,10 +49,13 @@ cd ${CLONE} | |||
48 | node dist/server/tools/import-youtube.js -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD" -y "YOUTUBE_URL" | 49 | node dist/server/tools/import-youtube.js -u "PEERTUBE_URL" -U "PEERTUBE_USER" --password "PEERTUBE_PASSWORD" -y "YOUTUBE_URL" |
49 | ``` | 50 | ``` |
50 | 51 | ||
51 | - PEERTUBE_URL : the full URL of your peertube server where you want to import, eg: https://peertube.cpy.re/ | 52 | * PEERTUBE_URL : the full URL of your PeerTube server where you want to import, eg: https://peertube.cpy.re/ |
52 | - PEERTUBE_USER : your peertube account where videos will be uploaded | 53 | * PEERTUBE_USER : your PeerTube account where videos will be uploaded |
53 | - PEERTUBE_PASSWORD : password of your peertube account | 54 | * PEERTUBE_PASSWORD : password of your PeerTube account |
54 | - YOUTUBE_URL : the youtube channel you want to import. Supports Youtube channel (eg https://www.youtube.com/channel/ChannelId) or Youtube user (eg: https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName) | 55 | * YOUTUBE_URL : the youtube video/user/channel/playlist you want to import. Examples: |
56 | * Channel: https://www.youtube.com/channel/ChannelId | ||
57 | * User https://www.youtube.com/c/UserName or https://www.youtube.com/user/UserName | ||
58 | * Video https://www.youtube.com/watch?v=blabla | ||
55 | 59 | ||
56 | The script will get all public videos from Youtube, download them, then upload to Peertube. | 60 | The script will get all public videos from Youtube, download them and upload to PeerTube. |
57 | Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection, ... without problem. \ No newline at end of file | 61 | Already downloaded videos will not be uploaded twice, so you can run and re-run the script in case of crash, disconnection... |