diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-21 16:28:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-22 10:25:24 +0200 |
commit | 62549e6c9818f422698f030e0b242609115493ed (patch) | |
tree | 12a969f694239fe5f926f779698df9523605ee80 /server/helpers/requests.ts | |
parent | a71d4140a5b7831dbe2eb7a0dfaa6a755cb2e906 (diff) | |
download | PeerTube-62549e6c9818f422698f030e0b242609115493ed.tar.gz PeerTube-62549e6c9818f422698f030e0b242609115493ed.tar.zst PeerTube-62549e6c9818f422698f030e0b242609115493ed.zip |
Rewrite youtube-dl import
Use python3 binary
Allows to use a custom youtube-dl release URL
Allows to use yt-dlp (youtube-dl fork)
Remove proxy config from configuration to use HTTP_PROXY and HTTPS_PROXY
env variables
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r-- | server/helpers/requests.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index 991270952..d93f55776 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { createWriteStream, remove } from 'fs-extra' | 1 | import { createWriteStream, remove } from 'fs-extra' |
2 | import got, { CancelableRequest, Options as GotOptions, RequestError } from 'got' | 2 | import got, { CancelableRequest, Options as GotOptions, RequestError, Response } from 'got' |
3 | import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' | 3 | import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { CONFIG } from '../initializers/config' | 5 | import { CONFIG } from '../initializers/config' |
6 | import { ACTIVITY_PUB, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' | 6 | import { ACTIVITY_PUB, BINARY_CONTENT_TYPES, PEERTUBE_VERSION, REQUEST_TIMEOUT, WEBSERVER } from '../initializers/constants' |
7 | import { pipelinePromise } from './core-utils' | 7 | import { pipelinePromise } from './core-utils' |
8 | import { processImage } from './image-utils' | 8 | import { processImage } from './image-utils' |
9 | import { logger } from './logger' | 9 | import { logger } from './logger' |
@@ -180,12 +180,17 @@ function getUserAgent () { | |||
180 | return `PeerTube/${PEERTUBE_VERSION} (+${WEBSERVER.URL})` | 180 | return `PeerTube/${PEERTUBE_VERSION} (+${WEBSERVER.URL})` |
181 | } | 181 | } |
182 | 182 | ||
183 | function isBinaryResponse (result: Response<any>) { | ||
184 | return BINARY_CONTENT_TYPES.has(result.headers['content-type']) | ||
185 | } | ||
186 | |||
183 | // --------------------------------------------------------------------------- | 187 | // --------------------------------------------------------------------------- |
184 | 188 | ||
185 | export { | 189 | export { |
186 | doRequest, | 190 | doRequest, |
187 | doJSONRequest, | 191 | doJSONRequest, |
188 | doRequestAndSaveToFile, | 192 | doRequestAndSaveToFile, |
193 | isBinaryResponse, | ||
189 | downloadImage, | 194 | downloadImage, |
190 | peertubeGot | 195 | peertubeGot |
191 | } | 196 | } |