From: Chocobozzz Date: Mon, 18 Jan 2021 13:29:06 +0000 (+0100) Subject: Fix youtube import X-Git-Tag: v3.1.0-rc.1~301 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=969e59d17d584baf695cf9a7d6122283518386a7;p=github%2FChocobozzz%2FPeerTube.git Fix youtube import --- diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 23982d528..72d457bc1 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -55,6 +55,8 @@ function getYoutubeDLInfo (url: string, opts?: string[]): Promise // this is a merge format and its extension will be appended if (info.ext === 'mp4') { info.mergeExt = 'mp4' + } else if (info.ext === 'webm') { + info.mergeExt = 'webm' } else { info.mergeExt = 'mkv' } @@ -132,11 +134,15 @@ function getYoutubeDLVideoFormat () { } function downloadYoutubeDLVideo (url: string, extension: string, timeout: number, mergeExtension?: string) { - const path = generateVideoImportTmpPath(url, extension) - const finalPath = mergeExtension ? path.replace(new RegExp(`${extension}$`), mergeExtension) : path + let path = generateVideoImportTmpPath(url, extension) + + path = mergeExtension + ? path.replace(new RegExp(`${extension}$`), mergeExtension) + : path + let timer - logger.info('Importing youtubeDL video %s to %s', url, finalPath) + logger.info('Importing youtubeDL video %s to %s', url, path) let options = [ '-f', getYoutubeDLVideoFormat(), '-o', path ] options = wrapWithProxyOptions(options) @@ -145,6 +151,8 @@ function downloadYoutubeDLVideo (url: string, extension: string, timeout: number options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ]) } + logger.debug('YoutubeDL options for %s.', url, { options }) + return new Promise((res, rej) => { safeGetYoutubeDL() .then(youtubeDL => { @@ -158,7 +166,7 @@ function downloadYoutubeDLVideo (url: string, extension: string, timeout: number return rej(err) } - return res(finalPath) + return res(path) }) timer = setTimeout(() => {