Add proxy option to yt-dlp
This commit is contained in:
parent
4f84a09a7e
commit
0b12e2d496
3 changed files with 7 additions and 5 deletions
|
@ -17,3 +17,4 @@ stableHordeApi=0000000000
|
||||||
stableHordeID=0000
|
stableHordeID=0000
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
ytdlpMaxResolution=720
|
ytdlpMaxResolution=720
|
||||||
|
proxy=socks5://localhost:3128
|
|
@ -8,6 +8,7 @@ let client;
|
||||||
let maxFileSize;
|
let maxFileSize;
|
||||||
|
|
||||||
let { ytdlpMaxResolution } = process.env;
|
let { ytdlpMaxResolution } = process.env;
|
||||||
|
const { proxy } = process.env;
|
||||||
// Convert to number as process.env is always a string
|
// Convert to number as process.env is always a string
|
||||||
ytdlpMaxResolution = Number(ytdlpMaxResolution);
|
ytdlpMaxResolution = Number(ytdlpMaxResolution);
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ export default {
|
||||||
|
|
||||||
if (format) {
|
if (format) {
|
||||||
let qualitys = await new Promise((resolve, reject) => {
|
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) {
|
if (err) {
|
||||||
reject(stderr);
|
reject(stderr);
|
||||||
}
|
}
|
||||||
|
@ -310,7 +311,7 @@ async function checkSize(url, format, args, interaction, tries = 0) {
|
||||||
|
|
||||||
async function getVideoDescription(urlArg) {
|
async function getVideoDescription(urlArg) {
|
||||||
return await new Promise((resolve, reject) => {
|
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) {
|
if (err) {
|
||||||
reject(stderr);
|
reject(stderr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import { execFile } from 'node:child_process';
|
import { execFile } from 'node:child_process';
|
||||||
const { NODE_ENV, ytdlpMaxResolution } = process.env;
|
const { NODE_ENV, ytdlpMaxResolution, proxy } = process.env;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
downloadVideo,
|
downloadVideo,
|
||||||
|
@ -15,7 +15,7 @@ export default {
|
||||||
};
|
};
|
||||||
async function downloadVideo(urlArg, output, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) {
|
async function downloadVideo(urlArg, output, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) {
|
||||||
await new Promise((resolve, reject) => {
|
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) {
|
if (err) {
|
||||||
return reject(stderr);
|
return reject(stderr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue