diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-15 08:32:06 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-15 08:32:06 +0200 |
commit | b3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b (patch) | |
tree | da107e31b93b558e532739ba7109d8a5ebfa249f /server | |
parent | 1ffb5fb6829e1cb77d0f676775a958f51dd9d794 (diff) | |
download | PeerTube-b3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b.tar.gz PeerTube-b3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b.tar.zst PeerTube-b3fc41a165b4fd039a18d8a7e41dcfeba4f43d7b.zip |
Fix youtube-dl update with proxy
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/requests.ts | 3 | ||||
-rw-r--r-- | server/helpers/youtube-dl.ts | 8 |
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 @@ | |||
1 | import { createWriteStream } from 'fs' | 1 | import { createWriteStream } from 'fs' |
2 | import { ensureDir, move, pathExists, remove, writeFile } from 'fs-extra' | 2 | import { ensureDir, move, pathExists, remove, writeFile } from 'fs-extra' |
3 | import got from 'got' | ||
4 | import { join } from 'path' | 3 | import { join } from 'path' |
5 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
6 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' | 5 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
@@ -9,6 +8,7 @@ import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } | |||
9 | import { peertubeTruncate, pipelinePromise, root } from './core-utils' | 8 | import { peertubeTruncate, pipelinePromise, root } from './core-utils' |
10 | import { isVideoFileExtnameValid } from './custom-validators/videos' | 9 | import { isVideoFileExtnameValid } from './custom-validators/videos' |
11 | import { logger } from './logger' | 10 | import { logger } from './logger' |
11 | import { peertubeGot } from './requests' | ||
12 | import { generateVideoImportTmpPath } from './utils' | 12 | import { generateVideoImportTmpPath } from './utils' |
13 | 13 | ||
14 | export type YoutubeDLInfo = { | 14 | export 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( |