aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-21 15:59:57 +0100
committerChocobozzz <me@florianbigard.com>2020-01-21 16:46:59 +0100
commitbe7ca0c6b9c51c639bac7d2da94599893e7b1c01 (patch)
tree328eadc393cd7b052f8366f888e968b561ad86c2
parent5e0171daaa00d7d1409b1d2408f03468e895459b (diff)
downloadPeerTube-be7ca0c6b9c51c639bac7d2da94599893e7b1c01.tar.gz
PeerTube-be7ca0c6b9c51c639bac7d2da94599893e7b1c01.tar.zst
PeerTube-be7ca0c6b9c51c639bac7d2da94599893e7b1c01.zip
Use a proxy for youtube-dl to avoid travis errors
-rw-r--r--config/default.yaml4
-rw-r--r--config/production.yaml.example4
-rw-r--r--config/test.yaml3
-rwxr-xr-xscripts/ci.sh4
-rw-r--r--server/helpers/youtube-dl.ts12
-rw-r--r--server/initializers/config.ts6
6 files changed, 29 insertions, 4 deletions
diff --git a/config/default.yaml b/config/default.yaml
index ce2b20c75..3260c62fc 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -234,6 +234,10 @@ import:
234 videos: 234 videos:
235 http: # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html 235 http: # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html
236 enabled: false 236 enabled: false
237 # You can use an HTTP/HTTPS/SOCKS proxy with youtube-dl
238 proxy:
239 enabled: false
240 url: ""
237 torrent: # Magnet URI or torrent file (use classic TCP/UDP/WebSeed to download the file) 241 torrent: # Magnet URI or torrent file (use classic TCP/UDP/WebSeed to download the file)
238 enabled: false 242 enabled: false
239 243
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 52892acfb..30cd2ffe0 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -248,6 +248,10 @@ import:
248 videos: 248 videos:
249 http: # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html 249 http: # Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html
250 enabled: false 250 enabled: false
251 # You can use an HTTP/HTTPS/SOCKS proxy with youtube-dl
252 proxy:
253 enabled: false
254 url: ""
251 torrent: # Magnet URI or torrent file (use classic TCP/UDP/WebSeed to download the file) 255 torrent: # Magnet URI or torrent file (use classic TCP/UDP/WebSeed to download the file)
252 enabled: false 256 enabled: false
253 257
diff --git a/config/test.yaml b/config/test.yaml
index 3ab391504..5d98b41c4 100644
--- a/config/test.yaml
+++ b/config/test.yaml
@@ -86,6 +86,9 @@ import:
86 videos: 86 videos:
87 http: 87 http:
88 enabled: true 88 enabled: true
89 proxy:
90 enabled: false
91 url: ""
89 torrent: 92 torrent:
90 enabled: true 93 enabled: true
91 94
diff --git a/scripts/ci.sh b/scripts/ci.sh
index 270a2b5bc..7b5c3f2bb 100755
--- a/scripts/ci.sh
+++ b/scripts/ci.sh
@@ -9,6 +9,8 @@ fi
9 9
10killall -q peertube || true 10killall -q peertube || true
11 11
12perl -0777 -i -pe 's#(proxy:\n\s+enabled: false\n\s+)url: ""#$1url: "'"$PROXY_URL"'"#' config/test.yaml
13
12if [ "$1" = "misc" ]; then 14if [ "$1" = "misc" ]; then
13 npm run build -- --light-fr 15 npm run build -- --light-fr
14 mocha --timeout 5000 --exit --require ts-node/register --require tsconfig-paths/register --bail server/tests/client.ts \ 16 mocha --timeout 5000 --exit --require ts-node/register --require tsconfig-paths/register --bail server/tests/client.ts \
@@ -40,3 +42,5 @@ elif [ "$1" = "lint" ]; then
40 npm run lint 42 npm run lint
41 ) 43 )
42fi 44fi
45
46git checkout -- config/test.yaml
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'
6import { ensureDir, remove, writeFile } from 'fs-extra' 6import { ensureDir, remove, writeFile } from 'fs-extra'
7import * as request from 'request' 7import * as request from 'request'
8import { createWriteStream } from 'fs' 8import { createWriteStream } from 'fs'
9import { CONFIG } from '@server/initializers/config'
9 10
10export type YoutubeDLInfo = { 11export type YoutubeDLInfo = {
11 name?: string 12 name?: string
@@ -45,11 +46,16 @@ function downloadYoutubeDLVideo (url: string, timeout: number) {
45 46
46 logger.info('Importing youtubeDL video %s', url) 47 logger.info('Importing youtubeDL video %s', url)
47 48
48 const options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ] 49 let options = [ '-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best', '-o', path ]
50
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 }
49 56
50 if (process.env.FFMPEG_PATH) { 57 if (process.env.FFMPEG_PATH) {
51 options.push('--ffmpeg-location') 58 options = options.concat([ '--ffmpeg-location', process.env.FFMPEG_PATH ])
52 options.push(process.env.FFMPEG_PATH)
53 } 59 }
54 60
55 return new Promise<string>(async (res, rej) => { 61 return new Promise<string>(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 = {
191 IMPORT: { 191 IMPORT: {
192 VIDEOS: { 192 VIDEOS: {
193 HTTP: { 193 HTTP: {
194 get ENABLED () { return config.get<boolean>('import.videos.http.enabled') } 194 get ENABLED () { return config.get<boolean>('import.videos.http.enabled') },
195 PROXY: {
196 get ENABLED () { return config.get<boolean>('import.videos.http.proxy.enabled') },
197 get URL () { return config.get<string>('import.videos.http.proxy.url') }
198 }
195 }, 199 },
196 TORRENT: { 200 TORRENT: {
197 get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') } 201 get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') }