forked from Supositware/Haha-Yes
Add proxy option to yt-dlp
This commit is contained in:
parent
4f84a09a7e
commit
0b12e2d496
3 changed files with 7 additions and 5 deletions
|
@ -16,4 +16,5 @@ botsggEndpoint=https://discord.bots.gg/api/v1
|
|||
stableHordeApi=0000000000
|
||||
stableHordeID=0000
|
||||
NODE_ENV=development
|
||||
ytdlpMaxResolution=720
|
||||
ytdlpMaxResolution=720
|
||||
proxy=socks5://localhost:3128
|
|
@ -8,6 +8,7 @@ let client;
|
|||
let maxFileSize;
|
||||
|
||||
let { ytdlpMaxResolution } = process.env;
|
||||
const { proxy } = process.env;
|
||||
// Convert to number as process.env is always a string
|
||||
ytdlpMaxResolution = Number(ytdlpMaxResolution);
|
||||
|
||||
|
@ -60,7 +61,7 @@ export default {
|
|||
|
||||
if (format) {
|
||||
let qualitys = await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [url, '--print', '%()j'], (err, stdout, stderr) => {
|
||||
execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', url, '--print', '%()j'], (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
|
@ -310,7 +311,7 @@ async function checkSize(url, format, args, interaction, tries = 0) {
|
|||
|
||||
async function getVideoDescription(urlArg) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [urlArg, '--no-warnings', '-O', '%(description)s'], (err, stdout, stderr) => {
|
||||
execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', urlArg, '--no-warnings', '-O', '%(description)s'], (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os from 'node:os';
|
||||
import { execFile } from 'node:child_process';
|
||||
const { NODE_ENV, ytdlpMaxResolution } = process.env;
|
||||
const { NODE_ENV, ytdlpMaxResolution, proxy } = process.env;
|
||||
|
||||
export default {
|
||||
downloadVideo,
|
||||
|
@ -15,7 +15,7 @@ export default {
|
|||
};
|
||||
async function downloadVideo(urlArg, output, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) {
|
||||
await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', ['-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings'], (err, stdout, stderr) => {
|
||||
execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', '-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings'], (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
return reject(stderr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue