aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/youtube-dl.ts')
-rw-r--r--server/helpers/youtube-dl.ts8
1 files changed, 5 insertions, 3 deletions
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(