From 652c64165b3d8d1c5d5fc646c29e5cd1c82a3330 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Apr 2020 14:15:44 +0200 Subject: Fix import captions test --- server/helpers/youtube-dl.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 277422645..6d2e6f6d1 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -21,8 +21,8 @@ export type YoutubeDLInfo = { } export type YoutubeDLSubs = { - language: string, - filename: string, + language: string + filename: string path: string }[] @@ -61,15 +61,20 @@ function getYoutubeDLSubs (url: string, opts?: object): Promise { youtubeDL.getSubs(url, options, (err, files) => { if (err) return rej(err) + logger.debug('Get subtitles from youtube dl.', { url, files }) + const subtitles = files.reduce((acc, filename) => { const matched = filename.match(/\.([a-z]{2})\.(vtt|ttml)/i) if (matched[1]) { - return [...acc, { - language: matched[1], - path: join(cwd, filename), - filename - }] + return [ + ...acc, + { + language: matched[1], + path: join(cwd, filename), + filename + } + ] } }, []) -- cgit v1.2.3