🔧 Update wget.ts script with proxy improvements and metadata adjustments

This commit is contained in:
2026-04-12 09:48:11 +08:00
parent 94b8aed144
commit f0fbe8e112
2 changed files with 23 additions and 10 deletions

View File

@@ -367,11 +367,11 @@
}, },
"wget.ts": { "wget.ts": {
"script_name": "wget.ts", "script_name": "wget.ts",
"script_length": 4888, "script_length": 5270,
"script_sha256": "de6ac5033d0ba57493d445045a201196bc214264667720cd16d8b45cfd1aa193", "script_sha256": "e66f9040be37f338a27d4d25c45aa119ee0198f2629fa168cd967ebb62c96be7",
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/wget.ts", "script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/wget.ts",
"single_script_file": true, "single_script_file": true,
"publish_time": 1737272626139, "publish_time": 1737272626139,
"update_time": 1775958189203 "update_time": 1775958487427
} }
} }

View File

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