From 35501c0fa7be9cb71e992c37e06f3cd01afc510b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 19 Feb 2018 11:12:58 +0100 Subject: Add ability to import just one video from youtube --- server/tools/import-youtube.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'server') 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 () { youtubeDL.getInfo(program['youtubeUrl'], options, processOptions, async (err, info) => { if (err) throw err + let infoArray: any[] + // Normalize utf8 fields - info = info.map(i => normalizeObject(i)) + if (Array.isArray(info) === true) { + infoArray = info.map(i => normalizeObject(i)) + } else { + infoArray = [ normalizeObject(info) ] + } - const videos = info.map(i => { + const videos = infoArray.map(i => { return { url: 'https://www.youtube.com/watch?v=' + i.id, name: i.title } }) -- cgit v1.2.3