From f97d299230636b0030ccd6314bf63c304378bed6 Mon Sep 17 00:00:00 2001 From: memorybox Date: Tue, 3 Apr 2018 02:28:25 +0800 Subject: fix #456 catching errors in import-videos (#457) --- server/tools/import-videos.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/server/tools/import-videos.ts b/server/tools/import-videos.ts index 809d69e4c..2f38ea7c7 100644 --- a/server/tools/import-videos.ts +++ b/server/tools/import-videos.ts @@ -76,7 +76,6 @@ async function run () { await processVideo(info, program['language']) } - // https://www.youtube.com/watch?v=2Upx39TBc1s console.log('I\'m finished!') process.exit(0) }) @@ -103,15 +102,21 @@ function processVideo (info: any, languageCode: number) { console.log('Downloading video "%s"...', videoInfo.title) const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] - youtubeDL.exec(videoInfo.url, options, processOptions, async (err, output) => { - if (err) return console.error(err) - - console.log(output.join('\n')) - - await uploadVideoOnPeerTube(normalizeObject(videoInfo), path, languageCode) - + try { + youtubeDL.exec(videoInfo.url, options, processOptions, async (err, output) => { + if (err) { + console.error(err) + return res() + } + + console.log(output.join('\n')) + await uploadVideoOnPeerTube(normalizeObject(videoInfo), path, languageCode) + return res() + }) + } catch (err) { + console.log(err.message) return res() - }) + } }) } -- cgit v1.2.3