comfyclips 1.0.0 → 1.2.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
@@ -5,11 +5,12 @@ Interactive CLI to download video or audio from social media links (YouTube, Ins
5
5
  ## Requirements
6
6
 
7
7
  - Node.js >= 18
8
- - [ffmpeg](https://ffmpeg.org/) on your PATH — required to merge separate video/audio streams and to extract/convert audio formats. Without it, downloads may fail or fall back to lower quality.
9
- - Debian/Ubuntu: `sudo apt-get install ffmpeg`
10
- - macOS: `brew install ffmpeg`
11
- - Windows: `choco install ffmpeg` (or download from ffmpeg.org and add it to PATH)
12
- - `yt-dlp`not required ahead of time. If it isn't found on your PATH, ComfyClips downloads a copy automatically on first run into `~/.comfyclips/bin`.
8
+
9
+ That's it everything else is provisioned automatically:
10
+
11
+ - **ffmpeg** used to merge separate video/audio streams and to extract/convert audio formats. If it's not on your PATH, `npm install` fetches a static build for your platform (via `ffmpeg-static`).
12
+ - **yt-dlp**if it isn't found on your PATH, ComfyClips downloads a copy on first run into `~/.comfyclips/bin`.
13
+ - **Deno** — YouTube requires a JS runtime to solve its signature challenge. If it isn't found on your PATH, ComfyClips downloads it on first run into `~/.comfyclips/bin`.
13
14
 
14
15
  ## Install
15
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfyclips",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Interactive CLI to download video or audio from social media platforms (YouTube, Instagram, TikTok, Facebook, X/Twitter) via yt-dlp.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,14 +30,15 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@inquirer/core": "^12.0.0",
33
+ "adm-zip": "^0.6.0",
33
34
  "boxen": "^8.0.1",
34
35
  "chalk": "^5.3.0",
35
36
  "cli-progress": "^3.12.0",
36
37
  "cli-table3": "^0.6.5",
38
+ "ffmpeg-static": "^5.3.0",
37
39
  "figlet": "^1.11.4",
38
40
  "inquirer": "^14.1.0",
39
41
  "ora": "^8.1.0",
40
42
  "yt-dlp-wrap-plus": "^2.5.0"
41
- },
42
- "packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
43
+ }
43
44
  }
package/src/binaries.js CHANGED
@@ -1,5 +1,7 @@
1
+ import AdmZip from 'adm-zip';
2
+ import ffmpegStaticPath from 'ffmpeg-static';
1
3
  import { spawnSync } from 'node:child_process';
2
- import { existsSync, mkdirSync } from 'node:fs';
4
+ import { chmodSync, existsSync, mkdirSync, rmSync } from 'node:fs';
3
5
  import os from 'node:os';
4
6
  import path from 'node:path';
5
7
  import chalk from 'chalk';
@@ -9,15 +11,86 @@ import YTDlpWrap from './ytdlp-lib.js';
9
11
  const CACHE_DIR = path.join(os.homedir(), '.comfyclips', 'bin');
10
12
  const YT_DLP_BIN_NAME = os.platform() === 'win32' ? 'yt-dlp.exe' : 'yt-dlp';
11
13
  const CACHED_YT_DLP_PATH = path.join(CACHE_DIR, YT_DLP_BIN_NAME);
14
+ const DENO_BIN_NAME = os.platform() === 'win32' ? 'deno.exe' : 'deno';
15
+ const CACHED_DENO_PATH = path.join(CACHE_DIR, DENO_BIN_NAME);
16
+ const DENO_LATEST_RELEASE_API = 'https://api.github.com/repos/denoland/deno/releases/latest';
12
17
 
13
18
  function commandExists(cmd, versionFlag = '--version') {
14
19
  const result = spawnSync(cmd, [versionFlag], { stdio: 'ignore' });
15
20
  return !result.error && result.status === 0;
16
21
  }
17
22
 
18
- export function isFfmpegAvailable() {
23
+ // Prefer a system ffmpeg if the user already has one on PATH; otherwise fall
24
+ // back to the static binary `ffmpeg-static` already fetched via its own npm
25
+ // postinstall step, so no separate download step is needed here.
26
+ export function resolveFfmpeg() {
19
27
  // ffmpeg uses single-dash flags (-version), unlike most CLIs.
20
- return commandExists('ffmpeg', '-version');
28
+ if (commandExists('ffmpeg', '-version')) {
29
+ return { available: true, locationArgs: [] };
30
+ }
31
+ if (ffmpegStaticPath && existsSync(ffmpegStaticPath)) {
32
+ return { available: true, locationArgs: ['--ffmpeg-location', ffmpegStaticPath] };
33
+ }
34
+ return { available: false, locationArgs: [] };
35
+ }
36
+
37
+ function denoAssetName() {
38
+ const platform = os.platform();
39
+ const arch = os.arch() === 'arm64' ? 'aarch64' : 'x86_64';
40
+
41
+ if (platform === 'darwin') return `deno-${arch}-apple-darwin.zip`;
42
+ if (platform === 'win32') return `deno-${arch}-pc-windows-msvc.zip`;
43
+ return `deno-${arch}-unknown-linux-gnu.zip`;
44
+ }
45
+
46
+ async function downloadDeno(destPath) {
47
+ const release = await fetch(DENO_LATEST_RELEASE_API).then((res) => {
48
+ if (!res.ok) throw new Error(`GitHub API responded with ${res.status}`);
49
+ return res.json();
50
+ });
51
+
52
+ const assetName = denoAssetName();
53
+ const asset = release.assets?.find((a) => a.name === assetName);
54
+ if (!asset) throw new Error(`No Deno release asset found for ${assetName}`);
55
+
56
+ const zipBuffer = await fetch(asset.browser_download_url).then((res) => {
57
+ if (!res.ok) throw new Error(`Download responded with ${res.status}`);
58
+ return res.arrayBuffer();
59
+ });
60
+
61
+ const zip = new AdmZip(Buffer.from(zipBuffer));
62
+ const entry = zip.getEntries().find((e) => e.entryName === DENO_BIN_NAME);
63
+ if (!entry) throw new Error(`${DENO_BIN_NAME} not found inside downloaded archive`);
64
+
65
+ zip.extractEntryTo(entry, CACHE_DIR, false, true);
66
+ if (os.platform() !== 'win32') chmodSync(destPath, 0o755);
67
+ }
68
+
69
+ // YouTube's extractor needs a JS runtime (Deno) to solve its signature
70
+ // challenge; without one, most modern formats silently disappear from the
71
+ // list yt-dlp reports. Auto-provision it the same way we do for yt-dlp
72
+ // itself, so `npm install` alone is enough — no manual setup step.
73
+ export async function resolveJsRuntimeArgs() {
74
+ if (commandExists('deno', '--version')) {
75
+ return [];
76
+ }
77
+
78
+ if (existsSync(CACHED_DENO_PATH)) {
79
+ return ['--js-runtimes', `deno:${CACHED_DENO_PATH}`];
80
+ }
81
+
82
+ console.log(chalk.yellow('No JS runtime found — required for reliable YouTube downloads.'));
83
+ const spinner = ora('Downloading Deno runtime (one-time setup)...').start();
84
+ try {
85
+ mkdirSync(CACHE_DIR, { recursive: true });
86
+ await downloadDeno(CACHED_DENO_PATH);
87
+ spinner.succeed(`Deno downloaded to ${CACHED_DENO_PATH}`);
88
+ return ['--js-runtimes', `deno:${CACHED_DENO_PATH}`];
89
+ } catch (err) {
90
+ spinner.fail(`Failed to download Deno automatically: ${err.message}`);
91
+ rmSync(CACHED_DENO_PATH, { force: true });
92
+ return [];
93
+ }
21
94
  }
22
95
 
23
96
  export async function resolveYtDlpBinaryPath() {
package/src/downloader.js CHANGED
@@ -26,9 +26,26 @@ function videoFormatSelector(quality) {
26
26
  ].join('/');
27
27
  }
28
28
 
29
- export function buildArgs({ url, mode, quality, audioFormat, outputDir, ffmpegAvailable }) {
29
+ export function buildArgs({
30
+ url,
31
+ mode,
32
+ quality,
33
+ audioFormat,
34
+ outputDir,
35
+ ffmpegAvailable,
36
+ jsRuntimeArgs = [],
37
+ ffmpegLocationArgs = [],
38
+ }) {
30
39
  const outputTemplate = path.join(outputDir, '%(title)s.%(ext)s');
31
- const args = [url, '-o', outputTemplate, '--no-playlist', '--newline'];
40
+ const args = [
41
+ url,
42
+ '-o',
43
+ outputTemplate,
44
+ '--no-playlist',
45
+ '--newline',
46
+ ...jsRuntimeArgs,
47
+ ...ffmpegLocationArgs,
48
+ ];
32
49
  const warnings = [];
33
50
 
34
51
  if (mode === 'audio') {
@@ -61,6 +78,8 @@ export async function downloadMedia({
61
78
  audioFormat,
62
79
  outputDir,
63
80
  ffmpegAvailable,
81
+ jsRuntimeArgs,
82
+ ffmpegLocationArgs,
64
83
  }) {
65
84
  mkdirSync(outputDir, { recursive: true });
66
85
 
@@ -72,6 +91,8 @@ export async function downloadMedia({
72
91
  audioFormat,
73
92
  outputDir,
74
93
  ffmpegAvailable,
94
+ jsRuntimeArgs,
95
+ ffmpegLocationArgs,
75
96
  });
76
97
  warnings.forEach(printWarning);
77
98
 
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ import { readFileSync, statSync } from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import chalk from 'chalk';
5
5
  import inquirer from 'inquirer';
6
- import { isFfmpegAvailable, resolveYtDlpBinaryPath } from './binaries.js';
6
+ import { resolveFfmpeg, resolveJsRuntimeArgs, resolveYtDlpBinaryPath } from './binaries.js';
7
7
  import { downloadMedia } from './downloader.js';
8
8
  import { PLATFORMS, hostMatchesPlatform } from './platforms.js';
9
9
  import boxedSelect from './prompts/boxedSelect.js';
@@ -137,7 +137,8 @@ async function main() {
137
137
 
138
138
  try {
139
139
  const binaryPath = await resolveYtDlpBinaryPath();
140
- const ffmpegAvailable = isFfmpegAvailable();
140
+ const { available: ffmpegAvailable, locationArgs: ffmpegLocationArgs } = resolveFfmpeg();
141
+ const jsRuntimeArgs = await resolveJsRuntimeArgs();
141
142
 
142
143
  const { outputFile, elapsedSeconds } = await downloadMedia({
143
144
  binaryPath,
@@ -147,6 +148,8 @@ async function main() {
147
148
  audioFormat,
148
149
  outputDir,
149
150
  ffmpegAvailable,
151
+ jsRuntimeArgs,
152
+ ffmpegLocationArgs,
150
153
  });
151
154
 
152
155
  let fileSize = 'Unknown';