@boy-offi9-inc/tidepull 0.7.8 → 0.8.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 CHANGED
@@ -199,13 +199,14 @@ From a clone, `node src/cli.ts <args>` runs the TypeScript source directly (Node
199
199
  | Cookies | Netscape `cookies.txt`; matched by domain, path, `Secure` and expiry; re-evaluated on every redirect hop |
200
200
  | CLI conveniences | `-a` batch input, `--download-archive`, `--limit-rate`, `--config-location` |
201
201
  | Merge / remux | ffmpeg |
202
+ | 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` |
202
203
 
203
204
  ## Footprint (enforced in CI)
204
205
  The core does only what every user needs: extract → select → download, events, cancellation. Everything else is a plugin or an opt-in subpath.
205
206
 
206
207
  | Import | Files | Raw | Gzip | Minified (gzip) |
207
208
  |---|---|---|---|---|
208
- | `@boy-offi9-inc/tidepull` (core: direct, HLS, generic page, selector, templates, resume, merge, playlists contract) | 18 | 49.6 KB | 13.7 KB | 23 KB (9.7 KB) |
209
+ | `@boy-offi9-inc/tidepull` (core: direct, HLS, generic page, selector, templates, resume, merge, audio extraction, playlists contract) | 18 | 50.5 KB | 14.0 KB | 23 KB (9.7 KB) |
209
210
  | `@boy-offi9-inc/tidepull/dash` (adds XML + MPD parsing) | +6 | +14 KB | +4.7 KB | +7.1 KB (+3.3 KB) |
210
211
  | `@boy-offi9-inc/tidepull/feeds` (RSS/Atom + .m3u; shares the XML parser with dash) | +5 | +9 KB | +3.3 KB | +3.8 KB (+1.9 KB) |
211
212
  | `@boy-offi9-inc/tidepull/playlist` (`pullAll`, item selection) | +1 | +3.9 KB | +1.5 KB | +1.9 KB (+1.0 KB) |
@@ -29,6 +29,9 @@ export type TidepullEvent = {
29
29
  } | {
30
30
  type: "merge";
31
31
  output: string;
32
+ } | {
33
+ type: "extract-audio";
34
+ output: string;
32
35
  } | {
33
36
  type: "remux";
34
37
  output: string;
@@ -1,3 +1,4 @@
1
1
  export declare function findFfmpeg(location?: string): string | undefined;
2
2
  export declare const mergeStreams: (bin: string, video: string, audio: string, out: string) => Promise<void>;
3
3
  export declare const remux: (bin: string, input: string, out: string) => Promise<void>;
4
+ export declare const extractAudio: (bin: string, input: string, out: string, format: string) => Promise<void>;
@@ -36,3 +36,13 @@ function run(bin, args) {
36
36
  }
37
37
  export const mergeStreams = (bin, video, audio, out) => run(bin, ["-i", video, "-i", audio, "-map", "0:v:0", "-map", "1:a:0", "-c", "copy", out]);
38
38
  export const remux = (bin, input, out) => run(bin, ["-i", input, "-c", "copy", out]);
39
+ export const extractAudio = (bin, input, out, format) => run(bin, ["-i", input, "-vn", "-c:a", audioCodec(format), out]);
40
+ const AUDIO_CODECS = {
41
+ mp3: "libmp3lame", m4a: "aac", opus: "libopus", ogg: "libvorbis", flac: "flac", wav: "pcm_s16le", best: "copy",
42
+ };
43
+ function audioCodec(format) {
44
+ const c = AUDIO_CODECS[format];
45
+ if (!c)
46
+ throw new TidepullError(`Unsupported audio format: ${format} (available: ${Object.keys(AUDIO_CODECS).join(", ")})`, 2);
47
+ return c;
48
+ }
@@ -9,6 +9,7 @@ export interface DownloadOptions {
9
9
  concurrency: number;
10
10
  mergeFormat: string;
11
11
  remuxVideo?: string;
12
+ extractAudio?: string;
12
13
  ffmpeg?: string;
13
14
  headers: Record<string, string>;
14
15
  limitRate?: number;
@@ -2,7 +2,7 @@ import { mkdir, rename, rm, stat } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { downloadDash, downloadHls, downloadHlsSubtitles, downloadHttp, RateLimiter } from "./downloader.js";
4
4
  import { TidepullError } from "./errors.js";
5
- import { findFfmpeg, mergeStreams, remux } from "./ffmpeg.js";
5
+ import { findFfmpeg, mergeStreams, remux, extractAudio } from "./ffmpeg.js";
6
6
  import { Meter } from "./meter.js";
7
7
  import { selectFormats } from "./selector.js";
8
8
  import { renderTemplate } from "./template.js";
@@ -52,6 +52,9 @@ export async function downloadInfo(info, opts, ctx) {
52
52
  if (merging && !ffmpeg) {
53
53
  throw new TidepullError(`ffmpeg is required to merge ${chosen.map((f) => f.format_id).join("+")}. Install it, or pick one format (-f b).`);
54
54
  }
55
+ if (opts.extractAudio && !ffmpeg) {
56
+ throw new TidepullError("ffmpeg is required for --extract-audio. Install it, or drop -x.");
57
+ }
55
58
  const predictedExt = merging ? opts.mergeFormat : chosen[0].ext;
56
59
  const fields = {
57
60
  ...scalars(info),
@@ -129,6 +132,13 @@ export async function downloadInfo(info, opts, ctx) {
129
132
  await Promise.all(tmp.map((t) => rm(t, { force: true })));
130
133
  }
131
134
  }
135
+ if (opts.extractAudio) {
136
+ const out = `${base}.${opts.extractAudio === "best" ? "mka" : opts.extractAudio}`;
137
+ ctx.emit({ type: "extract-audio", output: out });
138
+ await extractAudio(ffmpeg, target, out, opts.extractAudio);
139
+ await rm(target, { force: true });
140
+ target = out;
141
+ }
132
142
  if (opts.remuxVideo && path.extname(target).slice(1) !== opts.remuxVideo) {
133
143
  if (!ffmpeg)
134
144
  throw new TidepullError("ffmpeg is required for --remux-video");
package/dist/main.js CHANGED
@@ -35,6 +35,8 @@ Output:
35
35
  --no-continue Do not resume partial downloads
36
36
  --merge-output-format Container when merging video+audio (default: mp4)
37
37
  --remux-video EXT Remux the result into EXT with ffmpeg (e.g. mp4)
38
+ -x, --extract-audio Extract the audio track into an audio file (ffmpeg required)
39
+ --audio-format FORMAT Audio container for -x: mp3, m4a, opus, ogg, flac, wav, best (default: best)
38
40
  --ffmpeg-location PATH ffmpeg binary or directory
39
41
 
40
42
  Info only (nothing is downloaded):
@@ -121,6 +123,8 @@ export async function main(argv) {
121
123
  "no-continue": { type: "boolean" },
122
124
  "merge-output-format": { type: "string" },
123
125
  "remux-video": { type: "string" },
126
+ "extract-audio": { type: "boolean", short: "x" },
127
+ "audio-format": { type: "string" },
124
128
  "ffmpeg-location": { type: "string" },
125
129
  "dump-json": { type: "boolean", short: "j" },
126
130
  "get-url": { type: "boolean", short: "g" },
@@ -255,7 +259,7 @@ export async function main(argv) {
255
259
  return 0;
256
260
  }
257
261
  const opts = {
258
- format: values.format ?? DEFAULT_FORMAT,
262
+ format: values.format ?? (values["extract-audio"] ? "ba/b" : DEFAULT_FORMAT),
259
263
  output: values.output,
260
264
  paths: values.paths,
261
265
  resume: !values["no-continue"],
@@ -263,6 +267,7 @@ export async function main(argv) {
263
267
  concurrency: Math.max(1, num(values["concurrent-fragments"], 4)),
264
268
  mergeFormat: values["merge-output-format"],
265
269
  remuxVideo: values["remux-video"],
270
+ extractAudio: values["extract-audio"] ? (values["audio-format"] ?? "best") : undefined,
266
271
  headers,
267
272
  limitRate,
268
273
  writeSubs: !!values["write-subs"],
package/dist/ui/render.js CHANGED
@@ -56,6 +56,9 @@ export function humanRenderer(log, o) {
56
56
  case "merge":
57
57
  log.tag("merger", `Merging formats into "${e.output}"`);
58
58
  break;
59
+ case "extract-audio":
60
+ log.tag("audio", `Extracting audio to "${e.output}"`);
61
+ break;
59
62
  case "remux":
60
63
  log.tag("remux", `Remuxing to "${e.output}"`);
61
64
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boy-offi9-inc/tidepull",
3
- "version": "0.7.8",
3
+ "version": "0.8.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=50",
28
+ "size": "node scripts/size.mjs dist/index.js --budget=52",
29
29
  "lint:imports": "node scripts/lint-imports.mjs"
30
30
  },
31
31
  "devDependencies": {