aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-01-18 14:29:06 +0100
committerChocobozzz <me@florianbigard.com>2021-01-18 14:29:16 +0100
commit969e59d17d584baf695cf9a7d6122283518386a7 (patch)
treedd0491bd5e047024301722db318d1b7886706ddd /server
parentc86fa51b8a84210f3b9fcbeebc3f03f280d5982d (diff)
downloadPeerTube-969e59d17d584baf695cf9a7d6122283518386a7.tar.gz
PeerTube-969e59d17d584baf695cf9a7d6122283518386a7.tar.zst
PeerTube-969e59d17d584baf695cf9a7d6122283518386a7.zip
Fix youtube import
Diffstat (limited to 'server')
-rw-r--r--server/helpers/youtube-dl.ts16
1 files changed, 12 insertions, 4 deletions
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<YoutubeDLInfo>
55 // this is a merge format and its extension will be appended 55 // this is a merge format and its extension will be appended
56 if (info.ext === 'mp4') { 56 if (info.ext === 'mp4') {
57 info.mergeExt = 'mp4' 57 info.mergeExt = 'mp4'
58 } else if (info.ext === 'webm') {
59 info.mergeExt = 'webm'
58 } else { 60 } else {
59 info.mergeExt = 'mkv' 61 info.mergeExt = 'mkv'
60 } 62 }
@@ -132,11 +134,15 @@ function getYoutubeDLVideoFormat () {
132} 134}
133 135
134function downloadYoutubeDLVideo (url: string, extension: string, timeout: number, mergeExtension?: string) { 136function downloadYoutubeDLVideo (url: string, extension: string, timeout: number, mergeExtension?: string) {
135 const path = generateVideoImportTmpPath(url, extension) 137 let path = generateVideoImportTmpPath(url, extension)
136 const finalPath = mergeExtension ? path.replace(new RegExp(`${extension}$`), mergeExtension) : path 138
139 path = mergeExtension
140 ? path.replace(new RegExp(`${extension}$`), mergeExtension)
141 : path
142
137 let timer 143 let timer
138 144
139 logger.info('Importing youtubeDL video %s to %s', url, finalPath) 145 logger.info('Importing youtubeDL video %s to %s', url, path)
140 146
141 let options = [ '-f', getYoutubeDLVideoFormat(), '-o', path ] 147 let options = [ '-f', getYoutubeDLVideoFormat(), '-o', path ]
142 options = wrapWithProxyOptions(options) 148 options = wrapWithProxyOptions(options)
@@ -145,6 +151,8 @@ function downloadYoutubeDLVideo (url: string, extension: string, timeout: number
145 options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ]) 151 options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ])
146 } 152 }
147 153
154 logger.debug('YoutubeDL options for %s.', url, { options })
155
148 return new Promise<string>((res, rej) => { 156 return new Promise<string>((res, rej) => {
149 safeGetYoutubeDL() 157 safeGetYoutubeDL()
150 .then(youtubeDL => { 158 .then(youtubeDL => {
@@ -158,7 +166,7 @@ function downloadYoutubeDLVideo (url: string, extension: string, timeout: number
158 return rej(err) 166 return rej(err)
159 } 167 }
160 168
161 return res(finalPath) 169 return res(path)
162 }) 170 })
163 171
164 timer = setTimeout(() => { 172 timer = setTimeout(() => {