@dinoxx/dinox-cli 2.20.2 → 3.1.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 +17 -16
- package/dist/chunks/{applePodcast-V4FSJOC5.js → applePodcast-YDYM4JYQ.js} +3 -3
- package/dist/chunks/{bbc-NTMRPYRF.js → bbc-N3BM2EGG.js} +3 -3
- package/dist/chunks/{bilibili-UA3MBSPH.js → bilibili-V4XVW33T.js} +63 -9
- package/dist/chunks/{bohaishibei-B7UVXH4Y.js → bohaishibei-IQO5CZTN.js} +3 -3
- package/dist/chunks/{chunk-BZQYECIH.js → chunk-52XLDO77.js} +1 -1
- package/dist/chunks/{chunk-XEPDFQYD.js → chunk-5SORBZTD.js} +27 -27
- package/dist/chunks/{chunk-XMMTGPZ6.js → chunk-AZ43P73A.js} +56 -2
- package/dist/chunks/{chunk-W4EWLODY.js → chunk-DKY574LO.js} +3 -3
- package/dist/chunks/{chunk-4GM3PRSK.js → chunk-G6Y3MOUL.js} +6167 -3846
- package/dist/chunks/{chunk-BKCNERPB.js → chunk-JNRA4TTH.js} +99 -18
- package/dist/chunks/{chunk-3VZNZWDG.js → chunk-LAWV5XGL.js} +5 -0
- package/dist/chunks/{chunk-FIQYJ6KZ.js → chunk-LLAXR5EG.js} +1 -1
- package/dist/chunks/{chunk-MLOITAK6.js → chunk-LXC3IW4L.js} +2 -2
- package/dist/chunks/{chunk-TILRKKRN.js → chunk-MKEL2KNU.js} +893 -468
- package/dist/chunks/{chunk-7MGDG5BW.js → chunk-MMO7CINX.js} +499 -651
- package/dist/chunks/{chunk-FGQRYB7F.js → chunk-MZMOE3RX.js} +13 -1
- package/dist/chunks/{chunk-D3CETVY5.js → chunk-OZXS77HJ.js} +7 -7
- package/dist/chunks/{chunk-MDWXLRRN.js → chunk-PCB2JD6H.js} +6 -6
- package/dist/chunks/{chunk-6AZT4ARG.js → chunk-R2CGNGOT.js} +3 -3
- package/dist/chunks/{chunk-GTDX2LIJ.js → chunk-RSSEVU2F.js} +58 -10
- package/dist/chunks/{chunk-6D3QLMRM.js → chunk-TOGYWN3D.js} +1 -1
- package/dist/chunks/{chunk-CHGKDZV6.js → chunk-WCY3EKJQ.js} +4 -4
- package/dist/chunks/{chunk-QFSMFANX.js → chunk-YFGDTC2F.js} +9 -2
- package/dist/chunks/{chunk-QFUD3I7W.js → chunk-YX4SIEVS.js} +3 -4
- package/dist/chunks/{cookies-6QQHSM26.js → cookies-UUQZXH4R.js} +4 -6
- package/dist/chunks/{doubanGroup-HR4K2KMY.js → doubanGroup-MADXDGDI.js} +4 -4
- package/dist/chunks/{doubao-MXUHPLUB.js → doubao-DKZERP6Y.js} +2 -2
- package/dist/chunks/{douyin-UU2FSQPS.js → douyin-PIWFZHK7.js} +91 -5
- package/dist/chunks/{ensure-E3DIRHSQ.js → ensure-2OPNFDRW.js} +7 -7
- package/dist/chunks/{execute-YP2N2AMS.js → execute-C5W5ZJDC.js} +5 -5
- package/dist/chunks/{facebook-SZFOVE7R.js → facebook-TI2CF5UY.js} +2 -2
- package/dist/chunks/{feishu-ISWRJ7HI.js → feishu-XSSEBWQD.js} +2 -2
- package/dist/chunks/{ima-D7CX5WR4.js → ima-SKE2C64C.js} +2 -2
- package/dist/chunks/{instagram-HNDPO37H.js → instagram-4W4HCWJN.js} +2 -2
- package/dist/chunks/{install-IIMVFNAT.js → install-VBMWNPO6.js} +1 -3
- package/dist/chunks/{jike-H7L4LJTN.js → jike-GS64MEEO.js} +4 -4
- package/dist/chunks/{mcp-AK373P5P.js → mcp-WK7KIU44.js} +14 -12
- package/dist/chunks/{mcpServer-7VL4KJH2.js → mcpServer-M4HJFSNU.js} +17 -15
- package/dist/chunks/{metaso-ZVZW5UBB.js → metaso-RRYEUXIL.js} +2 -2
- package/dist/chunks/{run-OYMMVKCB.js → run-WNHMZLSJ.js} +11 -11
- package/dist/chunks/{runCli-ZJ7WYHJ7.js → runCli-GKTCIDBF.js} +12 -12
- package/dist/chunks/{setup-EEU6GSWX.js → setup-UYCLFOZH.js} +6 -6
- package/dist/chunks/{threads-ADW6IANQ.js → threads-JKMT3E73.js} +3 -3
- package/dist/chunks/{twitter-NAGCB3NI.js → twitter-WNBOJELM.js} +2 -2
- package/dist/chunks/{web-QFKZCM4F.js → web-LJESVHHV.js} +4 -4
- package/dist/chunks/{wechat-OXNNLT4J.js → wechat-N7O77CB4.js} +40 -1
- package/dist/chunks/{weibo-PMVGDNQU.js → weibo-XPEV5CLQ.js} +4 -4
- package/dist/chunks/{workbuddy-NNAXIIIZ.js → workbuddy-ZXNDX7O7.js} +5 -5
- package/dist/chunks/{xiaoheihe-WFQJRBAD.js → xiaoheihe-WXFAORLQ.js} +3 -3
- package/dist/chunks/{xiaohongshu-5CXBELGW.js → xiaohongshu-3N3ZVSXJ.js} +2 -2
- package/dist/chunks/{xiaoyuzhou-6L6IB46Y.js → xiaoyuzhou-OGIWFABL.js} +3 -3
- package/dist/chunks/{youtube-52NGBTQC.js → youtube-YRSK7CWC.js} +3 -3
- package/dist/chunks/{zcool-HDSWK4KD.js → zcool-K5KJ2KDG.js} +2 -2
- package/dist/chunks/{zhihu-EX2VRJYY.js → zhihu-X6XSPD6B.js} +2 -2
- package/dist/dinox.js +7 -7
- package/dist/dsh-plugin/lib/client.js +1030 -578
- package/dist/dsh-plugin/lib/index.js +11 -7
- package/dist/dsh-plugin/package.json +1 -1
- package/dist/dsh-plugin/runtime.json +2 -2
- package/dist/editor-ui/mcp-app.html +449 -583
- package/package.json +25 -12
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
2
2
|
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
clipEngineConfig
|
|
5
|
+
} from "./chunk-F7BDWXBG.js";
|
|
3
6
|
|
|
4
7
|
// ../../packages/clip-engine/src/net/cookieHeader.ts
|
|
5
8
|
import { readFile } from "node:fs/promises";
|
|
@@ -29,6 +32,15 @@ async function loadCookieHeader(cookiesFile, domainMatch) {
|
|
|
29
32
|
return pairs.join("; ");
|
|
30
33
|
}
|
|
31
34
|
|
|
35
|
+
// ../../packages/clip-engine/src/videoBudget.ts
|
|
36
|
+
function currentVideoByteBudget() {
|
|
37
|
+
const { maxVideoBytes, videoByteBudget } = clipEngineConfig().media;
|
|
38
|
+
const budget = videoByteBudget?.();
|
|
39
|
+
if (!budget || !Number.isFinite(budget.bytes)) return void 0;
|
|
40
|
+
return { bytes: Math.max(0, Math.min(budget.bytes, maxVideoBytes)), measured: budget.measured };
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
export {
|
|
33
|
-
loadCookieHeader
|
|
44
|
+
loadCookieHeader,
|
|
45
|
+
currentVideoByteBudget
|
|
34
46
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
2
2
|
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
DEFAULT_DAEMON_PORT,
|
|
5
4
|
closePowerSyncAndReleaseOwner,
|
|
6
5
|
connectPowerSync,
|
|
7
6
|
createTimeoutSignal,
|
|
@@ -14,14 +13,15 @@ import {
|
|
|
14
13
|
waitForDownloadIdle,
|
|
15
14
|
waitForLastSyncedAfter,
|
|
16
15
|
waitForUploadQueueEmpty
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-G6Y3MOUL.js";
|
|
18
17
|
import {
|
|
19
18
|
fingerprintDaemonRuntimeConfig,
|
|
20
19
|
loadConfig,
|
|
21
20
|
parseSyncTimeoutMs,
|
|
22
21
|
resolveConfig
|
|
23
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-WCY3EKJQ.js";
|
|
24
23
|
import {
|
|
24
|
+
DEFAULT_DAEMON_PORT,
|
|
25
25
|
acquireDaemonExclusiveIntentLock,
|
|
26
26
|
acquireDaemonStartLock,
|
|
27
27
|
getDaemonInfo,
|
|
@@ -32,23 +32,23 @@ import {
|
|
|
32
32
|
remainingDeadlineMs,
|
|
33
33
|
runWithinDeadline,
|
|
34
34
|
shutdownDaemonForExclusiveAccess
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-YFGDTC2F.js";
|
|
36
36
|
import {
|
|
37
37
|
getPackageVersion
|
|
38
38
|
} from "./chunk-WMJXAF3X.js";
|
|
39
39
|
import {
|
|
40
40
|
readStringOrFile
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-LXC3IW4L.js";
|
|
42
42
|
import {
|
|
43
43
|
printHumanReadableWarning,
|
|
44
44
|
requestContext
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-TOGYWN3D.js";
|
|
46
46
|
import {
|
|
47
47
|
getPowerSyncDbPath
|
|
48
48
|
} from "./chunk-XZLFMJOG.js";
|
|
49
49
|
import {
|
|
50
50
|
DinoxError
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-LAWV5XGL.js";
|
|
52
52
|
|
|
53
53
|
// src/daemon/lifecycle.ts
|
|
54
54
|
import { existsSync } from "node:fs";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
2
2
|
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
DEFAULT_DAEMON_PORT,
|
|
5
4
|
hydrateResolvedAuthIdentity,
|
|
6
5
|
restartDaemonLocked,
|
|
7
6
|
stopDaemonLocked
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-G6Y3MOUL.js";
|
|
9
8
|
import {
|
|
10
9
|
daemonServiceSpec,
|
|
11
10
|
fingerprintDaemonRuntimeConfig,
|
|
@@ -17,8 +16,9 @@ import {
|
|
|
17
16
|
resolveConfig,
|
|
18
17
|
usableDaemonService,
|
|
19
18
|
withAsyncRelease
|
|
20
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WCY3EKJQ.js";
|
|
21
20
|
import {
|
|
21
|
+
DEFAULT_DAEMON_PORT,
|
|
22
22
|
acquireDaemonStartLock,
|
|
23
23
|
getDaemonInfo,
|
|
24
24
|
getDaemonService,
|
|
@@ -27,16 +27,16 @@ import {
|
|
|
27
27
|
isProcessRunning,
|
|
28
28
|
readPid,
|
|
29
29
|
waitForFreshDaemon
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-YFGDTC2F.js";
|
|
31
31
|
import {
|
|
32
32
|
getPackageVersion
|
|
33
33
|
} from "./chunk-WMJXAF3X.js";
|
|
34
34
|
import {
|
|
35
35
|
printHumanReadableWarning
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-TOGYWN3D.js";
|
|
37
37
|
import {
|
|
38
38
|
DinoxError
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-LAWV5XGL.js";
|
|
40
40
|
|
|
41
41
|
// src/daemon/ensure.ts
|
|
42
42
|
import { existsSync } from "node:fs";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isDoubanUrl,
|
|
21
21
|
parseWebHtml,
|
|
22
22
|
replaceWebMarkdownImageUrls
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-MKEL2KNU.js";
|
|
24
24
|
import {
|
|
25
25
|
WebToMarkdownError
|
|
26
26
|
} from "./chunk-PTFGE4KS.js";
|
|
@@ -305,8 +305,8 @@ async function postJson(path, body, options, link) {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
function textToHtml(text) {
|
|
308
|
-
const
|
|
309
|
-
return text.split(/\n+/).map((line) => line.trim()).filter(Boolean).map((line) => `<p>${
|
|
308
|
+
const escapeHtml2 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
309
|
+
return text.split(/\n+/).map((line) => line.trim()).filter(Boolean).map((line) => `<p>${escapeHtml2(line)}</p>`).join("\n");
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
// ../../packages/clip-engine/src/lookiToMarkdown/index.ts
|
|
@@ -2,7 +2,7 @@ import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
composeClipMarkdown
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LLAXR5EG.js";
|
|
6
6
|
import {
|
|
7
7
|
clipEngineConfig
|
|
8
8
|
} from "./chunk-F7BDWXBG.js";
|
|
@@ -10,11 +10,6 @@ import {
|
|
|
10
10
|
formatBeijingDate
|
|
11
11
|
} from "./chunk-AHRCI2RW.js";
|
|
12
12
|
|
|
13
|
-
// ../../packages/clip-engine/src/ytdlpVideo/extract.ts
|
|
14
|
-
import { spawn } from "node:child_process";
|
|
15
|
-
import { readdir, rm, stat } from "node:fs/promises";
|
|
16
|
-
import { join } from "node:path";
|
|
17
|
-
|
|
18
13
|
// ../../packages/clip-engine/src/ytdlpVideo/errors.ts
|
|
19
14
|
var VideoExtractError = class extends Error {
|
|
20
15
|
code;
|
|
@@ -28,6 +23,9 @@ var VideoExtractError = class extends Error {
|
|
|
28
23
|
};
|
|
29
24
|
|
|
30
25
|
// ../../packages/clip-engine/src/ytdlpVideo/extract.ts
|
|
26
|
+
import { spawn } from "node:child_process";
|
|
27
|
+
import { readdir, rm, stat } from "node:fs/promises";
|
|
28
|
+
import { join } from "node:path";
|
|
31
29
|
var DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36";
|
|
32
30
|
var METADATA_TIMEOUT_MS = 6e4;
|
|
33
31
|
var VIDEO_BASENAME = "ytdlp-video";
|
|
@@ -54,6 +52,9 @@ function videoExtractErrorFromYtDlp(stderr, url, code = null) {
|
|
|
54
52
|
return new VideoExtractError("METADATA_FAILED", message, { url });
|
|
55
53
|
}
|
|
56
54
|
async function resolveVideoMetadata(url, opts) {
|
|
55
|
+
return (await resolveVideoInfo(url, opts)).metadata;
|
|
56
|
+
}
|
|
57
|
+
async function resolveVideoInfo(url, opts) {
|
|
57
58
|
const { stdout, stderr, code } = await runYtDlp(opts, [...commonArgs(opts), "-J", "--no-playlist", url], METADATA_TIMEOUT_MS);
|
|
58
59
|
if (code !== 0 || !stdout.trim()) {
|
|
59
60
|
throw videoExtractErrorFromYtDlp(stderr, url, code);
|
|
@@ -72,7 +73,7 @@ async function resolveVideoMetadata(url, opts) {
|
|
|
72
73
|
if (!metadata.title) {
|
|
73
74
|
throw new VideoExtractError("CONTENT_NOT_FOUND", "video has no title", { url });
|
|
74
75
|
}
|
|
75
|
-
return metadata;
|
|
76
|
+
return { info, metadata };
|
|
76
77
|
}
|
|
77
78
|
function buildVideoFormatSelector(maxHeight) {
|
|
78
79
|
const h = `[height<=${maxHeight}]`;
|
|
@@ -87,13 +88,14 @@ function buildVideoFormatSelector(maxHeight) {
|
|
|
87
88
|
}
|
|
88
89
|
async function downloadVideo(input) {
|
|
89
90
|
const maxBytes = clipEngineConfig().media.maxVideoBytes;
|
|
90
|
-
const { opts, outDir, url } = input;
|
|
91
|
+
const { opts, outDir, preferredFormat, url } = input;
|
|
92
|
+
const ladder = buildVideoFormatSelector(opts.maxHeight);
|
|
91
93
|
const args = [
|
|
92
94
|
...commonArgs(opts),
|
|
93
95
|
"--no-playlist",
|
|
94
96
|
"--no-progress",
|
|
95
97
|
"-f",
|
|
96
|
-
|
|
98
|
+
preferredFormat ? `${preferredFormat}/${ladder}` : ladder,
|
|
97
99
|
"--merge-output-format",
|
|
98
100
|
"mp4",
|
|
99
101
|
"--max-filesize",
|
|
@@ -256,10 +258,56 @@ function formatDuration(seconds) {
|
|
|
256
258
|
return hh > 0 ? `${hh}:${pad(mm)}:${pad(ss)}` : `${mm}:${pad(ss)}`;
|
|
257
259
|
}
|
|
258
260
|
|
|
261
|
+
// ../../packages/clip-engine/src/ytdlpVideo/formatBudget.ts
|
|
262
|
+
function estimateFormatBytes(format, durationSeconds) {
|
|
263
|
+
const exact = positive(format.filesize) ?? positive(format.filesize_approx);
|
|
264
|
+
if (exact) return exact;
|
|
265
|
+
const kbps = positive(format.tbr);
|
|
266
|
+
return kbps && durationSeconds ? Math.round(kbps * 1e3 * durationSeconds / 8) : void 0;
|
|
267
|
+
}
|
|
268
|
+
function pickBudgetedFormat(info, input) {
|
|
269
|
+
const formats = Array.isArray(info.formats) ? info.formats : [];
|
|
270
|
+
const duration = positive(info.duration);
|
|
271
|
+
const sized = formats.filter((f) => f.format_id).map((f) => ({ bytes: estimateFormatBytes(f, duration), f })).filter((x) => x.bytes !== void 0);
|
|
272
|
+
const hasVideo = (f) => Boolean(f.vcodec && f.vcodec !== "none");
|
|
273
|
+
const hasAudio = (f) => Boolean(f.acodec && f.acodec !== "none");
|
|
274
|
+
const avc = (f) => /^avc1/i.test(f.vcodec ?? "");
|
|
275
|
+
const inHeight = (f) => (f.height ?? 0) > 0 && (f.height ?? 0) <= input.maxHeight;
|
|
276
|
+
const audioOnly = sized.filter((x) => hasAudio(x.f) && !hasVideo(x.f));
|
|
277
|
+
const aac = audioOnly.filter((x) => /^mp4a/i.test(x.f.acodec ?? ""));
|
|
278
|
+
const audio = (aac.length > 0 ? aac : audioOnly).sort((a, b) => a.bytes - b.bytes)[0];
|
|
279
|
+
const candidates = [];
|
|
280
|
+
for (const x of sized) {
|
|
281
|
+
if (!hasVideo(x.f) || !inHeight(x.f)) continue;
|
|
282
|
+
if (hasAudio(x.f)) {
|
|
283
|
+
candidates.push({ avc: avc(x.f), bytes: x.bytes, height: x.f.height, selector: x.f.format_id });
|
|
284
|
+
} else if (audio) {
|
|
285
|
+
candidates.push({
|
|
286
|
+
avc: avc(x.f),
|
|
287
|
+
bytes: x.bytes + audio.bytes,
|
|
288
|
+
height: x.f.height,
|
|
289
|
+
selector: `${x.f.format_id}+${audio.f.format_id}`
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const pool = candidates.some((c) => c.avc) ? candidates.filter((c) => c.avc) : candidates;
|
|
294
|
+
if (pool.length === 0) return void 0;
|
|
295
|
+
pool.sort((a, b) => b.height - a.height || b.bytes - a.bytes);
|
|
296
|
+
const fit = pool.find((c) => c.bytes <= input.budgetBytes);
|
|
297
|
+
const chosen = fit ?? [...pool].sort((a, b) => a.bytes - b.bytes)[0];
|
|
298
|
+
return { estimatedBytes: chosen.bytes, fits: Boolean(fit), height: chosen.height, selector: chosen.selector };
|
|
299
|
+
}
|
|
300
|
+
function positive(value) {
|
|
301
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
302
|
+
}
|
|
303
|
+
|
|
259
304
|
export {
|
|
305
|
+
VideoExtractError,
|
|
260
306
|
resolveVideoMetadata,
|
|
307
|
+
resolveVideoInfo,
|
|
261
308
|
downloadVideo,
|
|
262
309
|
downloadAudio,
|
|
263
310
|
buildVideoMarkdown,
|
|
264
|
-
formatDuration
|
|
311
|
+
formatDuration,
|
|
312
|
+
pickBudgetedFormat
|
|
265
313
|
};
|
|
@@ -2,7 +2,7 @@ import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
DinoxError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LAWV5XGL.js";
|
|
6
6
|
|
|
7
7
|
// src/utils/requestContext.ts
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
getDaemonInfo,
|
|
9
9
|
getDaemonService,
|
|
10
10
|
sendDaemonRequest
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-YFGDTC2F.js";
|
|
12
12
|
import {
|
|
13
13
|
getPackageVersion
|
|
14
14
|
} from "./chunk-WMJXAF3X.js";
|
|
15
15
|
import {
|
|
16
16
|
printHumanReadableWarning
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TOGYWN3D.js";
|
|
18
18
|
import {
|
|
19
19
|
getConfigDir,
|
|
20
20
|
getConfigFilePath,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-XZLFMJOG.js";
|
|
23
23
|
import {
|
|
24
24
|
DinoxError
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-LAWV5XGL.js";
|
|
26
26
|
|
|
27
27
|
// src/utils/id.ts
|
|
28
28
|
import { uuidv7 } from "uuidv7";
|
|
@@ -736,7 +736,7 @@ var forwardDependencies = {
|
|
|
736
736
|
return Boolean(info && matchesRuntimeTokenBinding(info, version, config));
|
|
737
737
|
},
|
|
738
738
|
ensureDaemonRunning: async () => {
|
|
739
|
-
await (await import("./ensure-
|
|
739
|
+
await (await import("./ensure-2OPNFDRW.js")).ensureDaemonRunning();
|
|
740
740
|
},
|
|
741
741
|
sendDaemonRequest,
|
|
742
742
|
envTokenOverridesLogin,
|
|
@@ -10,7 +10,11 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
DinoxError,
|
|
12
12
|
wireErrorCode
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-LAWV5XGL.js";
|
|
14
|
+
|
|
15
|
+
// src/daemon/types.ts
|
|
16
|
+
var DEFAULT_DAEMON_PORT = 45678;
|
|
17
|
+
var DAEMON_METHOD_HEADER = "x-dinox-method";
|
|
14
18
|
|
|
15
19
|
// src/daemon/supervisor.ts
|
|
16
20
|
import crypto from "node:crypto";
|
|
@@ -874,7 +878,8 @@ async function sendDaemonRequest(method, params, requestOptions = {}) {
|
|
|
874
878
|
headers: {
|
|
875
879
|
Host: "dinox-daemon",
|
|
876
880
|
"Content-Type": "application/json",
|
|
877
|
-
"Content-Length": Buffer.byteLength(data)
|
|
881
|
+
"Content-Length": Buffer.byteLength(data),
|
|
882
|
+
.../^[\w.]{1,100}$/.test(method) ? { [DAEMON_METHOD_HEADER]: method } : {}
|
|
878
883
|
},
|
|
879
884
|
timeout: timeoutMs
|
|
880
885
|
};
|
|
@@ -1193,6 +1198,8 @@ async function shutdownDaemonForExclusiveAccess(timeoutMs = 5e3, expectedInstanc
|
|
|
1193
1198
|
|
|
1194
1199
|
export {
|
|
1195
1200
|
acquireExclusiveSqliteLease,
|
|
1201
|
+
DEFAULT_DAEMON_PORT,
|
|
1202
|
+
DAEMON_METHOD_HEADER,
|
|
1196
1203
|
DAEMON_SERVICE_ENV,
|
|
1197
1204
|
getDaemonService,
|
|
1198
1205
|
getDaemonDir,
|
|
@@ -2,7 +2,7 @@ import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
readStringOrFile
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-LXC3IW4L.js";
|
|
6
6
|
import {
|
|
7
7
|
parseNetscapeCookies
|
|
8
8
|
} from "./chunk-ULKGDBAJ.js";
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
printHumanReadableLine,
|
|
12
12
|
printSuccess,
|
|
13
13
|
resolveUserPath
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-TOGYWN3D.js";
|
|
15
15
|
import {
|
|
16
16
|
getDataDir
|
|
17
17
|
} from "./chunk-XZLFMJOG.js";
|
|
18
18
|
import {
|
|
19
19
|
DinoxError
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-LAWV5XGL.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/clip/cookies.ts
|
|
23
23
|
import fs from "node:fs/promises";
|
|
@@ -172,7 +172,6 @@ async function readStdin() {
|
|
|
172
172
|
|
|
173
173
|
export {
|
|
174
174
|
clipCookiesFile,
|
|
175
|
-
normalizeDomain,
|
|
176
175
|
serializeNetscapeCookies,
|
|
177
176
|
parseCookieHeader,
|
|
178
177
|
mergeCookies,
|
|
@@ -3,7 +3,6 @@ const require = __dinoxCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
clipCookiesFile,
|
|
5
5
|
mergeCookies,
|
|
6
|
-
normalizeDomain,
|
|
7
6
|
parseCookieHeader,
|
|
8
7
|
readCookieJar,
|
|
9
8
|
runClipCookiesImport,
|
|
@@ -12,17 +11,16 @@ import {
|
|
|
12
11
|
runClipCookiesSet,
|
|
13
12
|
serializeNetscapeCookies,
|
|
14
13
|
summarizeCookies
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-YX4SIEVS.js";
|
|
15
|
+
import "./chunk-LXC3IW4L.js";
|
|
17
16
|
import "./chunk-ULKGDBAJ.js";
|
|
18
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-TOGYWN3D.js";
|
|
19
18
|
import "./chunk-XZLFMJOG.js";
|
|
20
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-LAWV5XGL.js";
|
|
21
20
|
import "./chunk-XQZUX7OT.js";
|
|
22
21
|
export {
|
|
23
22
|
clipCookiesFile,
|
|
24
23
|
mergeCookies,
|
|
25
|
-
normalizeDomain,
|
|
26
24
|
parseCookieHeader,
|
|
27
25
|
readCookieJar,
|
|
28
26
|
runClipCookiesImport,
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
} from "./chunk-D5SBKLDX.js";
|
|
8
8
|
import {
|
|
9
9
|
extractWebClip
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-R2CGNGOT.js";
|
|
11
11
|
import {
|
|
12
12
|
loadBrowserCookies
|
|
13
13
|
} from "./chunk-ULKGDBAJ.js";
|
|
14
14
|
import {
|
|
15
15
|
DOUBAN_HOST_RE,
|
|
16
16
|
downloadWebImages
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-MKEL2KNU.js";
|
|
18
18
|
import "./chunk-2LW76QIL.js";
|
|
19
19
|
import "./chunk-PTFGE4KS.js";
|
|
20
20
|
import "./chunk-PJDD4R46.js";
|
|
@@ -31,8 +31,8 @@ import {
|
|
|
31
31
|
import "./chunk-QZQRG3JY.js";
|
|
32
32
|
import {
|
|
33
33
|
composeClipMarkdown
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-LLAXR5EG.js";
|
|
35
|
+
import "./chunk-AZ43P73A.js";
|
|
36
36
|
import {
|
|
37
37
|
unwrapRedirectUrl
|
|
38
38
|
} from "./chunk-URYABAYN.js";
|
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
} from "./chunk-QZQRG3JY.js";
|
|
14
14
|
import {
|
|
15
15
|
composeClipMarkdown
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-LLAXR5EG.js";
|
|
17
|
+
import "./chunk-AZ43P73A.js";
|
|
18
18
|
import "./chunk-URYABAYN.js";
|
|
19
19
|
import {
|
|
20
20
|
clipEngineConfig
|
|
@@ -5,11 +5,12 @@ import {
|
|
|
5
5
|
assertDouyinUrl
|
|
6
6
|
} from "./chunk-ABYPGMDC.js";
|
|
7
7
|
import {
|
|
8
|
+
currentVideoByteBudget,
|
|
8
9
|
loadCookieHeader
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-MZMOE3RX.js";
|
|
10
11
|
import {
|
|
11
12
|
buildVideoMarkdown
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RSSEVU2F.js";
|
|
13
14
|
import {
|
|
14
15
|
summarizeImageFailures
|
|
15
16
|
} from "./chunk-5KU25TMX.js";
|
|
@@ -19,8 +20,8 @@ import {
|
|
|
19
20
|
} from "./chunk-QZQRG3JY.js";
|
|
20
21
|
import {
|
|
21
22
|
composeClipMarkdown
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-LLAXR5EG.js";
|
|
24
|
+
import "./chunk-AZ43P73A.js";
|
|
24
25
|
import "./chunk-URYABAYN.js";
|
|
25
26
|
import {
|
|
26
27
|
clipEngineConfig,
|
|
@@ -64,6 +65,60 @@ async function downloadDouyinVideo(input) {
|
|
|
64
65
|
type: "video"
|
|
65
66
|
};
|
|
66
67
|
}
|
|
68
|
+
var DOUYIN_RATIO_LADDER = ["720p", "540p"];
|
|
69
|
+
function douyinRatioVariants(videoUrl) {
|
|
70
|
+
let url;
|
|
71
|
+
try {
|
|
72
|
+
url = new URL(videoUrl);
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (!/\/aweme\/v1\/play\/?$/.test(url.pathname) || !url.searchParams.has("ratio")) return null;
|
|
77
|
+
return DOUYIN_RATIO_LADDER.map((ratio) => {
|
|
78
|
+
const variant = new URL(url);
|
|
79
|
+
variant.searchParams.set("ratio", ratio);
|
|
80
|
+
return variant.toString();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async function probeDouyinVideoBytes(input) {
|
|
84
|
+
const fetcher = input.fetcher ?? fetch;
|
|
85
|
+
const controller = new AbortController();
|
|
86
|
+
const timer = setTimeout(() => controller.abort(), input.timeoutMs ?? 15e3);
|
|
87
|
+
try {
|
|
88
|
+
const response = await fetcher(input.videoUrl, {
|
|
89
|
+
headers: {
|
|
90
|
+
Accept: "*/*",
|
|
91
|
+
Range: "bytes=0-0",
|
|
92
|
+
Referer: "https://www.douyin.com/",
|
|
93
|
+
"User-Agent": MOBILE_UA,
|
|
94
|
+
...input.cookieHeader ? { Cookie: input.cookieHeader } : {}
|
|
95
|
+
},
|
|
96
|
+
redirect: "follow",
|
|
97
|
+
signal: controller.signal
|
|
98
|
+
});
|
|
99
|
+
await response.body?.cancel().catch(() => void 0);
|
|
100
|
+
if (!response.ok) return void 0;
|
|
101
|
+
const total = /\/(\d+)\s*$/.exec(response.headers.get("content-range") ?? "")?.[1];
|
|
102
|
+
const bytes = Number.parseInt(total ?? (response.status === 200 ? response.headers.get("content-length") ?? "" : ""), 10);
|
|
103
|
+
return Number.isFinite(bytes) && bytes > 0 ? bytes : void 0;
|
|
104
|
+
} catch {
|
|
105
|
+
return void 0;
|
|
106
|
+
} finally {
|
|
107
|
+
clearTimeout(timer);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function pickDouyinVideoUrl(input) {
|
|
111
|
+
const variants = douyinRatioVariants(input.videoUrl);
|
|
112
|
+
if (!variants) return { fits: true, videoUrl: input.videoUrl };
|
|
113
|
+
let smallest;
|
|
114
|
+
for (const videoUrl of variants) {
|
|
115
|
+
const bytes = await probeDouyinVideoBytes({ ...input, videoUrl });
|
|
116
|
+
if (bytes === void 0) continue;
|
|
117
|
+
if (bytes <= input.budgetBytes) return { bytes, fits: true, videoUrl };
|
|
118
|
+
if (!smallest || bytes < smallest.bytes) smallest = { bytes, videoUrl };
|
|
119
|
+
}
|
|
120
|
+
return smallest ? { ...smallest, fits: false } : { fits: true, videoUrl: input.videoUrl };
|
|
121
|
+
}
|
|
67
122
|
async function fetchDouyinVideo(input) {
|
|
68
123
|
const fetcher = input.fetcher ?? fetch;
|
|
69
124
|
const controller = new AbortController();
|
|
@@ -286,12 +341,23 @@ function nonPostPageKind(rawUrl) {
|
|
|
286
341
|
try {
|
|
287
342
|
const parsed = new URL(rawUrl);
|
|
288
343
|
if (/^live\.douyin\.com$/i.test(parsed.hostname) || /(^|\.)webcast\.amemv\.com$/i.test(parsed.hostname)) return "live room";
|
|
344
|
+
if (isDouyinPlacePage(parsed)) return "place";
|
|
345
|
+
if (isDouyinAiNotePage(parsed)) return "Douyin AI note";
|
|
289
346
|
if (!/(^|\.)(?:iesdouyin|douyin)\.com$/i.test(parsed.hostname)) return null;
|
|
290
347
|
return NON_POST_PAGES.find((page) => page.path.test(parsed.pathname))?.kind ?? null;
|
|
291
348
|
} catch {
|
|
292
349
|
return null;
|
|
293
350
|
}
|
|
294
351
|
}
|
|
352
|
+
function isDouyinPlacePage(parsed) {
|
|
353
|
+
const host = parsed.hostname;
|
|
354
|
+
const path = parsed.pathname;
|
|
355
|
+
if (/(^|\.)(?:iesdouyin|douyin)\.com$/i.test(host) && /^\/(?:share\/)?poi\//.test(path)) return true;
|
|
356
|
+
return /(^|\.)snssdk\.com$/i.test(host) && /(?:\/falcon\/)?poi(?:_mwa\/|_detail|\/)/i.test(path);
|
|
357
|
+
}
|
|
358
|
+
function isDouyinAiNotePage(parsed) {
|
|
359
|
+
return /(^|\.)so-landing\.douyin\.com$/i.test(parsed.hostname) && /\/ai_douyin\/ai_note_share\/?$/i.test(parsed.pathname);
|
|
360
|
+
}
|
|
295
361
|
function stripQuery(rawUrl) {
|
|
296
362
|
try {
|
|
297
363
|
const parsed = new URL(rawUrl);
|
|
@@ -486,7 +552,8 @@ async function extractDouyinClip(inputUrl, ctx) {
|
|
|
486
552
|
},
|
|
487
553
|
{ site: "Douyin" }
|
|
488
554
|
);
|
|
489
|
-
const
|
|
555
|
+
const videoUrl = await budgetedVideoUrl(metadata.videoUrl, cookieHeader);
|
|
556
|
+
const video = videoUrl ? await downloadVideo(ctx.workDir, videoUrl, cookieHeader) : null;
|
|
490
557
|
logInfo("douyin.runner", "extract.ok", { primaryVideo: Boolean(video), title: metadata.title });
|
|
491
558
|
return {
|
|
492
559
|
author: metadata.author,
|
|
@@ -561,6 +628,25 @@ async function downloadVideo(workDir, videoUrl, cookieHeader, fileName) {
|
|
|
561
628
|
return null;
|
|
562
629
|
}
|
|
563
630
|
}
|
|
631
|
+
async function budgetedVideoUrl(videoUrl, cookieHeader) {
|
|
632
|
+
const budget = currentVideoByteBudget();
|
|
633
|
+
if (!budget || !videoUrl) return videoUrl;
|
|
634
|
+
const pick = await pickDouyinVideoUrl({ budgetBytes: budget.bytes, cookieHeader, videoUrl });
|
|
635
|
+
if (pick.videoUrl !== videoUrl || !pick.fits) {
|
|
636
|
+
logInfo("douyin.runner", "video.format.budgeted", {
|
|
637
|
+
budgetBytes: budget.bytes,
|
|
638
|
+
bytes: pick.bytes,
|
|
639
|
+
fits: pick.fits,
|
|
640
|
+
measured: budget.measured,
|
|
641
|
+
videoUrl: pick.videoUrl
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
if (!pick.fits && budget.measured) {
|
|
645
|
+
logWarn("douyin.runner", "video.skipped", { reason: "over-upload-budget", url: videoUrl });
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
return pick.videoUrl;
|
|
649
|
+
}
|
|
564
650
|
export {
|
|
565
651
|
extractDouyinClip
|
|
566
652
|
};
|
|
@@ -2,16 +2,16 @@ import { createRequire as __dinoxCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __dinoxCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
ensureDaemonRunning
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-PCB2JD6H.js";
|
|
6
|
+
import "./chunk-G6Y3MOUL.js";
|
|
7
|
+
import "./chunk-WCY3EKJQ.js";
|
|
8
|
+
import "./chunk-JNRA4TTH.js";
|
|
9
|
+
import "./chunk-YFGDTC2F.js";
|
|
10
10
|
import "./chunk-7ODU7LXP.js";
|
|
11
11
|
import "./chunk-WMJXAF3X.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-TOGYWN3D.js";
|
|
13
13
|
import "./chunk-XZLFMJOG.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-LAWV5XGL.js";
|
|
15
15
|
import "./chunk-XQZUX7OT.js";
|
|
16
16
|
export {
|
|
17
17
|
ensureDaemonRunning
|
|
@@ -3,13 +3,13 @@ const require = __dinoxCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
executeCommandLine,
|
|
5
5
|
runCapturedInProcess
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-DKY574LO.js";
|
|
7
|
+
import "./chunk-WCY3EKJQ.js";
|
|
8
|
+
import "./chunk-YFGDTC2F.js";
|
|
9
9
|
import "./chunk-WMJXAF3X.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-TOGYWN3D.js";
|
|
11
11
|
import "./chunk-XZLFMJOG.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-LAWV5XGL.js";
|
|
13
13
|
import "./chunk-XQZUX7OT.js";
|
|
14
14
|
export {
|
|
15
15
|
executeCommandLine,
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
} from "./chunk-QZQRG3JY.js";
|
|
22
22
|
import {
|
|
23
23
|
composeClipMarkdown
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-LLAXR5EG.js";
|
|
25
|
+
import "./chunk-AZ43P73A.js";
|
|
26
26
|
import "./chunk-URYABAYN.js";
|
|
27
27
|
import {
|
|
28
28
|
clipEngineConfig,
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
} from "./chunk-W7R5JTSA.js";
|
|
12
12
|
import {
|
|
13
13
|
composeClipMarkdown
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-LLAXR5EG.js";
|
|
15
|
+
import "./chunk-AZ43P73A.js";
|
|
16
16
|
import "./chunk-URYABAYN.js";
|
|
17
17
|
import {
|
|
18
18
|
clipEngineConfig
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from "./chunk-2M7RJATW.js";
|
|
7
7
|
import {
|
|
8
8
|
composeClipMarkdown
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-LLAXR5EG.js";
|
|
10
|
+
import "./chunk-AZ43P73A.js";
|
|
11
11
|
import "./chunk-URYABAYN.js";
|
|
12
12
|
import "./chunk-AHRCI2RW.js";
|
|
13
13
|
import "./chunk-6VMHHE5Y.js";
|