Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
b3fc41a1
Verified
Commit
b3fc41a1
authored
Oct 15, 2021
by
Chocobozzz
Browse files
Fix youtube-dl update with proxy
parent
1ffb5fb6
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/helpers/requests.ts
View file @
b3fc41a1
...
...
@@ -186,7 +186,8 @@ export {
doRequest
,
doJSONRequest
,
doRequestAndSaveToFile
,
downloadImage
downloadImage
,
peertubeGot
}
// ---------------------------------------------------------------------------
...
...
server/helpers/youtube-dl.ts
View file @
b3fc41a1
import
{
createWriteStream
}
from
'
fs
'
import
{
ensureDir
,
move
,
pathExists
,
remove
,
writeFile
}
from
'
fs-extra
'
import
got
from
'
got
'
import
{
join
}
from
'
path
'
import
{
CONFIG
}
from
'
@server/initializers/config
'
import
{
HttpStatusCode
}
from
'
../../shared/models/http/http-error-codes
'
...
...
@@ -9,6 +8,7 @@ import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES }
import
{
peertubeTruncate
,
pipelinePromise
,
root
}
from
'
./core-utils
'
import
{
isVideoFileExtnameValid
}
from
'
./custom-validators/videos
'
import
{
logger
}
from
'
./logger
'
import
{
peertubeGot
}
from
'
./requests
'
import
{
generateVideoImportTmpPath
}
from
'
./utils
'
export
type
YoutubeDLInfo
=
{
...
...
@@ -343,7 +343,9 @@ class YoutubeDL {
await
ensureDir
(
binDirectory
)
try
{
const
result
=
await
got
(
url
,
{
followRedirect
:
false
})
const
gotContext
=
{
bodyKBLimit
:
20
_000
}
const
result
=
await
peertubeGot
(
url
,
{
followRedirect
:
false
,
context
:
gotContext
})
if
(
result
.
statusCode
!==
HttpStatusCode
.
FOUND_302
)
{
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 {
const
newUrl
=
result
.
headers
.
location
const
newVersion
=
/
\/(\d{4}\.\d\d\.\d\d(\.\d)?)\/
youtube-dl$/
.
exec
(
newUrl
)[
1
]
const
downloadFileStream
=
g
ot
.
stream
(
newUrl
)
const
downloadFileStream
=
peertubeG
ot
.
stream
(
newUrl
,
{
context
:
gotContext
}
)
const
writeStream
=
createWriteStream
(
bin
,
{
mode
:
493
})
await
pipelinePromise
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment