@boy-offi9-inc/tidepull 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +8 -7
- package/dist/ui/banner.js +67 -59
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -235,10 +235,6 @@ export async function main(argv) {
|
|
|
235
235
|
log.error(errMsg(e));
|
|
236
236
|
return e instanceof TidepullError ? e.exitCode : 1;
|
|
237
237
|
}
|
|
238
|
-
if (!urls.length && !values["list-extractors"]) {
|
|
239
|
-
log.error("You must provide at least one URL. Try 'tidepull --help'.");
|
|
240
|
-
return 2;
|
|
241
|
-
}
|
|
242
238
|
const headers = {};
|
|
243
239
|
for (const h of values.header ?? []) {
|
|
244
240
|
const i = h.indexOf(":");
|
|
@@ -262,9 +258,14 @@ export async function main(argv) {
|
|
|
262
258
|
return e instanceof TidepullError ? e.exitCode : 1;
|
|
263
259
|
}
|
|
264
260
|
showBanner = interactiveStdout && !values["list-extractors"];
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
const bannerText = showBanner
|
|
262
|
+
? renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor(), plugins.map((p) => p.name)) + "\n"
|
|
263
|
+
: "";
|
|
264
|
+
if (bannerText)
|
|
265
|
+
process.stderr.write(bannerText);
|
|
266
|
+
if (!urls.length && !values["list-extractors"]) {
|
|
267
|
+
log.error("No URL given. Quick start: tidepull <url> ('tidepull --help' for everything)");
|
|
268
|
+
return 2;
|
|
268
269
|
}
|
|
269
270
|
const tp = createTidepull({
|
|
270
271
|
http: { headers, headerHosts: values["header-host"] ?? [], userAgent: values["user-agent"], retries: num(values.retries, 3), cookies },
|
package/dist/ui/banner.js
CHANGED
|
@@ -1,74 +1,82 @@
|
|
|
1
|
-
const GLYPH = "\u2b22";
|
|
2
1
|
const visible = (s) => s.replace(/\x1b\[[0-9;]*m/g, "").length;
|
|
3
2
|
function termWidth() {
|
|
4
3
|
return process.stdout.columns ?? 80;
|
|
5
4
|
}
|
|
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
|
-
const pluginValue = plugins.length ? plugins.join(", ") : "";
|
|
31
|
-
if (plugins.length) {
|
|
32
|
-
rows.push(["plugins", fit(tag(pluginValue), pluginValue)]);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
rows.push(["plugins", dim("none")]);
|
|
36
|
-
}
|
|
37
|
-
return rows;
|
|
5
|
+
const ART_WIDE = [
|
|
6
|
+
"___________________ ___________",
|
|
7
|
+
"__ /___(_)_____ /________________ ____ /__ /",
|
|
8
|
+
"_ __/_ /_ __ /_ _ \\__ __ \\ / / /_ /__ / ",
|
|
9
|
+
"/ /_ _ / / /_/ / / __/_ /_/ / /_/ /_ / _ / ",
|
|
10
|
+
"\\__/ /_/ \\__,_/ \\___/_ .___/\\__,_/ /_/ /_/ ",
|
|
11
|
+
" /_/ ",
|
|
12
|
+
];
|
|
13
|
+
const ART_MID = [
|
|
14
|
+
" __ _ __ ____",
|
|
15
|
+
" / /_(_)__/ /__ ___ __ __/ / /",
|
|
16
|
+
"/ __/ / _ / -_) _ \\/ // / / / ",
|
|
17
|
+
"\\__/_/\\_,_/\\__/ .__/\\_,_/_/_/ ",
|
|
18
|
+
" /_/ ",
|
|
19
|
+
];
|
|
20
|
+
const COMMANDS = [
|
|
21
|
+
["tidepull <url>", "pull best video + audio"],
|
|
22
|
+
["tidepull -F <url>", "list available formats"],
|
|
23
|
+
["tidepull -x <url>", "extract the audio track"],
|
|
24
|
+
["tidepull --live <url>", "record a live stream"],
|
|
25
|
+
];
|
|
26
|
+
const CMD_PAD = 24;
|
|
27
|
+
function pad(s, n) {
|
|
28
|
+
return s + " ".repeat(Math.max(1, n - visible(s)));
|
|
38
29
|
}
|
|
39
30
|
export function renderBanner(version, theme, color = true, plugins = [], width) {
|
|
40
31
|
const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
|
|
41
32
|
const paint = (c, s) => (plain ? s : c + s + theme.reset);
|
|
42
33
|
const accent = (s) => paint(theme.accent, s);
|
|
43
34
|
const dim = (s) => paint(theme.dim, s);
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
const ok = (s) => paint(theme.success, s);
|
|
36
|
+
const w = width ?? termWidth();
|
|
37
|
+
const commandBlock = (colWidth, rows = COMMANDS) => rows.map(([cmd, desc]) => {
|
|
38
|
+
const space = cmd.indexOf(" ");
|
|
39
|
+
const name = space < 0 ? cmd : cmd.slice(0, space);
|
|
40
|
+
const rest = space < 0 ? "" : cmd.slice(space);
|
|
41
|
+
return " " + accent(name) + pad(dim(rest), colWidth - visible(name)) + dim(desc);
|
|
42
|
+
});
|
|
43
|
+
const PLUGIN_LABEL = "plugins: ";
|
|
44
|
+
let pluginValue = plugins.length ? plugins.join(", ") : "none";
|
|
45
|
+
const room = w - 2 - visible(`v${version}`) - 2 - PLUGIN_LABEL.length;
|
|
46
|
+
if (visible(pluginValue) > room) {
|
|
47
|
+
let names = plugins;
|
|
48
|
+
while (names.length > 1) {
|
|
49
|
+
names = names.slice(0, -1);
|
|
50
|
+
const body = names.join(", ") + ` +${plugins.length - names.length}`;
|
|
51
|
+
if (visible(body) <= room) {
|
|
52
|
+
pluginValue = body;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (visible(pluginValue) > room)
|
|
57
|
+
pluginValue = pluginValue.slice(0, Math.max(1, room - 1)) + "\u2026";
|
|
58
|
+
}
|
|
59
|
+
const pluginLine = dim(PLUGIN_LABEL) + (plugins.length ? ok(pluginValue) : dim(pluginValue));
|
|
60
|
+
if (w >= 54) {
|
|
61
|
+
const lines = ART_WIDE.map((l) => accent(l));
|
|
62
|
+
lines.push("");
|
|
63
|
+
lines.push(" " + dim("media downloader") + " " + ok(`v${version}`));
|
|
64
|
+
lines.push(" " + pluginLine);
|
|
65
|
+
lines.push("");
|
|
66
|
+
lines.push(...commandBlock(CMD_PAD));
|
|
67
|
+
lines.push("");
|
|
68
|
+
lines.push(" " + dim("tidepull --help for everything else"));
|
|
69
|
+
return lines.join("\n");
|
|
58
70
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
lines.push(accent("\u250c\u2500" + " ") + shownTitle + " " + accent(" " + dash.repeat(fill) + "\u2510"));
|
|
66
|
-
for (const [key, value] of rows) {
|
|
67
|
-
const pad = Math.max(0, inner - 2 - LABEL - visible(value));
|
|
68
|
-
lines.push(accent("\u2502") + " " + dim(key.padEnd(LABEL)) + value + " ".repeat(pad) + " " + accent("\u2502"));
|
|
71
|
+
if (w >= 34) {
|
|
72
|
+
const lines = ART_MID.map((l) => accent(" " + l));
|
|
73
|
+
lines.push("");
|
|
74
|
+
lines.push(" " + ok(`v${version}`) + " " + pluginLine);
|
|
75
|
+
lines.push(" " + accent("tidepull") + dim(" <url> --help for more"));
|
|
76
|
+
return lines.join("\n");
|
|
69
77
|
}
|
|
70
|
-
|
|
71
|
-
return
|
|
78
|
+
const title = `tidepull v${version}`;
|
|
79
|
+
return [accent(title), dim("see --help")].join("\n");
|
|
72
80
|
}
|
|
73
81
|
export const _visibleWidth = visible;
|
|
74
82
|
export { termWidth };
|
package/package.json
CHANGED