From c32745f374672374dc09d694ba19ccf4dc92306c Mon Sep 17 00:00:00 2001 From: m1n99 <113222588+m1n99@users.noreply.github.com> Date: Fri, 9 Aug 2024 09:42:33 +0800 Subject: [PATCH] =?UTF-8?q?Feat:=E4=B8=BAyoutubedr=E8=AE=BE=E7=BD=AEenjoy?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=90=86=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=20(#949)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Feat:为youtubedr设置enjoy的代理环境变量 * fix: Use English comment in youtubedr.ts --------- Co-authored-by: m1n99 --- enjoy/src/main/youtubedr.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/enjoy/src/main/youtubedr.ts b/enjoy/src/main/youtubedr.ts index 65e0f559..9d9f6160 100644 --- a/enjoy/src/main/youtubedr.ts +++ b/enjoy/src/main/youtubedr.ts @@ -133,6 +133,7 @@ class Youtubedr { { timeout: TEN_MINUTES, signal: this.abortController.signal, + env: this.proxyEnv() } ); @@ -188,6 +189,7 @@ class Youtubedr { command, { timeout: ONE_MINUTE, + env: this.proxyEnv() }, (error, stdout, stderr) => { if (error) { @@ -255,6 +257,21 @@ class Youtubedr { abortDownload() { this.abortController?.abort(); } + + /** + * Set the proxy environment variables + * @returns env object + */ + proxyEnv = () => { + // keep current environment variables + let env = {...process.env} + const proxyConfig = settings.getSync("proxy") as ProxyConfigType; + if (proxyConfig.enabled && proxyConfig.url) { + env["HTTP_PROXY"] = proxyConfig.url; + env["HTTPS_PROXY"] = proxyConfig.url; + } + return env + } } export default new Youtubedr();