aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-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}