Feat:为youtubedr设置enjoy的代理环境变量 (#949)
* Feat:为youtubedr设置enjoy的代理环境变量 * fix: Use English comment in youtubedr.ts --------- Co-authored-by: m1n99 <laym1n91993@gmail.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user