@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 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
- if (showBanner) {
266
- const pluginNames = plugins.map((p) => p.name);
267
- process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor(), pluginNames) + "\n");
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
- function infoRows(version, theme, plain, plugins, valueRoom) {
7
- const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
8
- const ok = (s) => (plain ? s : theme.success + s + theme.reset);
9
- const tag = (s) => (plain ? s : theme.tag + s + theme.reset);
10
- const fit = (s, plain_s) => {
11
- if (visible(plain_s) <= valueRoom)
12
- return s;
13
- if (plugins.length > 1 && plain_s === plugins.join(", ")) {
14
- let names = plugins;
15
- do {
16
- names = names.slice(0, -1);
17
- const body = names.join(", ") + ` +${plugins.length - names.length}`;
18
- if (visible(body) <= valueRoom)
19
- return tag(body);
20
- } while (names.length > 1);
21
- const one = plugins[0].slice(0, Math.max(1, valueRoom - 1)) + "\u2026";
22
- return tag(one);
23
- }
24
- return s;
25
- };
26
- const rows = [
27
- ["media downloader", ok(`v${version}`)],
28
- ["stdout", ok("data only")],
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 w = Math.min(width ?? termWidth(), 60);
45
- const inner = w - 2;
46
- const LABEL = 17;
47
- if (inner - 2 - LABEL < 10) {
48
- const full = `${GLYPH} tidepull ${version}`;
49
- const title = visible(full) > inner - 5
50
- ? full.slice(0, Math.max(1, inner - 6)) + "\u2026"
51
- : full;
52
- const dash = "\u2500";
53
- const fill = Math.max(1, inner - visible(title) - 4);
54
- return [
55
- accent("\u250c\u2500" + " ") + title + " " + accent(" " + dash.repeat(fill) + "\u2510"),
56
- accent("\u2514" + dash.repeat(inner) + "\u2518"),
57
- ].join("\n");
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
- const rows = infoRows(version, theme, plain, plugins, inner - 2 - LABEL);
60
- const lines = [];
61
- const title = `${GLYPH} tidepull` + (plain ? ` v${version}` : ` ${paint(theme.dim, `v${version}`)}`);
62
- const shownTitle = visible(title) > inner - 4 ? `${GLYPH} tidepull` : title;
63
- const dash = "\u2500";
64
- const fill = Math.max(1, inner - visible(shownTitle) - 4);
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
- lines.push(accent("\u2514" + dash.repeat(inner) + "\u2518"));
71
- return lines.join("\n");
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "A minimal, from-scratch media downloader library: extractor plugins, yt-dlp-style format selection, resumable downloads.",
5
5
  "type": "module",
6
6
  "license": "MIT",