From be7ca0c6b9c51c639bac7d2da94599893e7b1c01 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 21 Jan 2020 15:59:57 +0100 Subject: Use a proxy for youtube-dl to avoid travis errors --- server/helpers/youtube-dl.ts | 12 +++++++++--- server/initializers/config.ts | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 87a0d0584..d17c9d554 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -6,6 +6,7 @@ import { peertubeTruncate, root } from './core-utils' import { ensureDir, remove, writeFile } from 'fs-extra' import * as request from 'request' import { createWriteStream } from 'fs' +import { CONFIG } from '@server/initializers/config' export type YoutubeDLInfo = { name?: string @@ -45,11 +46,16 @@ function downloadYoutubeDLVideo (url: string, timeout: number) { logger.info('Importing youtubeDL video %s', url) - const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] + let options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] + + if (CONFIG.IMPORT.VIDEOS.HTTP.PROXY.ENABLED) { + logger.debug('Using proxy for YoutubeDL') + + options = [ '--proxy', CONFIG.IMPORT.VIDEOS.HTTP.PROXY.URL ].concat(options) + } if (process.env.FFMPEG_PATH) { - options.push('--ffmpeg-location') - options.push(process.env.FFMPEG_PATH) + options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ]) } return new Promise(async (res, rej) => { diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 95b069533..7fd77f3e8 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -191,7 +191,11 @@ const CONFIG = { IMPORT: { VIDEOS: { HTTP: { - get ENABLED () { return config.get('import.videos.http.enabled') } + get ENABLED () { return config.get('import.videos.http.enabled') }, + PROXY: { + get ENABLED () { return config.get('import.videos.http.proxy.enabled') }, + get URL () { return config.get('import.videos.http.proxy.url') } + } }, TORRENT: { get ENABLED () { return config.get('import.videos.torrent.enabled') } -- cgit v1.2.3