Fix youtube import

pull/3616/head
Chocobozzz 2021-01-18 14:29:06 +01:00
parent c86fa51b8a
commit 969e59d17d
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 12 additions and 4 deletions

View File

@ -55,6 +55,8 @@ function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo>
// this is a merge format and its extension will be appended // this is a merge format and its extension will be appended
if (info.ext === 'mp4') { if (info.ext === 'mp4') {
info.mergeExt = 'mp4' info.mergeExt = 'mp4'
} else if (info.ext === 'webm') {
info.mergeExt = 'webm'
} else { } else {
info.mergeExt = 'mkv' info.mergeExt = 'mkv'
} }
@ -132,11 +134,15 @@ function getYoutubeDLVideoFormat () {
} }
function downloadYoutubeDLVideo (url: string, extension: string, timeout: number, mergeExtension?: string) { function downloadYoutubeDLVideo (url: string, extension: string, timeout: number, mergeExtension?: string) {
const path = generateVideoImportTmpPath(url, extension) let path = generateVideoImportTmpPath(url, extension)
const finalPath = mergeExtension ? path.replace(new RegExp(`${extension}$`), mergeExtension) : path
path = mergeExtension
? path.replace(new RegExp(`${extension}$`), mergeExtension)
: path
let timer 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 ] let options = [ '-f', getYoutubeDLVideoFormat(), '-o', path ]
options = wrapWithProxyOptions(options) options = wrapWithProxyOptions(options)
@ -145,6 +151,8 @@ function downloadYoutubeDLVideo (url: string, extension: string, timeout: number
options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ]) options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ])
} }
logger.debug('YoutubeDL options for %s.', url, { options })
return new Promise<string>((res, rej) => { return new Promise<string>((res, rej) => {
safeGetYoutubeDL() safeGetYoutubeDL()
.then(youtubeDL => { .then(youtubeDL => {
@ -158,7 +166,7 @@ function downloadYoutubeDLVideo (url: string, extension: string, timeout: number
return rej(err) return rej(err)
} }
return res(finalPath) return res(path)
}) })
timer = setTimeout(() => { timer = setTimeout(() => {