From 982f2fc9b42537ca40ff29bf62c1ca3692d4b587 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 17 Jun 2020 09:42:00 +0200 Subject: [PATCH] Correctly fix subtitles import --- server/helpers/youtube-dl.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 2014aab0a..bb5930952 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -67,17 +67,16 @@ function getYoutubeDLSubs (url: string, opts?: object): Promise { const subtitles = files.reduce((acc, filename) => { const matched = filename.match(/\.([a-z]{2})\.(vtt|ttml)/i) + if (!matched || !matched[1]) return acc - if (matched[1]) { - return [ - ...acc, - { - language: matched[1], - path: join(cwd, filename), - filename - } - ] - } + return [ + ...acc, + { + language: matched[1], + path: join(cwd, filename), + filename + } + ] }, []) return res(subtitles)