@boy-offi9-inc/tidepull 0.4.0 → 0.4.2

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/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
  <img src="docs/assets/logo.svg" alt="tidepull logo" width="88" height="88">
3
3
  </p>
4
4
 
5
+ [![npm version](https://img.shields.io/npm/v/@boy-offi9-inc/tidepull)](https://www.npmjs.com/package/@boy-offi9-inc/tidepull)
6
+ [![npm downloads/month](https://img.shields.io/npm/dm/@boy-offi9-inc/tidepull)](https://www.npmjs.com/package/@boy-offi9-inc/tidepull)
7
+ [![CI](https://github.com/boy-offi9-inc/Tidepull/actions/workflows/ci.yml/badge.svg)](https://github.com/boy-offi9-inc/Tidepull/actions/workflows/ci.yml)
8
+ ![Node](https://img.shields.io/badge/node-%3E%3D22.18-339933)
9
+ ![dependencies](https://img.shields.io/badge/dependencies-zero-brightgreen)
10
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
11
+ ![TypeScript](https://img.shields.io/badge/TypeScript-5-3178c6)
12
+
5
13
  # tidepull
6
14
 
7
15
  A minimal, from-scratch media downloader **library** (and CLI) for Node. Minimal by design: a ~22 KB minified core with no runtime dependencies today (~9 KB gzip), fully typed, no terminal code in the core. Everything that isn't needed by every user is opt-in.
@@ -56,6 +64,19 @@ const files = await pullAll(g, "https://example.com/podcast.rss", { items: "1-3,
56
64
 
57
65
  `g.resolve(url)` returns an `Info` or a `Playlist` (`isPlaylist(x)` tells you which). `g.extract(url)` still returns a single `Info` and refuses a playlist with a clear error. A failing item is thrown by default; pass `onError` to report it and continue. Template fields for playlist items: `%(playlist)s`, `%(playlist_index)02d`, `%(playlist_count)s`, `%(playlist_id)s`.
58
66
 
67
+ ## Example
68
+ ```console
69
+ $ tidepull -F URL # list formats
70
+ ID EXT RESOLUTION FPS | SIZE TBR PROTO | VCODEC ACODEC NOTE
71
+ hls-600 ts 640x360 | 600k hls | unknown unknown
72
+ hls-1200 ts 1280x720 | 1200k hls | unknown unknown
73
+
74
+ $ tidepull URL -P ~/Videos
75
+ [download] Destination: ~/Videos/master.ts
76
+ [download] 100% of 439.45KiB in 00:00
77
+ [done] ~/Videos/master.ts
78
+ ```
79
+
59
80
  ## API (everything else is internal)
60
81
  | Export | Purpose |
61
82
  |---|---|
@@ -90,7 +111,17 @@ export default definePlugin({
90
111
  ```
91
112
  Plugins run before built-ins; the generic fallback is always last. From disk: `import { loadPlugins } from "@boy-offi9-inc/tidepull/loader"` (the CLI does this for you, and bundles DASH). A plugin targeting a different `apiVersion` is refused with a clear message instead of failing mysteriously. **Plugins execute with your privileges. Only load code you trust.** See `src/extractors/_template.ts`.
92
113
 
93
- Ready-made site plugins live in a separate private repo, [boy-offi9-inc/tidepull-plugins](https://github.com/boy-offi9-inc/tidepull-plugins); its `docs/PLUGINS.md` is the contract a plugin must satisfy (naming, `apiVersion`, what an extractor may touch, how it is reviewed) before it can be loaded there.
114
+ Ready-made site plugins live in the public [boy-offi9-inc/tidepull-plugins](https://github.com/boy-offi9-inc/tidepull-plugins) repo; its `docs/PLUGINS.md` is the contract a plugin must satisfy (naming, `apiVersion`, what an extractor may touch, how it is reviewed) before it can be loaded there.
115
+
116
+ Ready-made plugins today: [`@boy-offi9-inc/tidepull-plugin-example`](https://github.com/boy-offi9-inc/tidepull-plugins/tree/main/plugins/example) (og:video / og:audio metas) and [`@boy-offi9-inc/tidepull-plugin-soundcloud`](https://github.com/boy-offi9-inc/tidepull-plugins/tree/main/plugins/soundcloud) (public SoundCloud tracks).
117
+
118
+ ### Ecosystem
119
+
120
+ | Repo | Package | What it is |
121
+ |---|---|---|
122
+ | [Tidepull](https://github.com/boy-offi9-inc/Tidepull) (here) | `@boy-offi9-inc/tidepull` | the core: extract, select, download — zero dependencies |
123
+ | [tidepull-plugins](https://github.com/boy-offi9-inc/tidepull-plugins) | `@boy-offi9-inc/tidepull-plugin-*` | site plugins and the authoring template, contract in its `docs/PLUGINS.md` |
124
+ | [reqkit](https://github.com/boy-offi9-inc/reqkit) | — | transport/resilience helpers for plugin authors (planned) |
94
125
 
95
126
  An extractor may instead return a `Playlist` (`{ kind: "playlist", id, title, extractor, webpage_url, entries: [{ url, title? }] }`) for a page that lists several items; each entry is then extracted on its own by the same extractors.
96
127
 
@@ -133,6 +164,8 @@ TIDEPULL_THEME=high-contrast tidepull URL # --theme still wins if you also
133
164
 
134
165
  A theme only decides *which* codes are emitted: `--no-color`, `NO_COLOR` and a non-TTY stderr still strip every escape sequence, so redirected output and CI logs stay plain text.
135
166
 
167
+ On an interactive terminal the CLI shows a launch banner and a spinner while resolving a URL; quiet, JSON, `-g`, simulate and non-TTY modes suppress both so piped output stays data-only.
168
+
136
169
  From a clone, `node src/cli.ts <args>` runs the TypeScript source directly (Node >= 22.18); `npm run build` emits JS + `.d.ts`.
137
170
 
138
171
  ## Capabilities and limits
package/dist/main.js CHANGED
@@ -13,7 +13,9 @@ import { defaultPluginDir, loadPlugins } from "./loader.js";
13
13
  import { table, fmtBytes } from "./ui/format.js";
14
14
  import { Logger, shouldUseColor } from "./ui/log.js";
15
15
  import { humanRenderer, jsonRenderer } from "./ui/render.js";
16
+ import { renderBanner } from "./ui/banner.js";
16
17
  import { pickTheme, THEME_NAMES } from "./ui/theme.js";
18
+ import { Spinner } from "./ui/spinner.js";
17
19
  /** Package version, read from package.json. */
18
20
  export const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
19
21
  const HELP = `tidepull ${VERSION}: a minimal media downloader
@@ -177,6 +179,12 @@ export async function main(argv) {
177
179
  process.stderr.write(`ERROR: ${errMsg(e)}\n`);
178
180
  return 2;
179
181
  }
182
+ // Banner: interactive terminals only. Anything machine-facing (quiet, json,
183
+ // get-url, simulate, progress-json) or non-TTY stdout suppresses it.
184
+ const machineMode = values.quiet || values["dump-json"] || values["get-url"] || values.simulate || values["progress-json"];
185
+ if (process.stdout.isTTY && !machineMode) {
186
+ process.stderr.write(renderBanner(VERSION, theme, !values["no-color"] && shouldUseColor()) + "\n");
187
+ }
180
188
  const log = new Logger({
181
189
  quiet: values.quiet,
182
190
  verbose: values.verbose,
@@ -272,6 +280,14 @@ export async function main(argv) {
272
280
  process.stderr.write(e.stack + "\n");
273
281
  code = Math.max(code, e instanceof TidepullError ? e.exitCode : 1);
274
282
  };
283
+ // Spinner for the resolve/extract phase: TTY stderr only, machine modes never see it.
284
+ const interactive = process.stdout.isTTY && !machineMode && !values["no-progress"];
285
+ const spinner = new Spinner({ text: "extracting…", env: process.env });
286
+ const spin = () => {
287
+ if (interactive)
288
+ spinner.start();
289
+ };
290
+ const stopSpin = (final) => spinner.stop(final);
275
291
  /** What to do with one extracted item: print info, list formats, print URLs, or download it. */
276
292
  const handle = async (info, fields) => {
277
293
  if (values["dump-json"])
@@ -303,8 +319,10 @@ export async function main(argv) {
303
319
  try {
304
320
  for (const url of urls) {
305
321
  try {
322
+ spin();
306
323
  const resolved = await tp.resolve(url, { signal: ctl.signal });
307
324
  if (isPlaylist(resolved) && (values["dump-json"] || values["list-formats"])) {
325
+ stopSpin(`${resolved.title}: ${resolved.entries.length} item(s)`);
308
326
  // listing a playlist needs no request per entry
309
327
  if (values["dump-json"])
310
328
  process.stdout.write(JSON.stringify(resolved) + "\n");
@@ -315,6 +333,7 @@ export async function main(argv) {
315
333
  continue;
316
334
  }
317
335
  for await (const item of resolveItems(tp, resolved, { signal: ctl.signal, items: values["playlist-items"] })) {
336
+ stopSpin();
318
337
  try {
319
338
  if (item.error)
320
339
  throw item.error;
@@ -328,6 +347,7 @@ export async function main(argv) {
328
347
  }
329
348
  }
330
349
  catch (e) {
350
+ stopSpin();
331
351
  if (ctl.signal.aborted) {
332
352
  process.stderr.write("\n");
333
353
  log.error("Interrupted by user (partial files kept, re-run to resume)");
@@ -341,6 +361,7 @@ export async function main(argv) {
341
361
  }
342
362
  }
343
363
  finally {
364
+ stopSpin();
344
365
  process.removeListener("SIGINT", onSigint);
345
366
  }
346
367
  return code;
@@ -0,0 +1,3 @@
1
+ import type { Theme } from "./theme.js";
2
+ /** Launch banner for interactive terminals; version dimmed beside the logo. */
3
+ export declare function renderBanner(version: string, theme: Theme, color?: boolean): string;
@@ -0,0 +1,28 @@
1
+ const GLYPHS = {
2
+ t: ["| |_ ", "| __|", "| |_ ", " \\__|"],
3
+ i: ["|_ _|", " | | ", " | | ", "|___|"],
4
+ d: [" __| |", " / _` |", "| (_| |", " \\__,_|"],
5
+ e: [" ___ ", " / _ \\", "| __/", " \\___|"],
6
+ p: ["| '_ \\ ", "| |_) |", "| .__/ ", "|_| "],
7
+ u: ["| | ", "| | ", "| | ", "|_| "],
8
+ l: ["| |", "| |", "| |", "|_|"],
9
+ };
10
+ /** Block-letter logo, assembled row by row so the letters are correct by construction. */
11
+ function logo() {
12
+ const rows = ["", "", "", ""];
13
+ for (const ch of "tidepull") {
14
+ const g = GLYPHS[ch];
15
+ for (let r = 0; r < 4; r++)
16
+ rows[r] += g[r] + (r === 0 && ch !== "l" ? " " : " ");
17
+ }
18
+ return rows.map((r) => r.trimEnd());
19
+ }
20
+ /** Launch banner for interactive terminals; version dimmed beside the logo. */
21
+ export function renderBanner(version, theme, color = true) {
22
+ const plain = !color || !!process.env.NO_COLOR || theme.name === "mono";
23
+ const paint = (c, s) => (plain ? s : c + s + theme.reset);
24
+ const dim = (s) => (plain ? s : theme.dim + s + theme.reset);
25
+ const rows = logo();
26
+ rows[3] = paint(theme.accent, rows[3]) + " " + dim(`v${version}`);
27
+ return rows.map((r, i) => (i === 3 ? r : paint(theme.accent, r))).join("\n");
28
+ }
@@ -0,0 +1,24 @@
1
+ export interface SpinnerOptions {
2
+ text?: string;
3
+ stream?: NodeJS.WriteStream;
4
+ env?: NodeJS.ProcessEnv;
5
+ interval?: number;
6
+ }
7
+ /**
8
+ * Single-line activity spinner on stderr. Never touches stdout, and never
9
+ * starts at all when stderr is not a TTY or CI is detected: machine modes
10
+ * must see zero bytes from it.
11
+ */
12
+ export declare class Spinner {
13
+ private timer;
14
+ private frame;
15
+ private text;
16
+ private readonly stream;
17
+ private readonly env;
18
+ private readonly interval;
19
+ constructor(o?: SpinnerOptions);
20
+ get active(): boolean;
21
+ start(): this;
22
+ stop(finalLine?: string): this;
23
+ private render;
24
+ }
@@ -0,0 +1,49 @@
1
+ const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧"];
2
+ /**
3
+ * Single-line activity spinner on stderr. Never touches stdout, and never
4
+ * starts at all when stderr is not a TTY or CI is detected: machine modes
5
+ * must see zero bytes from it.
6
+ */
7
+ export class Spinner {
8
+ timer;
9
+ frame = 0;
10
+ text;
11
+ stream;
12
+ env;
13
+ interval;
14
+ constructor(o = {}) {
15
+ this.text = o.text ?? "extracting…";
16
+ this.stream = o.stream ?? process.stderr;
17
+ this.env = o.env ?? process.env;
18
+ this.interval = o.interval ?? 80;
19
+ }
20
+ get active() {
21
+ return this.timer !== undefined;
22
+ }
23
+ start() {
24
+ if (this.timer || !this.stream.isTTY || this.env.CI)
25
+ return this;
26
+ this.render();
27
+ this.timer = setInterval(() => {
28
+ this.frame = (this.frame + 1) % FRAMES.length;
29
+ this.render();
30
+ }, this.interval);
31
+ this.timer.unref();
32
+ return this;
33
+ }
34
+ stop(finalLine) {
35
+ if (!this.timer)
36
+ return this;
37
+ clearInterval(this.timer);
38
+ this.timer = undefined;
39
+ this.stream.write(`\r\x1b[K`);
40
+ if (finalLine) {
41
+ const dim = this.env.NO_COLOR ? "" : "\x1b[2m";
42
+ this.stream.write(`${dim}${finalLine}\x1b[0m\n`);
43
+ }
44
+ return this;
45
+ }
46
+ render() {
47
+ this.stream.write(`\r\x1b[K${FRAMES[this.frame]} ${this.text}`);
48
+ }
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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",