mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Support youtube-dl executables
Also disable youtube tests in CI due to youtube blocking
This commit is contained in:
parent
5439a591e0
commit
38dbafcf63
12 changed files with 221 additions and 134 deletions
|
@ -3,7 +3,7 @@ import { VideoResolution, VideoResolutionType } from '@peertube/peertube-models'
|
|||
import { CONFIG } from '@server/initializers/config.js'
|
||||
import { execa, Options as ExecaNodeOptions } from 'execa'
|
||||
import { ensureDir, pathExists } from 'fs-extra/esm'
|
||||
import { writeFile } from 'fs/promises'
|
||||
import { chmod, writeFile } from 'fs/promises'
|
||||
import { OptionsOfBufferResponseBody } from 'got'
|
||||
import { dirname, join } from 'path'
|
||||
import { logger, loggerTagsFactory } from '../logger.js'
|
||||
|
@ -34,7 +34,7 @@ export class YoutubeDLCLI {
|
|||
logger.info('Updating youtubeDL binary from %s.', url, lTags())
|
||||
|
||||
const gotOptions: OptionsOfBufferResponseBody = {
|
||||
context: { bodyKBLimit: 20_000 },
|
||||
context: { bodyKBLimit: 100_000 },
|
||||
responseType: 'buffer' as 'buffer'
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,10 @@ export class YoutubeDLCLI {
|
|||
|
||||
await writeFile(youtubeDLBinaryPath, gotResult.body)
|
||||
|
||||
if (!CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE.PYTHON_PATH) {
|
||||
await chmod(youtubeDLBinaryPath, '744')
|
||||
}
|
||||
|
||||
logger.info('youtube-dl updated %s.', youtubeDLBinaryPath, lTags())
|
||||
} catch (err) {
|
||||
logger.error('Cannot update youtube-dl from %s.', url, { err, ...lTags() })
|
||||
|
@ -215,8 +219,11 @@ export class YoutubeDLCLI {
|
|||
completeArgs = this.wrapWithIPOptions(completeArgs)
|
||||
completeArgs = this.wrapWithFFmpegOptions(completeArgs)
|
||||
|
||||
const { PYTHON_PATH } = CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE
|
||||
const subProcess = execa(PYTHON_PATH, [ youtubeDLBinaryPath, ...completeArgs, url ], processOptions)
|
||||
const subProcessBinary = CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE.PYTHON_PATH || youtubeDLBinaryPath
|
||||
const subProcessArgs = [ ...completeArgs, url ]
|
||||
if (subProcessBinary !== youtubeDLBinaryPath) subProcessArgs.unshift(youtubeDLBinaryPath)
|
||||
|
||||
const subProcess = execa(subProcessBinary, subProcessArgs, processOptions)
|
||||
|
||||
if (timeout) {
|
||||
setTimeout(() => subProcess.kill(), timeout)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue