X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fyoutube-dl.ts;h=c2aa8870ae3b5d7627899077b6138241b750ab35;hb=c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e;hp=2014aab0a486ae5f0007bbb35c638594e6f6a95c;hpb=c7763eddd14ee6a4a448d5187f46f79b22047d20;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 2014aab0a..c2aa8870a 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) @@ -139,7 +138,7 @@ async function updateYoutubeDLBinary () { const binDirectory = join(root(), 'node_modules', 'youtube-dl', 'bin') const bin = join(binDirectory, 'youtube-dl') const detailsPath = join(binDirectory, 'details') - const url = 'https://yt-dl.org/downloads/latest/youtube-dl' + const url = process.env.YOUTUBE_DL_DOWNLOAD_HOST || 'https://yt-dl.org/downloads/latest/youtube-dl' await ensureDir(binDirectory)