diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-19 11:12:58 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-19 11:12:58 +0100 |
commit | 35501c0fa7be9cb71e992c37e06f3cd01afc510b (patch) | |
tree | 705902d13c0ed812bb9295b64996d3168a3ec543 /server/tools/import-youtube.ts | |
parent | 1263fc4e6eff9ba4bf4c706c6e37c2e556bf8eb5 (diff) | |
download | PeerTube-35501c0fa7be9cb71e992c37e06f3cd01afc510b.tar.gz PeerTube-35501c0fa7be9cb71e992c37e06f3cd01afc510b.tar.zst PeerTube-35501c0fa7be9cb71e992c37e06f3cd01afc510b.zip |
Add ability to import just one video from youtube
Diffstat (limited to 'server/tools/import-youtube.ts')
-rw-r--r-- | server/tools/import-youtube.ts | 10 |
1 files changed, 8 insertions, 2 deletions
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 | ||