aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-15 08:32:06 +0200
committerChocobozzz <me@florianbigard.com>2021-10-15 08:32:06 +0200
commitb3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b (patch)
treeda107e31b93b558e532739ba7109d8a5ebfa249f /server/helpers
parent1ffb5fb6829e1cb77d0f676775a958f51dd9d794 (diff)
downloadPeerTube-b3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b.tar.gz
PeerTube-b3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b.tar.zst
PeerTube-b3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b.zip
Fix youtube-dl update with proxy
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/requests.ts3
-rw-r--r--server/helpers/youtube-dl.ts8
2 files changed, 7 insertions, 4 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts
index 74ed1d786..991270952 100644
--- a/server/helpers/requests.ts
+++ b/server/helpers/requests.ts
@@ -186,7 +186,8 @@ export {
186 doRequest, 186 doRequest,
187 doJSONRequest, 187 doJSONRequest,
188 doRequestAndSaveToFile, 188 doRequestAndSaveToFile,
189 downloadImage 189 downloadImage,
190 peertubeGot
190} 191}
191 192
192// --------------------------------------------------------------------------- 193// ---------------------------------------------------------------------------
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 3072affed..0392ec4c7 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -1,6 +1,5 @@
1import { createWriteStream } from 'fs' 1import { createWriteStream } from 'fs'
2import { ensureDir, move, pathExists, remove, writeFile } from 'fs-extra' 2import { ensureDir, move, pathExists, remove, writeFile } from 'fs-extra'
3import got from 'got'
4import { join } from 'path' 3import { join } from 'path'
5import { CONFIG } from '@server/initializers/config' 4import { CONFIG } from '@server/initializers/config'
6import { HttpStatusCode } from '../../shared/models/http/http-error-codes' 5import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
@@ -9,6 +8,7 @@ import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES }
9import { peertubeTruncate, pipelinePromise, root } from './core-utils' 8import { peertubeTruncate, pipelinePromise, root } from './core-utils'
10import { isVideoFileExtnameValid } from './custom-validators/videos' 9import { isVideoFileExtnameValid } from './custom-validators/videos'
11import { logger } from './logger' 10import { logger } from './logger'
11import { peertubeGot } from './requests'
12import { generateVideoImportTmpPath } from './utils' 12import { generateVideoImportTmpPath } from './utils'
13 13
14export type YoutubeDLInfo = { 14export type YoutubeDLInfo = {
@@ -343,7 +343,9 @@ class YoutubeDL {
343 await ensureDir(binDirectory) 343 await ensureDir(binDirectory)
344 344
345 try { 345 try {
346 const result = await got(url, { followRedirect: false }) 346 const gotContext = { bodyKBLimit: 20_000 }
347
348 const result = await peertubeGot(url, { followRedirect: false, context: gotContext })
347 349
348 if (result.statusCode !== HttpStatusCode.FOUND_302) { 350 if (result.statusCode !== HttpStatusCode.FOUND_302) {
349 logger.error('youtube-dl update error: did not get redirect for the latest version link. Status %d', result.statusCode) 351 logger.error('youtube-dl update error: did not get redirect for the latest version link. Status %d', result.statusCode)
@@ -353,7 +355,7 @@ class YoutubeDL {
353 const newUrl = result.headers.location 355 const newUrl = result.headers.location
354 const newVersion = /\/(\d{4}\.\d\d\.\d\d(\.\d)?)\/youtube-dl$/.exec(newUrl)[1] 356 const newVersion = /\/(\d{4}\.\d\d\.\d\d(\.\d)?)\/youtube-dl$/.exec(newUrl)[1]
355 357
356 const downloadFileStream = got.stream(newUrl) 358 const downloadFileStream = peertubeGot.stream(newUrl, { context: gotContext })
357 const writeStream = createWriteStream(bin, { mode: 493 }) 359 const writeStream = createWriteStream(bin, { mode: 493 })
358 360
359 await pipelinePromise( 361 await pipelinePromise(