@boy-offi9-inc/tidepull 0.18.0 → 0.20.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/README.md +20 -12
- package/dist/core/errors.d.ts +10 -1
- package/dist/core/errors.js +27 -1
- package/dist/core/http.js +18 -3
- package/dist/core/pipeline.js +28 -12
- package/dist/extractors/direct.d.ts +2 -0
- package/dist/extractors/direct.js +3 -2
- package/dist/extractors/generic.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/main.js +7 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
# tidepull
|
|
14
14
|
|
|
15
|
-
A minimal, from-scratch media downloader **library** (and CLI) for Node. Minimal by design: a ~
|
|
15
|
+
A minimal, from-scratch media downloader **library** (and CLI) for Node. Minimal by design: a ~23 KB minified core with no runtime dependencies today (~10 KB gzip), fully typed, no terminal code in the core. Everything that isn't needed by every user is opt-in.
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
@@ -136,16 +136,22 @@ tidepull --limit-rate 1M URL # cap the speed (500K, 1.5M,
|
|
|
136
136
|
tidepull --cookies cookies.txt URL # use your own logged-in session
|
|
137
137
|
tidepull https://example.com/podcast.rss -P ~/Music # every item of a feed or .m3u playlist
|
|
138
138
|
tidepull --playlist-items 1-3,7 URL # only some items (-F lists a playlist's entries)
|
|
139
|
+
tidepull --parallel 4 URL # download N playlist/multi-URL items concurrently
|
|
140
|
+
tidepull plugin install @boy-offi9-inc/tidepull-plugin-youtube # install a site plugin from npm
|
|
141
|
+
tidepull plugin list # what is installed (name + version)
|
|
142
|
+
tidepull plugin remove tidepull-plugin-youtube.ts # uninstall one plugin file
|
|
139
143
|
```
|
|
140
144
|
|
|
141
145
|
**Cookies.** `--cookies FILE` reads a Netscape `cookies.txt` (the format browser extensions export). Each cookie is sent only to the host, path and scheme it was issued for. Keep the file private (`chmod 600`); you get a warning if other users can read it.
|
|
142
146
|
|
|
143
|
-
**Playlists.** A feed or `.m3u` URL downloads every item; `--playlist-items 1-3,7,10-` chooses some. Items are numbered in the file name (`01 - Title.mp3`). A failing item is reported and the rest continue (exit code 1). `-j` prints the playlist as one JSON object and `-F` lists its entries, without downloading.
|
|
147
|
+
**Playlists.** A feed or `.m3u` URL downloads every item; `--playlist-items 1-3,7,10-` chooses some. Items are numbered in the file name (`01 - Title.mp3`). A failing item is reported and the rest continue (exit code 1). `-j` prints the playlist as one JSON object and `-F` lists its entries, without downloading. `--parallel N` downloads N items concurrently (extraction stays sequential so site plugins aren't hammered; only the downloads run in parallel, 1–16).
|
|
144
148
|
|
|
145
149
|
**Batch and archive.** `-a FILE` reads one URL per line (`#` starts a comment, `-` reads stdin). `--download-archive FILE` records each finished item and skips it on later runs.
|
|
146
150
|
|
|
147
151
|
**Config file.** Defaults go in `~/.config/tidepull/config` (or `--config-location FILE`): one or more options per line, `#` for comments, for example `-P ~/Videos` and `--limit-rate 2M`. Options on the command line win; `--no-config` ignores the file.
|
|
148
152
|
|
|
153
|
+
**Plugins on the command line.** `tidepull plugin install <pkg>` npm-installs a plugin and drops its entry file into the plugin dir; `plugin list` shows what is installed, `plugin remove FILE` deletes one. Explicit and user-triggered only — Tidepull never installs anything on its own. On startup the CLI checks npm (cached 24h, `TIDEPULL_NO_UPDATE_CHECK=1` to disable) and flags a stale core or plugin; the banner names the detected plugins, and two plugins claiming the same name warn and keep the first-loaded one.
|
|
154
|
+
|
|
149
155
|
### Terminal themes
|
|
150
156
|
|
|
151
157
|
The CLI colors its output from a named theme. `--theme NAME` picks one for that run; `TIDEPULL_THEME` sets the default in your environment or config file. The flag wins over the variable.
|
|
@@ -164,7 +170,7 @@ TIDEPULL_THEME=high-contrast tidepull URL # --theme still wins if you also
|
|
|
164
170
|
|
|
165
171
|
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.
|
|
166
172
|
|
|
167
|
-
On an interactive terminal the CLI shows
|
|
173
|
+
On an interactive terminal the CLI shows the wave wordmark banner while a download is queued (width-tiered so it stays readable on narrow or mobile fonts), with version and detected plugins underneath; a bare call adds the quick-start commands and one status line (ffmpeg found or not, plugin count, plugin dir). `--help`, `--version`, quiet, JSON, `-g`, simulate and non-TTY modes show neither banner nor spinner, so piped and one-off output stays data-only.
|
|
168
174
|
|
|
169
175
|
From a clone, `node src/cli.ts <args>` runs the TypeScript source directly (Node >= 22.18); `npm run build` emits JS + `.d.ts`.
|
|
170
176
|
|
|
@@ -198,21 +204,23 @@ From a clone, `node src/cli.ts <args>` runs the TypeScript source directly (Node
|
|
|
198
204
|
| Output templates | `%(title)s`, `%(x\|default)s`, `%(title).50s`, `%(n)02d`, sanitized |
|
|
199
205
|
| Playlists | RSS 2.0/1.0 and Atom feeds (`<enclosure>`, Atom enclosure links, Media RSS) and `.m3u` files; opt-in via `/feeds` (built into the CLI); entries are extracted one by one, in order |
|
|
200
206
|
| Cookies | Netscape `cookies.txt`; matched by domain, path, `Secure` and expiry; re-evaluated on every redirect hop |
|
|
201
|
-
| CLI conveniences | `-a` batch input, `--download-archive`, `--limit-rate`, `--config-location` |
|
|
207
|
+
| CLI conveniences | `-a` batch input, `--download-archive`, `--limit-rate`, `--parallel`, `--config-location`, `plugin install/list/remove` |
|
|
202
208
|
| Merge / remux | ffmpeg |
|
|
203
209
|
| Audio extraction | `-x` pulls the audio track into its own container with ffmpeg (`--audio-format`: mp3, m4a, opus, ogg, flac, wav, `best`); with no explicit `--format` the selector defaults to `ba/b` |
|
|
204
210
|
|
|
205
211
|
## Footprint (enforced in CI)
|
|
206
212
|
The core does only what every user needs: extract → select → download, events, cancellation. Everything else is a plugin or an opt-in subpath.
|
|
207
213
|
|
|
208
|
-
| Import | Files | Raw | Gzip |
|
|
209
|
-
|
|
210
|
-
| `@boy-offi9-inc/tidepull` (core: direct, HLS, generic page, selector, templates, resume, merge, audio extraction, playlists contract) | 18 |
|
|
211
|
-
| `@boy-offi9-inc/tidepull/dash` (adds XML + MPD parsing) |
|
|
212
|
-
| `@boy-offi9-inc/tidepull/feeds` (RSS/Atom + .m3u; shares the XML parser with dash) |
|
|
213
|
-
| `@boy-offi9-inc/tidepull/playlist` (`pullAll`, item selection) |
|
|
214
|
-
| `@boy-offi9-inc/tidepull/cookies` (cookies.txt) |
|
|
215
|
-
| `@boy-offi9-inc/tidepull/loader` (plugins from disk) |
|
|
214
|
+
| Import | Files | Raw | Gzip |
|
|
215
|
+
|---|---|---|---|
|
|
216
|
+
| `@boy-offi9-inc/tidepull` (core: direct, HLS, generic page, selector, templates, resume, merge, audio extraction, playlists contract, error codes) | 18 | 54.4 KB | 15.1 KB |
|
|
217
|
+
| `@boy-offi9-inc/tidepull/dash` (adds XML + MPD parsing) | 6 | 15.3 KB | 4.7 KB |
|
|
218
|
+
| `@boy-offi9-inc/tidepull/feeds` (RSS/Atom + .m3u; shares the XML parser with dash) | 5 | 7.9 KB | 2.8 KB |
|
|
219
|
+
| `@boy-offi9-inc/tidepull/playlist` (`pullAll`, item selection) | 1 | 3.9 KB | 1.5 KB |
|
|
220
|
+
| `@boy-offi9-inc/tidepull/cookies` (cookies.txt) | 2 | 3.0 KB | 1.2 KB |
|
|
221
|
+
| `@boy-offi9-inc/tidepull/loader` (plugins from disk) | 3 | 4.6 KB | 1.7 KB |
|
|
222
|
+
|
|
223
|
+
Numbers are what `node scripts/size.mjs dist/<entry>.js` reports for each subpath entry (files statically reachable from that entry); the subpath rows are their own modules, not including the core.
|
|
216
224
|
|
|
217
225
|
`npm run size` fails the build if the core grows past its budget. CLI and terminal UI are not part of `import "@boy-offi9-inc/tidepull"`.
|
|
218
226
|
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export declare class TidepullError extends Error {
|
|
2
2
|
exitCode: number;
|
|
3
|
-
|
|
3
|
+
code?: TidepullErrorCode;
|
|
4
|
+
remedy?: string;
|
|
5
|
+
constructor(message: string, exitCode?: number, opts?: {
|
|
6
|
+
code?: TidepullErrorCode;
|
|
7
|
+
remedy?: string;
|
|
8
|
+
});
|
|
4
9
|
}
|
|
10
|
+
export type TidepullErrorCode = "RATE_LIMITED" | "AUTH_REQUIRED" | "GEO_BLOCKED" | "EXTRACTOR_BROKEN" | "UNSUPPORTED" | "UPSTREAM_FAILED";
|
|
11
|
+
export declare const EXIT_CODES: Record<TidepullErrorCode, number>;
|
|
12
|
+
export declare function codedError(code: TidepullErrorCode, message: string, remedy?: string): TidepullError;
|
|
5
13
|
export declare const errMsg: (e: unknown) => string;
|
|
6
14
|
export declare function abortError(): TidepullError;
|
|
7
15
|
export declare class RedirectError extends TidepullError {
|
|
8
16
|
constructor(message: string);
|
|
9
17
|
}
|
|
18
|
+
export declare function httpErrorCode(status: number): TidepullErrorCode;
|
package/dist/core/errors.js
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
export class TidepullError extends Error {
|
|
2
2
|
exitCode;
|
|
3
|
-
|
|
3
|
+
code;
|
|
4
|
+
remedy;
|
|
5
|
+
constructor(message, exitCode = 1, opts = {}) {
|
|
4
6
|
super(message);
|
|
5
7
|
this.name = "TidepullError";
|
|
6
8
|
this.exitCode = exitCode;
|
|
9
|
+
if (opts.code)
|
|
10
|
+
this.code = opts.code;
|
|
11
|
+
if (opts.remedy)
|
|
12
|
+
this.remedy = opts.remedy;
|
|
7
13
|
}
|
|
8
14
|
}
|
|
15
|
+
export const EXIT_CODES = {
|
|
16
|
+
RATE_LIMITED: 75,
|
|
17
|
+
AUTH_REQUIRED: 77,
|
|
18
|
+
GEO_BLOCKED: 77,
|
|
19
|
+
EXTRACTOR_BROKEN: 70,
|
|
20
|
+
UNSUPPORTED: 64,
|
|
21
|
+
UPSTREAM_FAILED: 75,
|
|
22
|
+
};
|
|
23
|
+
export function codedError(code, message, remedy) {
|
|
24
|
+
return new TidepullError(message, EXIT_CODES[code], { code, remedy });
|
|
25
|
+
}
|
|
9
26
|
export const errMsg = (e) => (e instanceof Error ? e.message : String(e));
|
|
10
27
|
export function abortError() {
|
|
11
28
|
const e = new TidepullError("Aborted", 130);
|
|
@@ -18,3 +35,12 @@ export class RedirectError extends TidepullError {
|
|
|
18
35
|
this.name = "RedirectError";
|
|
19
36
|
}
|
|
20
37
|
}
|
|
38
|
+
export function httpErrorCode(status) {
|
|
39
|
+
if (status === 429)
|
|
40
|
+
return "RATE_LIMITED";
|
|
41
|
+
if (status === 401 || status === 403)
|
|
42
|
+
return "AUTH_REQUIRED";
|
|
43
|
+
if (status === 451)
|
|
44
|
+
return "GEO_BLOCKED";
|
|
45
|
+
return "UPSTREAM_FAILED";
|
|
46
|
+
}
|
package/dist/core/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TidepullError, RedirectError, errMsg } from "./errors.js";
|
|
1
|
+
import { TidepullError, RedirectError, errMsg, codedError, httpErrorCode } from "./errors.js";
|
|
2
2
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
3
3
|
const REDIRECT = new Set([301, 302, 303, 307, 308]);
|
|
4
4
|
const OPEN_HEADERS = new Set(["user-agent", "accept", "accept-language", "accept-encoding", "range", "referer", "origin"]);
|
|
@@ -58,7 +58,10 @@ export class Http {
|
|
|
58
58
|
const res = await this.follow(url, init);
|
|
59
59
|
if ((res.status >= 500 || res.status === 429) && attempt < this.retries) {
|
|
60
60
|
await res.body?.cancel();
|
|
61
|
-
|
|
61
|
+
const ra = Number(res.headers.get("retry-after"));
|
|
62
|
+
if (Number.isFinite(ra) && ra > 0)
|
|
63
|
+
await sleep(Math.min(ra * 1000, 15_000));
|
|
64
|
+
lastErr = codedError(httpErrorCode(res.status), `HTTP ${res.status} from ${url}`);
|
|
62
65
|
continue;
|
|
63
66
|
}
|
|
64
67
|
return res;
|
|
@@ -69,7 +72,11 @@ export class Http {
|
|
|
69
72
|
lastErr = e;
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
|
-
|
|
75
|
+
const status = lastStatus(lastErr);
|
|
76
|
+
if (status !== undefined) {
|
|
77
|
+
throw codedError(httpErrorCode(status), `Unable to reach ${url} after ${this.retries + 1} attempts: HTTP ${status}`);
|
|
78
|
+
}
|
|
79
|
+
throw codedError("UPSTREAM_FAILED", `Unable to reach ${url}: ${errMsg(lastErr)}`);
|
|
73
80
|
}
|
|
74
81
|
async follow(url, init) {
|
|
75
82
|
const start = new URL(url);
|
|
@@ -120,3 +127,11 @@ export class Http {
|
|
|
120
127
|
};
|
|
121
128
|
}
|
|
122
129
|
}
|
|
130
|
+
function lastStatus(e) {
|
|
131
|
+
if (e instanceof TidepullError) {
|
|
132
|
+
const m = /HTTP (\d{3})/.exec(e.message);
|
|
133
|
+
if (m)
|
|
134
|
+
return Number(m[1]);
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
package/dist/core/pipeline.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, rename, rm, stat } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { downloadDash, downloadHls, downloadHttp, RateLimiter } from "./downloader.js";
|
|
4
|
-
import { TidepullError } from "./errors.js";
|
|
4
|
+
import { TidepullError, codedError, errMsg } from "./errors.js";
|
|
5
5
|
import { findFfmpeg, mergeStreams, remux, extractAudio } from "./ffmpeg.js";
|
|
6
6
|
import { Meter } from "./meter.js";
|
|
7
7
|
import { selectFormats } from "./selector.js";
|
|
@@ -18,18 +18,34 @@ export async function resolveUrl(rawUrl, ctx) {
|
|
|
18
18
|
}
|
|
19
19
|
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
20
20
|
throw new TidepullError(`Unsupported URL scheme: ${url.protocol}`, 2);
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
throw
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const candidates = ctx.extractors.filter((e) => e.suitable(url));
|
|
22
|
+
if (candidates.length === 0)
|
|
23
|
+
throw codedError("UNSUPPORTED", `No extractor can handle ${url.href}`, "Check the URL, or install a plugin for this site (tidepull plugins)");
|
|
24
|
+
let lastErr;
|
|
25
|
+
for (const ex of candidates) {
|
|
26
|
+
ctx.emit({ type: "extract", extractor: ex.name, url: url.href });
|
|
27
|
+
let result;
|
|
28
|
+
try {
|
|
29
|
+
result = await ex.extract(url, ctx);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
if (ctx.signal?.aborted)
|
|
33
|
+
throw e;
|
|
34
|
+
lastErr = e;
|
|
35
|
+
ctx.log.debug(`extractor "${ex.name}" failed: ${e instanceof Error ? e.message : String(e)} — trying next candidate`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (isPlaylist(result)) {
|
|
39
|
+
if (!result.entries?.length)
|
|
40
|
+
throw new TidepullError(`Extractor "${ex.name}" returned an empty playlist`);
|
|
41
|
+
}
|
|
42
|
+
else if (!result.formats?.length)
|
|
43
|
+
throw new TidepullError(`Extractor "${ex.name}" returned no formats`);
|
|
44
|
+
return result;
|
|
29
45
|
}
|
|
30
|
-
|
|
31
|
-
throw
|
|
32
|
-
|
|
46
|
+
if (lastErr instanceof TidepullError)
|
|
47
|
+
throw lastErr;
|
|
48
|
+
throw new TidepullError(`All ${candidates.length} matching extractor(s) failed for ${url.href}: ${errMsg(lastErr)}`);
|
|
33
49
|
}
|
|
34
50
|
export async function extractInfo(rawUrl, ctx) {
|
|
35
51
|
const result = await resolveUrl(rawUrl, ctx);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { TidepullError } from "../core/errors.js";
|
|
1
|
+
import { TidepullError, codedError, httpErrorCode } from "../core/errors.js";
|
|
2
|
+
export { httpErrorCode };
|
|
2
3
|
import { extOf, stem } from "./util.js";
|
|
3
4
|
const VIDEO = new Set(["mp4", "m4v", "webm", "mkv", "mov", "flv", "avi", "ts"]);
|
|
4
5
|
const AUDIO = new Set(["mp3", "m4a", "aac", "ogg", "oga", "opus", "wav", "flac"]);
|
|
@@ -15,7 +16,7 @@ export async function extractDirect(url, ctx) {
|
|
|
15
16
|
res = await ctx.http.request(url.href, { headers: { Range: "bytes=0-0" } });
|
|
16
17
|
await res.body?.cancel();
|
|
17
18
|
if (!res.ok)
|
|
18
|
-
throw
|
|
19
|
+
throw codedError(httpErrorCode(res.status), `HTTP ${res.status} ${res.statusText} for ${url.href}`);
|
|
19
20
|
size = Number(/\/(\d+)$/.exec(res.headers.get("content-range") ?? "")?.[1]) || undefined;
|
|
20
21
|
}
|
|
21
22
|
const audioOnly = AUDIO.has(ext);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { TidepullError, errMsg } from "../core/errors.js";
|
|
1
|
+
import { TidepullError, errMsg, codedError } from "../core/errors.js";
|
|
2
|
+
import { httpErrorCode } from "./direct.js";
|
|
2
3
|
import { isPlaylist } from "../core/pipeline.js";
|
|
3
4
|
import { extractDirect } from "./direct.js";
|
|
4
5
|
import { extractHls } from "./hls.js";
|
|
@@ -64,7 +65,7 @@ export const genericExtractor = {
|
|
|
64
65
|
const res = await ctx.http.request(url.href);
|
|
65
66
|
if (!res.ok) {
|
|
66
67
|
await res.body?.cancel();
|
|
67
|
-
throw
|
|
68
|
+
throw codedError(httpErrorCode(res.status), `HTTP ${res.status} ${res.statusText} for ${url.href}`);
|
|
68
69
|
}
|
|
69
70
|
const ct = (res.headers.get("content-type") ?? "").toLowerCase();
|
|
70
71
|
if (FEED_CT.test(ct)) {
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export type { DownloadOptions } from "./core/pipeline.js";
|
|
|
8
8
|
export { isPlaylist } from "./core/pipeline.js";
|
|
9
9
|
export type { HttpOptions } from "./core/http.js";
|
|
10
10
|
export { Http } from "./core/http.js";
|
|
11
|
-
export { TidepullError } from "./core/errors.js";
|
|
11
|
+
export { TidepullError, codedError, EXIT_CODES } from "./core/errors.js";
|
|
12
|
+
export type { TidepullErrorCode } from "./core/errors.js";
|
|
12
13
|
export { selectFormats, DEFAULT_FORMAT } from "./core/selector.js";
|
|
13
14
|
export { renderTemplate, sanitize } from "./core/template.js";
|
|
14
15
|
export { parseMaster as parseHlsMaster, parseMedia as parseHlsMedia } from "./core/hls.js";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { Tidepull, createTidepull } from "./tidepull.js";
|
|
|
2
2
|
export { definePlugin, PLUGIN_API_VERSION } from "./plugins.js";
|
|
3
3
|
export { isPlaylist } from "./core/pipeline.js";
|
|
4
4
|
export { Http } from "./core/http.js";
|
|
5
|
-
export { TidepullError } from "./core/errors.js";
|
|
5
|
+
export { TidepullError, codedError, EXIT_CODES } from "./core/errors.js";
|
|
6
6
|
export { selectFormats, DEFAULT_FORMAT } from "./core/selector.js";
|
|
7
7
|
export { renderTemplate, sanitize } from "./core/template.js";
|
|
8
8
|
export { parseMaster as parseHlsMaster, parseMedia as parseHlsMedia } from "./core/hls.js";
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { DEFAULT_FORMAT, selectFormats } from "./core/selector.js";
|
|
3
|
-
import { TidepullError, errMsg } from "./core/errors.js";
|
|
3
|
+
import { TidepullError, errMsg, codedError } from "./core/errors.js";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
6
6
|
import { homedir } from "node:os";
|
|
@@ -105,7 +105,7 @@ General:
|
|
|
105
105
|
--version Show version
|
|
106
106
|
|
|
107
107
|
stdout carries data only (-j, -F, -g, --print-path, --progress-json). Everything else goes to stderr.
|
|
108
|
-
Exit codes: 0 ok, 1 error, 2 usage error, 130 interrupted.`;
|
|
108
|
+
Exit codes: 0 ok, 1 error, 2 usage error, 64 unsupported, 70 extractor broken, 75 rate-limited/transient (retry), 77 auth required, 130 interrupted.`;
|
|
109
109
|
function listFormats(info) {
|
|
110
110
|
const rows = [["ID", "EXT", "RESOLUTION", "FPS", "│", "SIZE", "TBR", "PROTO", "│", "VCODEC", "ACODEC", "NOTE"]];
|
|
111
111
|
const sorted = [...info.formats].sort((a, b) => (a.height ?? 0) - (b.height ?? 0) || (a.tbr ?? 0) - (b.tbr ?? 0));
|
|
@@ -390,9 +390,13 @@ export async function main(argv) {
|
|
|
390
390
|
process.once("SIGINT", onSigint);
|
|
391
391
|
let code = 0;
|
|
392
392
|
const report = (e, url) => {
|
|
393
|
+
const coded = e instanceof TidepullError ? e.code : undefined;
|
|
394
|
+
const remedy = e instanceof TidepullError ? e.remedy : undefined;
|
|
393
395
|
log.error(errMsg(e));
|
|
396
|
+
if (remedy)
|
|
397
|
+
log.error(`hint: ${remedy}`);
|
|
394
398
|
if (values["progress-json"])
|
|
395
|
-
process.stdout.write(JSON.stringify({ type: "error", message: errMsg(e), url }) + "\n");
|
|
399
|
+
process.stdout.write(JSON.stringify({ type: "error", message: errMsg(e), url, ...(coded ? { code: coded } : {}) }) + "\n");
|
|
396
400
|
if (values.verbose && e instanceof Error && e.stack)
|
|
397
401
|
process.stderr.write(e.stack + "\n");
|
|
398
402
|
code = Math.max(code, e instanceof TidepullError ? e.exitCode : 1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boy-offi9-inc/tidepull",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && node scripts/fix-dts.mjs",
|
|
26
26
|
"prepack": "npm run build",
|
|
27
27
|
"prepublishOnly": "npm run typecheck && npm test",
|
|
28
|
-
"size": "node scripts/size.mjs dist/index.js --budget=
|
|
28
|
+
"size": "node scripts/size.mjs dist/index.js --budget=56",
|
|
29
29
|
"lint:imports": "node scripts/lint-imports.mjs"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|