From: Chocobozzz Date: Wed, 17 Jun 2020 07:42:00 +0000 (+0200) Subject: Correctly fix subtitles import X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=982f2fc9b42537ca40ff29bf62c1ca3692d4b587;p=oweals%2Fpeertube.git Correctly fix subtitles import --- 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[1]) { - return [ - ...acc, - { - language: matched[1], - path: join(cwd, filename), - filename - } - ] - } + if (!matched || !matched[1]) return acc + + return [ + ...acc, + { + language: matched[1], + path: join(cwd, filename), + filename + } + ] }, []) return res(subtitles)