🔧 Update wget.ts script with proxy improvements and metadata adjustments
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
log,
|
||||
printLastLine,
|
||||
} from "https://script.hatter.ink/@70/deno-commons-mod.ts";
|
||||
import {getEnv} from "../libraries/deno-commons-mod.ts";
|
||||
|
||||
function getOutputFilename(filename: string): string {
|
||||
const original = filename;
|
||||
@@ -50,14 +51,21 @@ function getOutputFilenameFromUrl(url: string): string {
|
||||
return getOutputFilename(getFilenameFromUrl(url));
|
||||
}
|
||||
|
||||
function getEnvironmentProxy(): string | undefined {
|
||||
return Deno.env.get("ALL_PROXY") || Deno.env.get("HTTPS_PROXY") ||
|
||||
function getEnvironmentProxy(autoProxy: boolean): string | undefined {
|
||||
const proxy = Deno.env.get("ALL_PROXY") || Deno.env.get("HTTPS_PROXY") ||
|
||||
Deno.env.get("HTTP_PROXY");
|
||||
if (proxy) {
|
||||
return proxy;
|
||||
}
|
||||
if (autoProxy) {
|
||||
return getEnv("AUTO_PROXY");
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const args = Deno.args;
|
||||
const flags = parseArgs(Deno.args, {
|
||||
boolean: ["help", "no-proxy", "hatter-proxy"],
|
||||
boolean: ["help", "no-proxy", "auto-proxy", "hatter-proxy"],
|
||||
string: ["proxy", "output"],
|
||||
});
|
||||
|
||||
@@ -68,7 +76,11 @@ if (args.length === 0) {
|
||||
if (flags.help) {
|
||||
console.log(`wget.ts - download file
|
||||
|
||||
wget.ts [--proxy socks5h://ip:port] [--no-proxy] [--hatter-proxy] [--output filename] <URL>`);
|
||||
Environments:
|
||||
- ALL_PROXY,HTTPS_PROXY,HTTP_PROXY ~ For proxy
|
||||
- AUTO_PROXY ~ For auto proxy
|
||||
|
||||
wget.ts [--proxy socks5h://ip:port] [--no-proxy] [--auto-proxy] [--hatter-proxy] [--output filename] <URL>`);
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
@@ -109,8 +121,9 @@ const outputFileWritable = Deno.createSync(outputFilename).writable;
|
||||
|
||||
let init = undefined;
|
||||
const noProxy = flags["no-proxy"];
|
||||
const autoProxy = flags["auto-proxy"];
|
||||
const hatterProxy = flags["hatter-proxy"];
|
||||
const proxy = flags.proxy || getEnvironmentProxy();
|
||||
const proxy = flags.proxy || getEnvironmentProxy(autoProxy);
|
||||
if (proxy && !noProxy && !hatterProxy) {
|
||||
log.info(`Using proxy: ${proxy}`);
|
||||
init = {
|
||||
@@ -167,5 +180,5 @@ log.success(
|
||||
}`,
|
||||
);
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T094236+08:00.MEUCIB55YAAJvIXHI4GyG1V/
|
||||
// FtnHQSOh9GTJv4saSFZKoCvdAiEA/VKd6+MnnfWlw3aT8HrOLl/hT0j1cxtUfGjW84MoHS4=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T094803+08:00.MEUCIBdigqOZCNwVHEF/AEpP
|
||||
// CSTp8ru7SCFX0MeB0N3PsGUhAiEA/gZ1cbK/FyK9w14+63YvxdTUwX273b+LgteJ95BjGag=
|
||||
|
||||
Reference in New Issue
Block a user