aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-08 21:16:10 +0100
committerGitHub <noreply@github.com>2020-12-08 21:16:10 +0100
commitf2eb23cd87cf32b8fe545178143b5f49e06a58da (patch)
treeaf7d59945af70e28fd85047e2c688c59a908f548 /server/helpers/youtube-dl.ts
parentc977fd3ec931c059111ddb2b8d6ddbb20b6b99a1 (diff)
downloadPeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.gz
PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.tar.zst
PeerTube-f2eb23cd87cf32b8fe545178143b5f49e06a58da.zip
emit more specific status codes on video upload (#3423)
- reduce http status codes list to potentially useful codes - convert more codes to typed ones - factorize html generator for error responses
Diffstat (limited to 'server/helpers/youtube-dl.ts')
-rw-r--r--server/helpers/youtube-dl.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index 302b2e206..9e8ef90d8 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -7,6 +7,7 @@ import { 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' 9import { CONFIG } from '@server/initializers/config'
10import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
10 11
11export type YoutubeDLInfo = { 12export type YoutubeDLInfo = {
12 name?: string 13 name?: string
@@ -154,7 +155,7 @@ async function updateYoutubeDLBinary () {
154 return res() 155 return res()
155 } 156 }
156 157
157 if (result.statusCode !== 302) { 158 if (result.statusCode !== HttpStatusCode.FOUND_302) {
158 logger.error('youtube-dl update error: did not get redirect for the latest version link. Status %d', result.statusCode) 159 logger.error('youtube-dl update error: did not get redirect for the latest version link. Status %d', result.statusCode)
159 return res() 160 return res()
160 } 161 }
@@ -164,7 +165,7 @@ async function updateYoutubeDLBinary () {
164 const newVersion = /yt-dl\.org\/downloads\/(\d{4}\.\d\d\.\d\d(\.\d)?)\/youtube-dl/.exec(url)[1] 165 const newVersion = /yt-dl\.org\/downloads\/(\d{4}\.\d\d\.\d\d(\.\d)?)\/youtube-dl/.exec(url)[1]
165 166
166 downloadFile.on('response', result => { 167 downloadFile.on('response', result => {
167 if (result.statusCode !== 200) { 168 if (result.statusCode !== HttpStatusCode.OK_200) {
168 logger.error('Cannot update youtube-dl: new version response is not 200, it\'s %d.', result.statusCode) 169 logger.error('Cannot update youtube-dl: new version response is not 200, it\'s %d.', result.statusCode)
169 return res() 170 return res()
170 } 171 }