forked from yt-dlp/ejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.ts
More file actions
42 lines (39 loc) · 960 Bytes
/
run.ts
File metadata and controls
42 lines (39 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { argv, exit } from "node:process";
import { readFileSync } from "node:fs";
import { isOneOf } from "./src/utils.ts";
import main from "./src/yt/solver/main.ts";
const args = argv.slice(2);
if (args.length < 2) {
console.error(
`ERROR: Missing argument\nusage: ${
argv[1]
} <player> [<type>:<request> ...]`,
);
exit(1);
}
const player = readFileSync(args[0], "utf-8");
const requests = {
n: [] as string[],
sig: [] as string[],
};
for (const request of args.slice(1)) {
const [type, challenge] = request.split(":", 2);
if (!isOneOf(type, "sig", "n")) {
console.error(`ERROR: Unsupported request type: ${type}`);
exit(1);
}
requests[type].push(challenge);
}
console.log(
JSON.stringify(
main({
type: "player",
player,
output_preprocessed: false,
requests: [
{ type: "n", challenges: requests.n },
{ type: "sig", challenges: requests.sig },
],
}),
),
);