aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-22 17:19:03 +0100
committerChocobozzz <me@florianbigard.com>2020-01-22 17:19:03 +0100
commit93905586ee198d4ac0a0fd5141a9fcbb10a94652 (patch)
tree6dd8fb2ff89e5e50f5cb67156c417323fbcd8919
parentfef213cae10cbbf760b5ec81a1ed154038b59a61 (diff)
downloadPeerTube-93905586ee198d4ac0a0fd5141a9fcbb10a94652.tar.gz
PeerTube-93905586ee198d4ac0a0fd5141a9fcbb10a94652.tar.zst
PeerTube-93905586ee198d4ac0a0fd5141a9fcbb10a94652.zip
Proxy youtube-dl format command too
-rw-r--r--server/helpers/youtube-dl.ts20
1 files changed, 13 insertions, 7 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index d17c9d554..577a59dbf 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -25,7 +25,8 @@ const processOptions = {
25 25
26function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo> { 26function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo> {
27 return new Promise<YoutubeDLInfo>(async (res, rej) => { 27 return new Promise<YoutubeDLInfo>(async (res, rej) => {
28 const args = opts || [ '-j', '--flat-playlist' ] 28 let args = opts || [ '-j', '--flat-playlist' ]
29 args = wrapWithProxyOptions(args)
29 30
30 const youtubeDL = await safeGetYoutubeDL() 31 const youtubeDL = await safeGetYoutubeDL()
31 youtubeDL.getInfo(url, args, processOptions, (err, info) => { 32 youtubeDL.getInfo(url, args, processOptions, (err, info) => {
@@ -47,12 +48,7 @@ function downloadYoutubeDLVideo (url: string, timeout: number) {
47 logger.info('Importing youtubeDL video %s', url) 48 logger.info('Importing youtubeDL video %s', url)
48 49
49 let options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] 50 let options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ]
50 51 options = wrapWithProxyOptions(options)
51 if (CONFIG.IMPORT.VIDEOS.HTTP.PROXY.ENABLED) {
52 logger.debug('Using proxy for YoutubeDL')
53
54 options = [ '--proxy', CONFIG.IMPORT.VIDEOS.HTTP.PROXY.URL ].concat(options)
55 }
56 52
57 if (process.env.FFMPEG_PATH) { 53 if (process.env.FFMPEG_PATH) {
58 options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ]) 54 options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ])
@@ -270,3 +266,13 @@ function getCategory (categories: string[]) {
270 266
271 return undefined 267 return undefined
272} 268}
269
270function wrapWithProxyOptions (options: string[]) {
271 if (CONFIG.IMPORT.VIDEOS.HTTP.PROXY.ENABLED) {
272 logger.debug('Using proxy for YoutubeDL')
273
274 return [ '--proxy', CONFIG.IMPORT.VIDEOS.HTTP.PROXY.URL ].concat(options)
275 }
276
277 return options
278}