popost 4.6.8 → 4.6.9
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/SKILL.md +1 -1
- package/dist/cli.js +183 -80
- package/dist/index.js +180 -77
- package/dist/types/providers/link-bundle.d.ts +8 -2
- package/dist/types/providers/link-video.d.ts +27 -0
- package/dist/types/providers/link.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/references/image-workflow.md +1 -1
- package/references/onboarding.md +1 -1
- package/references/post-bundle.md +4 -3
- package/references/video-step-1-read.md +3 -1
package/dist/index.js
CHANGED
|
@@ -260,7 +260,7 @@ var VERSION;
|
|
|
260
260
|
var init_version = __esm({
|
|
261
261
|
"src/version.ts"() {
|
|
262
262
|
"use strict";
|
|
263
|
-
VERSION = "4.6.
|
|
263
|
+
VERSION = "4.6.9";
|
|
264
264
|
}
|
|
265
265
|
});
|
|
266
266
|
|
|
@@ -948,8 +948,8 @@ var init_post_bundle = __esm({
|
|
|
948
948
|
const blocker = await resourceBlocker(rt, res, baseDir);
|
|
949
949
|
if (blocker) blockers.push(blocker);
|
|
950
950
|
}
|
|
951
|
-
const
|
|
952
|
-
for (const item2 of
|
|
951
|
+
const missing3 = Array.isArray(bundle.missing) ? bundle.missing : [];
|
|
952
|
+
for (const item2 of missing3) blockers.push(msg(`the bundle still declares a missing item: ${plain(item2)}`, `bundle \u4ECD\u58F0\u660E\u7F3A\u9879: ${plain(item2)}`));
|
|
953
953
|
return { buildable: blockers.length === 0, blockers };
|
|
954
954
|
};
|
|
955
955
|
}
|
|
@@ -1603,11 +1603,11 @@ var init_args = __esm({
|
|
|
1603
1603
|
);
|
|
1604
1604
|
values.set(keyOf(positional.name), positional.variadic ? raws : raws[0]);
|
|
1605
1605
|
});
|
|
1606
|
-
const
|
|
1606
|
+
const missing3 = [
|
|
1607
1607
|
...declared.filter((p) => p.required !== false && !values.has(keyOf(p.name))).map((p) => p.name),
|
|
1608
1608
|
...(spec8.options ?? []).filter((o) => o.required && !values.has(keyOf(o.flag))).map((o) => o.flag)
|
|
1609
1609
|
];
|
|
1610
|
-
if (
|
|
1610
|
+
if (missing3.length) throw new UsageError(`the following arguments are required: ${missing3.join(", ")}`);
|
|
1611
1611
|
for (const option of spec8.options ?? []) {
|
|
1612
1612
|
const key2 = keyOf(option.flag);
|
|
1613
1613
|
if (!values.has(key2) && option.default !== void 0) values.set(key2, option.default);
|
|
@@ -8322,18 +8322,18 @@ var init_steps = __esm({
|
|
|
8322
8322
|
};
|
|
8323
8323
|
fontsStep = async (ctx) => {
|
|
8324
8324
|
const project = projectOf(ctx);
|
|
8325
|
-
const
|
|
8326
|
-
for (const role of ctx.spec.fonts) if (!await isInstalled(project, role))
|
|
8327
|
-
if (!
|
|
8325
|
+
const missing3 = [];
|
|
8326
|
+
for (const role of ctx.spec.fonts) if (!await isInstalled(project, role)) missing3.push(role);
|
|
8327
|
+
if (!missing3.length)
|
|
8328
8328
|
return skipped(
|
|
8329
8329
|
msg(`font roles already installed: ${ctx.spec.fonts.join(", ")}`, `\u5B57\u4F53\u89D2\u8272\u5DF2\u5B89\u88C5\uFF1A${ctx.spec.fonts.join(", ")}`) + linksNote(project)
|
|
8330
8330
|
);
|
|
8331
|
-
const { result, fontLinks } = await installFonts(ctx.rt, project,
|
|
8331
|
+
const { result, fontLinks } = await installFonts(ctx.rt, project, missing3.join(","), true);
|
|
8332
8332
|
const { installed } = result;
|
|
8333
|
-
const kept2 = ctx.spec.fonts.length -
|
|
8333
|
+
const kept2 = ctx.spec.fonts.length - missing3.length;
|
|
8334
8334
|
const detail2 = msg(
|
|
8335
|
-
`installed ${
|
|
8336
|
-
`\u5DF2\u5B89\u88C5 ${
|
|
8335
|
+
`installed ${missing3.join(", ")}${kept2 ? `; ${kept2} already installed` : ""}`,
|
|
8336
|
+
`\u5DF2\u5B89\u88C5 ${missing3.join(", ")}${kept2 ? `\uFF1B${kept2} \u4E2A\u6B64\u524D\u5DF2\u5B89\u88C5` : ""}`
|
|
8337
8337
|
) + linksNote(project);
|
|
8338
8338
|
return done(detail2, [], cjkFontWarnings(project, installed.map((role) => role.id)), fontLinks);
|
|
8339
8339
|
};
|
|
@@ -10287,9 +10287,9 @@ var init_routes_get = __esm({
|
|
|
10287
10287
|
const html2 = editorHtml(await ctx.load(), source2, ctx.req.rawQuery, ctx.state.cloud.mode());
|
|
10288
10288
|
return noStoreResponse(html2, "text/html; charset=utf-8");
|
|
10289
10289
|
};
|
|
10290
|
-
staticFile = async (ctx, root, urlPath,
|
|
10290
|
+
staticFile = async (ctx, root, urlPath, missing3) => {
|
|
10291
10291
|
const file = await readProjectFile(ctx.rt, root, urlPath);
|
|
10292
|
-
return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx,
|
|
10292
|
+
return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx, missing3);
|
|
10293
10293
|
};
|
|
10294
10294
|
EXACT = {
|
|
10295
10295
|
"/api/export-options": async (ctx) => {
|
|
@@ -12582,8 +12582,8 @@ var init_inspiration_plan = __esm({
|
|
|
12582
12582
|
const b = bundle;
|
|
12583
12583
|
if (b.parseStatus !== "ready" && !options.allowIncomplete) {
|
|
12584
12584
|
const errorsOf = b.errors ?? [];
|
|
12585
|
-
const
|
|
12586
|
-
const detail2 = [...errorsOf, ...
|
|
12585
|
+
const missing3 = (b.missing ?? []).map((m) => msg(`missing ${m}`, `\u7F3A ${m}`));
|
|
12586
|
+
const detail2 = [...errorsOf, ...missing3].join(msg("; ", "\uFF1B")) || msg("no reason given", "\u672A\u8BF4\u660E");
|
|
12587
12587
|
throw new InputError(
|
|
12588
12588
|
msg(
|
|
12589
12589
|
`PostBundle parseStatus=${String(b.parseStatus)}: the content is incomplete (${detail2}). Complete it from local screenshots or text and mark it ready first, or, to save only what is there, add --allow-incomplete`,
|
|
@@ -12727,7 +12727,7 @@ var init_inspiration = __esm({
|
|
|
12727
12727
|
});
|
|
12728
12728
|
|
|
12729
12729
|
// src/providers/link-bundle.ts
|
|
12730
|
-
var text3, badResponse, tagsOf2, imageOf, validPublishedAt, planPost, remoteView, COMMON_RATIOS, gcd2, ratioOf, fileName, sizeOf, reason, downloadPictures, utcNow2, buildBundle;
|
|
12730
|
+
var text3, badResponse, tagsOf2, imageOf, validPublishedAt, planPost, remoteView, COMMON_RATIOS, gcd2, ratioOf, fileName, sizeOf, reason, downloadPictures, utcNow2, pictureResource, videoResource, buildBundle;
|
|
12731
12731
|
var init_link_bundle = __esm({
|
|
12732
12732
|
"src/providers/link-bundle.ts"() {
|
|
12733
12733
|
"use strict";
|
|
@@ -12770,6 +12770,7 @@ var init_link_bundle = __esm({
|
|
|
12770
12770
|
const serverNote = text3(post.note) || (note ?? "").trim();
|
|
12771
12771
|
return {
|
|
12772
12772
|
platform: post.platform,
|
|
12773
|
+
kind: post.kind === "images" || post.kind === "video" ? post.kind : null,
|
|
12773
12774
|
sourceUrl,
|
|
12774
12775
|
title: text3(post.title),
|
|
12775
12776
|
text: text3(post.text),
|
|
@@ -12784,6 +12785,7 @@ var init_link_bundle = __esm({
|
|
|
12784
12785
|
};
|
|
12785
12786
|
remoteView = (plan4) => ({
|
|
12786
12787
|
platform: plan4.platform,
|
|
12788
|
+
...plan4.kind ? { kind: plan4.kind } : {},
|
|
12787
12789
|
title: plan4.title,
|
|
12788
12790
|
text: plan4.text,
|
|
12789
12791
|
tags: plan4.tags,
|
|
@@ -12838,7 +12840,17 @@ var init_link_bundle = __esm({
|
|
|
12838
12840
|
return { saved, failure: null };
|
|
12839
12841
|
};
|
|
12840
12842
|
utcNow2 = (rt) => `${rt.now().toISOString().slice(0, 19)}+00:00`;
|
|
12841
|
-
|
|
12843
|
+
pictureResource = (s) => ({
|
|
12844
|
+
id: `img${s.index}`,
|
|
12845
|
+
kind: "image",
|
|
12846
|
+
path: s.file,
|
|
12847
|
+
mimeType: s.mimeType,
|
|
12848
|
+
sha256: s.sha256,
|
|
12849
|
+
...s.width && s.height ? { width: s.width, height: s.height } : {},
|
|
12850
|
+
...s.alt ? { alt: s.alt } : {}
|
|
12851
|
+
});
|
|
12852
|
+
videoResource = (v) => ({ id: "video", kind: "video", path: v.file, mimeType: v.mimeType, sha256: v.sha256, bytes: v.bytes });
|
|
12853
|
+
buildBundle = (rt, plan4, saved, video) => {
|
|
12842
12854
|
const first = saved[0];
|
|
12843
12855
|
const complete3 = saved.length > 0;
|
|
12844
12856
|
return {
|
|
@@ -12851,15 +12863,7 @@ var init_link_bundle = __esm({
|
|
|
12851
12863
|
music: { title: "", url: "" },
|
|
12852
12864
|
pageOrder: saved.map((s) => s.index),
|
|
12853
12865
|
ratio: first?.width && first.height ? ratioOf(first.width, first.height) : null,
|
|
12854
|
-
resources: saved.map((
|
|
12855
|
-
id: `img${s.index}`,
|
|
12856
|
-
kind: "image",
|
|
12857
|
-
path: s.file,
|
|
12858
|
-
mimeType: s.mimeType,
|
|
12859
|
-
sha256: s.sha256,
|
|
12860
|
-
...s.width && s.height ? { width: s.width, height: s.height } : {},
|
|
12861
|
-
...s.alt ? { alt: s.alt } : {}
|
|
12862
|
-
})),
|
|
12866
|
+
resources: [...saved.map(pictureResource), ...video ? [videoResource(video)] : []],
|
|
12863
12867
|
parseStatus: complete3 ? "ready" : "missing_resources",
|
|
12864
12868
|
auth: {
|
|
12865
12869
|
required: false,
|
|
@@ -12878,6 +12882,71 @@ var init_link_bundle = __esm({
|
|
|
12878
12882
|
}
|
|
12879
12883
|
});
|
|
12880
12884
|
|
|
12885
|
+
// src/providers/link-video.ts
|
|
12886
|
+
var MAX_VIDEO_BYTES, REQUEST_TIMEOUT_SEC, DOWNLOAD_TIMEOUT_SEC, EXTENSIONS2, LEADING_BOXES, ascii4, sniffVideoMime, missing, videoLink, downloadVideo;
|
|
12887
|
+
var init_link_video = __esm({
|
|
12888
|
+
"src/providers/link-video.ts"() {
|
|
12889
|
+
"use strict";
|
|
12890
|
+
init_util();
|
|
12891
|
+
init_i18n();
|
|
12892
|
+
init_api();
|
|
12893
|
+
init_base();
|
|
12894
|
+
init_errors3();
|
|
12895
|
+
MAX_VIDEO_BYTES = 200 * 1024 * 1024;
|
|
12896
|
+
REQUEST_TIMEOUT_SEC = 300;
|
|
12897
|
+
DOWNLOAD_TIMEOUT_SEC = 600;
|
|
12898
|
+
EXTENSIONS2 = { "video/mp4": ".mp4", "video/quicktime": ".mov", "video/webm": ".webm" };
|
|
12899
|
+
LEADING_BOXES = ["moov", "mdat", "free", "wide", "skip"];
|
|
12900
|
+
ascii4 = (bytes, from, to) => String.fromCharCode(...bytes.subarray(from, to));
|
|
12901
|
+
sniffVideoMime = (head, claimed) => {
|
|
12902
|
+
if (head.length >= 4 && head[0] === 26 && head[1] === 69 && head[2] === 223 && head[3] === 163) return "video/webm";
|
|
12903
|
+
if (head.length < 12) return null;
|
|
12904
|
+
const box2 = ascii4(head, 4, 8);
|
|
12905
|
+
if (box2 === "ftyp") return ascii4(head, 8, 12) === "qt " ? "video/quicktime" : "video/mp4";
|
|
12906
|
+
if (LEADING_BOXES.includes(box2)) return claimed === "video/quicktime" ? "video/quicktime" : "video/mp4";
|
|
12907
|
+
return null;
|
|
12908
|
+
};
|
|
12909
|
+
missing = (code, error2) => ({ missing: { code, error: error2 } });
|
|
12910
|
+
videoLink = async (client2, inspirationId) => {
|
|
12911
|
+
let answer3;
|
|
12912
|
+
try {
|
|
12913
|
+
answer3 = await client2.request("GET", `/inspirations/${encodeURIComponent(inspirationId)}/video`, { timeoutSec: REQUEST_TIMEOUT_SEC });
|
|
12914
|
+
} catch (error2) {
|
|
12915
|
+
if (error2 instanceof PopostApiError && error2.code === "VIDEO_GENERATION_DISABLED") return { skipped: true };
|
|
12916
|
+
if (error2 instanceof PopostApiError) return missing(error2.code || "API_ERROR", error2.message);
|
|
12917
|
+
if (error2 instanceof ImageProviderError) return missing("API_ERROR", error2.message);
|
|
12918
|
+
throw error2;
|
|
12919
|
+
}
|
|
12920
|
+
if (!isRecord(answer3) || typeof answer3.url !== "string" || typeof answer3.mimeType !== "string" || !EXTENSIONS2[answer3.mimeType])
|
|
12921
|
+
return missing("BAD_RESPONSE", msg("the answer for the post video has no usable link", "\u5E16\u5B50\u89C6\u9891\u7684\u54CD\u5E94\u91CC\u6CA1\u6709\u53EF\u7528\u7684\u94FE\u63A5"));
|
|
12922
|
+
return { url: answer3.url, mimeType: answer3.mimeType };
|
|
12923
|
+
};
|
|
12924
|
+
downloadVideo = async (rt, client2, inspirationId, outDir2, retry) => {
|
|
12925
|
+
const link = await videoLink(client2, inspirationId);
|
|
12926
|
+
if (!("url" in link)) return link;
|
|
12927
|
+
const what = msg("the post video", "\u5E16\u5B50\u89C6\u9891");
|
|
12928
|
+
const tmp = rt.path.join(outDir2, "video.download");
|
|
12929
|
+
let raw;
|
|
12930
|
+
try {
|
|
12931
|
+
raw = await downloadResult(rt, link.url, tmp, MAX_VIDEO_BYTES, DOWNLOAD_TIMEOUT_SEC, { what, retry });
|
|
12932
|
+
} catch (error2) {
|
|
12933
|
+
await rt.fs.rm(tmp).catch(() => void 0);
|
|
12934
|
+
if (error2 instanceof PopostApiError) return missing(error2.code || "DOWNLOAD_FAILED", error2.message);
|
|
12935
|
+
throw error2;
|
|
12936
|
+
}
|
|
12937
|
+
const mimeType2 = sniffVideoMime(raw.subarray(0, 16), link.mimeType);
|
|
12938
|
+
if (!mimeType2) {
|
|
12939
|
+
await rt.fs.rm(tmp);
|
|
12940
|
+
return missing("BAD_RESPONSE", msg(`the download of ${what} is not an MP4/MOV/WebM video; ${retry}`, `${what}\u4E0B\u8F7D\u7684\u5185\u5BB9\u4E0D\u662F MP4/MOV/WebM \u89C6\u9891\uFF1B${retry}`));
|
|
12941
|
+
}
|
|
12942
|
+
const file = `video${EXTENSIONS2[mimeType2]}`;
|
|
12943
|
+
const path2 = rt.path.join(outDir2, file);
|
|
12944
|
+
await rt.fs.rename(tmp, path2);
|
|
12945
|
+
return { saved: { file, path: path2, mimeType: mimeType2, sha256: sha256(raw), bytes: raw.length } };
|
|
12946
|
+
};
|
|
12947
|
+
}
|
|
12948
|
+
});
|
|
12949
|
+
|
|
12881
12950
|
// src/providers/link-task.ts
|
|
12882
12951
|
var POLL_INTERVAL_MS, MAX_POLL_FAILURES, RATE_LIMIT_WAIT_MS, RATE_LIMIT_WAIT_MAX_MS, TASK_ID2, STATUSES, taskOf2, isTerminal, TRANSIENT_CODES2, isTransient2, rateLimitWaitMs, fetchTask, waitForTask2;
|
|
12883
12952
|
var init_link_task = __esm({
|
|
@@ -12953,7 +13022,7 @@ var init_link_task = __esm({
|
|
|
12953
13022
|
});
|
|
12954
13023
|
|
|
12955
13024
|
// src/providers/link.ts
|
|
12956
|
-
var NOTE_MAX, TIMEOUT_MAX_SEC, LOCAL_CODES, shellArg, resumeCommand, briefOf, badArgs, checkOptions, parseBody, outDirOf, makeClient, dryRunOf, createTask, codeText, failedOutcome, unfinishedOutcome, succeededOutcome, finish2, failureOf5, report, parseLink, linkStatus;
|
|
13025
|
+
var NOTE_MAX, TIMEOUT_MAX_SEC, LOCAL_CODES, shellArg, resumeCommand, briefOf, badArgs, checkOptions, parseBody, outDirOf, makeClient, dryRunOf, createTask, codeText, failedOutcome, unfinishedOutcome, videoPart, succeededOutcome, finish2, failureOf5, report, parseLink, linkStatus;
|
|
12957
13026
|
var init_link = __esm({
|
|
12958
13027
|
"src/providers/link.ts"() {
|
|
12959
13028
|
"use strict";
|
|
@@ -12965,6 +13034,7 @@ var init_link = __esm({
|
|
|
12965
13034
|
init_cli_config();
|
|
12966
13035
|
init_errors3();
|
|
12967
13036
|
init_link_bundle();
|
|
13037
|
+
init_link_video();
|
|
12968
13038
|
init_link_task();
|
|
12969
13039
|
init_paths();
|
|
12970
13040
|
init_secrets();
|
|
@@ -13045,7 +13115,30 @@ var init_link = __esm({
|
|
|
13045
13115
|
);
|
|
13046
13116
|
return { exit: 1, body: { ok: false, code, error: error2, task: { id: id2, status: task?.status ?? null, chargedCredits: task?.chargedCredits ?? null }, resume } };
|
|
13047
13117
|
};
|
|
13048
|
-
|
|
13118
|
+
videoPart = async (rt, client2, plan4, call2, outDir2, retry) => {
|
|
13119
|
+
if (plan4.kind !== "video" || call2.noVideo || !plan4.inspirationId) return { fields: {}, note: "" };
|
|
13120
|
+
const outcome = await downloadVideo(rt, client2, plan4.inspirationId, outDir2, retry);
|
|
13121
|
+
if ("skipped" in outcome) return { fields: {}, note: "" };
|
|
13122
|
+
if ("saved" in outcome) {
|
|
13123
|
+
const path2 = shellArg(outcome.saved.path);
|
|
13124
|
+
return {
|
|
13125
|
+
saved: outcome.saved,
|
|
13126
|
+
fields: { video: outcome.saved.path },
|
|
13127
|
+
note: msg(
|
|
13128
|
+
`; the post's original video is ${path2}: use it as the reference video (for example popost video replication init <project> --reference ${path2})`,
|
|
13129
|
+
`\uFF1B\u5E16\u5B50\u539F\u89C6\u9891\u5728 ${path2}\uFF1A\u7528\u5B83\u4F5C\u53C2\u8003\u89C6\u9891\uFF08\u4F8B\u5982 popost video replication init <\u9879\u76EE> --reference ${path2}\uFF09`
|
|
13130
|
+
)
|
|
13131
|
+
};
|
|
13132
|
+
}
|
|
13133
|
+
return {
|
|
13134
|
+
fields: { videoMissing: outcome.missing },
|
|
13135
|
+
note: msg(
|
|
13136
|
+
`; the original video could not be fetched (${outcome.missing.code}): the bundle has the cover and text only; for shot, subtitle or sound analysis ask the user for the video file or a screen recording`,
|
|
13137
|
+
`\uFF1B\u6CA1\u80FD\u53D6\u5230\u5E16\u5B50\u539F\u89C6\u9891\uFF08${outcome.missing.code}\uFF09\uFF1Abundle \u53EA\u6709\u5C01\u9762\u548C\u6587\u5B57\uFF1B\u8981\u505A\u5206\u955C\u3001\u5B57\u5E55\u6216\u58F0\u97F3\u5206\u6790\uFF0C\u8BF7\u7528\u6237\u63D0\u4F9B\u89C6\u9891\u6587\u4EF6\u6216\u5F55\u5C4F`
|
|
13138
|
+
)
|
|
13139
|
+
};
|
|
13140
|
+
};
|
|
13141
|
+
succeededOutcome = async (rt, client2, task, call2, fallback) => {
|
|
13049
13142
|
if (!task.post) throw badResponse(msg("the task succeeded but the answer has no post", "\u4EFB\u52A1\u5DF2\u6210\u529F\uFF0C\u4F46\u54CD\u5E94\u91CC\u6CA1\u6709 post"));
|
|
13050
13143
|
const plan4 = planPost(task.post, fallback.url, fallback.note);
|
|
13051
13144
|
const info = { id: task.id, status: task.status, created: task.created, chargedCredits: task.chargedCredits };
|
|
@@ -13072,7 +13165,8 @@ var init_link = __esm({
|
|
|
13072
13165
|
const { saved, failure: failure4 } = await downloadPictures(rt, plan4.images, outDir2, retry);
|
|
13073
13166
|
const images = saved.map((s) => s.path);
|
|
13074
13167
|
if (failure4) return { exit: 1, body: { ok: false, code: "DOWNLOAD_FAILED", error: failure4, task: { id: task.id, status: task.status, chargedCredits: task.chargedCredits }, images, resume: resumeCommand(task.id, call2) } };
|
|
13075
|
-
const
|
|
13168
|
+
const video = await videoPart(rt, client2, plan4, call2, outDir2, retry);
|
|
13169
|
+
const bundle = buildBundle(rt, plan4, saved, video.saved);
|
|
13076
13170
|
const [valid, errors] = validateBundle(bundle);
|
|
13077
13171
|
if (!valid) throw badResponse(msg(`the parsed result does not make a valid PostBundle: ${errors.join("; ")}`, `\u89E3\u6790\u7ED3\u679C\u65E0\u6CD5\u7EC4\u6210\u5408\u6CD5\u7684 PostBundle\uFF1A${errors.join("\uFF1B")}`));
|
|
13078
13172
|
const bundlePath = rt.path.join(outDir2, "postbundle.json");
|
|
@@ -13082,8 +13176,8 @@ var init_link = __esm({
|
|
|
13082
13176
|
"the post has no pictures: the bundle is marked missing_resources and cannot be built directly; the platform saved this post to My Inspirations",
|
|
13083
13177
|
"\u5E16\u5B50\u91CC\u6CA1\u6709\u56FE\u7247\uFF1Abundle \u6807\u4E3A missing_resources\uFF0C\u4E0D\u80FD\u76F4\u63A5 build\uFF1B\u5E73\u53F0\u5DF2\u628A\u8FD9\u6761\u5E16\u5B50\u5B58\u5165\u300C\u6211\u7684\u7075\u611F\u300D"
|
|
13084
13178
|
);
|
|
13085
|
-
const post = { platform: plan4.platform, title: plan4.title, sourceUrl: plan4.sourceUrl, imageCount: saved.length, ...plan4.inspirationId ? { inspirationId: plan4.inspirationId } : {} };
|
|
13086
|
-
return { exit: 0, body: { ok: true, task: info, bundle: bundlePath, images, post, next: `popost validate --file ${file} && popost import --file ${file}`, note } };
|
|
13179
|
+
const post = { platform: plan4.platform, ...plan4.kind ? { kind: plan4.kind } : {}, title: plan4.title, sourceUrl: plan4.sourceUrl, imageCount: saved.length, ...plan4.inspirationId ? { inspirationId: plan4.inspirationId } : {} };
|
|
13180
|
+
return { exit: 0, body: { ok: true, task: info, bundle: bundlePath, images, ...video.fields, post, next: `popost validate --file ${file} && popost import --file ${file}`, note: note + video.note } };
|
|
13087
13181
|
};
|
|
13088
13182
|
finish2 = async (rt, client2, state, first, call2, fallback) => {
|
|
13089
13183
|
const id2 = state.id;
|
|
@@ -13098,7 +13192,7 @@ var init_link = __esm({
|
|
|
13098
13192
|
);
|
|
13099
13193
|
return unfinishedOutcome("POLL_FAILED", what, id2, waited.task, call2);
|
|
13100
13194
|
}
|
|
13101
|
-
return waited.task.status === "failed" ? failedOutcome(waited.task) : succeededOutcome(rt, waited.task, call2, fallback);
|
|
13195
|
+
return waited.task.status === "failed" ? failedOutcome(waited.task) : succeededOutcome(rt, client2, waited.task, call2, fallback);
|
|
13102
13196
|
};
|
|
13103
13197
|
failureOf5 = (error2) => {
|
|
13104
13198
|
if (error2 instanceof CliReject) return { code: "CONFIG", exit: error2.code, message: error2.message };
|
|
@@ -13617,7 +13711,7 @@ var link_exports = {};
|
|
|
13617
13711
|
__export(link_exports, {
|
|
13618
13712
|
main: () => main16
|
|
13619
13713
|
});
|
|
13620
|
-
var out, timeout, noDownload, config2, main16;
|
|
13714
|
+
var out, timeout, noDownload, noVideo, config2, main16;
|
|
13621
13715
|
var init_link2 = __esm({
|
|
13622
13716
|
"src/commands/link.ts"() {
|
|
13623
13717
|
"use strict";
|
|
@@ -13651,6 +13745,14 @@ var init_link2 = __esm({
|
|
|
13651
13745
|
"\u4E0D\u4E0B\u8F7D\u56FE\u7247\uFF0C\u53EA\u6253\u5370\u5E16\u5B50\u5185\u5BB9\u548C\u56FE\u7247\u5730\u5740\uFF08\u5730\u5740\u662F\u77ED\u671F\u7B7E\u540D\u94FE\u63A5\uFF0C\u5F88\u5FEB\u5931\u6548\uFF09"
|
|
13652
13746
|
)
|
|
13653
13747
|
});
|
|
13748
|
+
noVideo = () => ({
|
|
13749
|
+
flag: "--no-video",
|
|
13750
|
+
kind: "flag",
|
|
13751
|
+
help: msg(
|
|
13752
|
+
"for a video post, keep the cover and text only: do not fetch the original video file",
|
|
13753
|
+
"\u89C6\u9891\u5E16\u53EA\u4FDD\u7559\u5C01\u9762\u548C\u6587\u5B57\uFF0C\u4E0D\u53D6\u539F\u89C6\u9891\u6587\u4EF6"
|
|
13754
|
+
)
|
|
13755
|
+
});
|
|
13654
13756
|
config2 = () => ({ flag: "--config", help: msg("private config JSON (popost.baseUrl / popost.auth.envVar)", "\u79C1\u6709\u914D\u7F6E JSON\uFF08popost.baseUrl / popost.auth.envVar\uFF09") });
|
|
13655
13757
|
main16 = (argv, rt) => runSubcommand2(
|
|
13656
13758
|
"popost link",
|
|
@@ -13665,8 +13767,8 @@ var init_link2 = __esm({
|
|
|
13665
13767
|
parse: {
|
|
13666
13768
|
spec: {
|
|
13667
13769
|
description: msg(
|
|
13668
|
-
`Have popost.ai parse a social post link (${platformNameList("or")}
|
|
13669
|
-
`\u8BA9 popost.ai \u89E3\u6790\u4E00\u6761\u793E\u5A92\u5E16\u5B50\u94FE\u63A5\uFF08${platformNameList("or")}\
|
|
13770
|
+
`Have popost.ai parse a social post link (${platformNameList("or")}), wait for the result, download the pictures and write a PostBundle (postbundle.v1). A video post also gets its original video file (video.mp4, free) for shot, subtitle and sound analysis; YouTube, Bilibili and WeChat Channels give the cover and post details only. Get the live price with link quote first, then submit with --confirm --max-credits N, the ceiling the user authorized; the actual net charge is task.chargedCredits; a link already saved is reused without a new charge. The parsed post is also saved to My Inspirations.`,
|
|
13771
|
+
`\u8BA9 popost.ai \u89E3\u6790\u4E00\u6761\u793E\u5A92\u5E16\u5B50\u94FE\u63A5\uFF08${platformNameList("or")}\uFF09\uFF0C\u7B49\u5F85\u7ED3\u679C\uFF0C\u628A\u56FE\u7247\u4E0B\u8F7D\u5230\u672C\u5730\u5E76\u5199\u51FA PostBundle\uFF08postbundle.v1\uFF09\u3002\u89C6\u9891\u5E16\u8FD8\u4F1A\u53D6\u56DE\u539F\u89C6\u9891\u6587\u4EF6\uFF08video.mp4\uFF0C\u4E0D\u53E6\u6263\u79EF\u5206\uFF09\uFF0C\u7528\u4E8E\u5206\u955C\u3001\u5B57\u5E55\u548C\u58F0\u97F3\u5206\u6790\uFF1BYouTube\u3001\u54D4\u54E9\u54D4\u54E9\u548C\u5FAE\u4FE1\u89C6\u9891\u53F7\u53EA\u6709\u5C01\u9762\u548C\u5E16\u5B50\u4FE1\u606F\u3002\u5148 link quote \u67E5\u8BE2\u52A8\u6001\u4EF7\u683C\uFF0C\u518D\u5E26 --confirm --max-credits N \u6309\u5DF2\u6388\u6743\u4E0A\u9650\u63D0\u4EA4\uFF1B\u5B9E\u9645\u51C0\u6263\u89C1 task.chargedCredits\uFF1B\u5DF2\u4FDD\u5B58\u8FC7\u7684\u94FE\u63A5\u76F4\u63A5\u590D\u7528\u3001\u4E0D\u518D\u6263\u3002\u89E3\u6790\u7ED3\u679C\u540C\u65F6\u5B58\u5165\u300C\u6211\u7684\u7075\u611F\u300D\u3002`
|
|
13670
13772
|
),
|
|
13671
13773
|
positionals: [{ name: "url", help: msg("the post link (http/https)", "\u5E16\u5B50\u94FE\u63A5\uFF08http/https\uFF09") }],
|
|
13672
13774
|
options: [
|
|
@@ -13676,12 +13778,13 @@ var init_link2 = __esm({
|
|
|
13676
13778
|
out(),
|
|
13677
13779
|
timeout(),
|
|
13678
13780
|
noDownload(),
|
|
13781
|
+
noVideo(),
|
|
13679
13782
|
{ flag: "--dry-run", kind: "flag", help: msg("offline, no key, no charge: only show the requests that would be sent", "\u4E0D\u8054\u7F51\u3001\u4E0D\u9700\u8981\u5BC6\u94A5\u3001\u4E0D\u6263\u79EF\u5206\uFF0C\u53EA\u5C55\u793A\u5C06\u53D1\u51FA\u7684\u8BF7\u6C42") },
|
|
13680
13783
|
config2()
|
|
13681
13784
|
]
|
|
13682
13785
|
},
|
|
13683
13786
|
// Into a project (--out inside one): the parse is charged under the project's task (providers/task.ts).
|
|
13684
|
-
run: async (a) => parseLink(await aroundPath(rt, a.string("out")), { url: a.req("url"), note: a.string("note"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), dryRun: a.flag("dry-run"), confirm: a.flag("confirm"), maxCredits: a.number("max-credits"), config: a.string("config") })
|
|
13787
|
+
run: async (a) => parseLink(await aroundPath(rt, a.string("out")), { url: a.req("url"), note: a.string("note"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), noVideo: a.flag("no-video"), dryRun: a.flag("dry-run"), confirm: a.flag("confirm"), maxCredits: a.number("max-credits"), config: a.string("config") })
|
|
13685
13788
|
},
|
|
13686
13789
|
status: {
|
|
13687
13790
|
spec: {
|
|
@@ -13690,9 +13793,9 @@ var init_link2 = __esm({
|
|
|
13690
13793
|
"\u7EE7\u7EED\u7B49\u5F85\u4E00\u4E2A\u5DF2\u5B58\u5728\u7684\u89E3\u6790\u4EFB\u52A1\u5E76\u4E0B\u8F7D\u7ED3\u679C\uFF08\u7528\u4E8E link parse \u8D85\u65F6\u6216\u88AB\u6253\u65AD\u4E4B\u540E\uFF09\u3002\u4E0D\u65B0\u5EFA\u4EFB\u52A1\u3001\u4E0D\u6263\u79EF\u5206\u3002"
|
|
13691
13794
|
),
|
|
13692
13795
|
positionals: [{ name: "task-id", help: msg("the task.id printed by link parse", "link parse \u8F93\u51FA\u7684 task.id") }],
|
|
13693
|
-
options: [out(), timeout(), noDownload(), config2()]
|
|
13796
|
+
options: [out(), timeout(), noDownload(), noVideo(), config2()]
|
|
13694
13797
|
},
|
|
13695
|
-
run: (a) => linkStatus(rt, { taskId: a.req("task-id"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), config: a.string("config") })
|
|
13798
|
+
run: (a) => linkStatus(rt, { taskId: a.req("task-id"), out: a.string("out"), timeoutSec: a.number("timeout"), noDownload: a.flag("no-download"), noVideo: a.flag("no-video"), config: a.string("config") })
|
|
13696
13799
|
}
|
|
13697
13800
|
},
|
|
13698
13801
|
argv,
|
|
@@ -16249,10 +16352,10 @@ var init_footage2 = __esm({
|
|
|
16249
16352
|
const { fs, path: path2 } = rt;
|
|
16250
16353
|
await fs.mkdir(job.dir);
|
|
16251
16354
|
const have = new Set(await fs.readdir(job.dir));
|
|
16252
|
-
const
|
|
16253
|
-
if (
|
|
16254
|
-
const lo =
|
|
16255
|
-
const hi =
|
|
16355
|
+
const missing3 = job.frames.filter((f) => !have.has(frameName(f)));
|
|
16356
|
+
if (missing3.length === 0) return { extracted: 0, reused: job.frames.length };
|
|
16357
|
+
const lo = missing3[0] ?? 0;
|
|
16358
|
+
const hi = missing3[missing3.length - 1] ?? 0;
|
|
16256
16359
|
const tmp = path2.join(job.dir, ".extract-" + rt.randomUUID());
|
|
16257
16360
|
await fs.mkdir(tmp);
|
|
16258
16361
|
try {
|
|
@@ -16279,11 +16382,11 @@ var init_footage2 = __esm({
|
|
|
16279
16382
|
path2.join(tmp, "%0" + FRAME_DIGITS + "d.png")
|
|
16280
16383
|
]);
|
|
16281
16384
|
const written2 = new Set(await fs.readdir(tmp));
|
|
16282
|
-
const absent =
|
|
16385
|
+
const absent = missing3.filter((f) => !written2.has(frameName(f - lo)));
|
|
16283
16386
|
if (absent.length > 0)
|
|
16284
16387
|
throw new Error("Extracting frames " + lo + ".." + hi + " of " + job.file + " gave " + written2.size + " pictures; frame " + absent[0] + " is missing. The file may be damaged or shorter than its header says; re-encode it with ffmpeg.");
|
|
16285
|
-
for (const f of
|
|
16286
|
-
return { extracted:
|
|
16388
|
+
for (const f of missing3) await fs.rename(path2.join(tmp, frameName(f - lo)), path2.join(job.dir, frameName(f)));
|
|
16389
|
+
return { extracted: missing3.length, reused: job.frames.length - missing3.length };
|
|
16287
16390
|
} finally {
|
|
16288
16391
|
await fs.rm(tmp);
|
|
16289
16392
|
}
|
|
@@ -20362,14 +20465,14 @@ var init_check3 = __esm({
|
|
|
20362
20465
|
measuredLabel = (b) => [b.kind, b.mode, b.direction, b.via ? "via " + b.via : ""].filter(Boolean).join(" ");
|
|
20363
20466
|
coverageProblems = ({ r, m, at: at7 }) => {
|
|
20364
20467
|
const fps = m.source.fps, s22 = (f) => (f / fps).toFixed(2);
|
|
20365
|
-
const
|
|
20468
|
+
const missing3 = m.shots.filter((s) => !r.present.includes(s.index + 1)).map((s) => error("shots", "Shot " + (s.index + 1) + " (" + s22(s.start) + "-" + s22(s.end) + " s) has no entry.", "Open " + shotSheetFile(s.index + 1) + ' and add {"shot": ' + (s.index + 1) + ', "time": [' + s22(s.start) + ", " + s22(s.end) + '], "layout": "...", "layers": [...]} for it.'));
|
|
20366
20469
|
const extra2 = r.present.filter((n) => n > m.shots.length).map((n) => error(at7(n) + ".shot", "There is no shot " + n + ": the measurement has " + m.shots.length + ".", "Remove the entry, or give it the number of the shot it describes."));
|
|
20367
20470
|
const times = r.elements.shots.flatMap((s) => {
|
|
20368
20471
|
const ms = m.shots[s.shot - 1];
|
|
20369
20472
|
if (!ms || Math.abs(s.time[0] - ms.start / fps) <= TIME_SLACK && Math.abs(s.time[1] - ms.end / fps) <= TIME_SLACK) return [];
|
|
20370
20473
|
return [warning(at7(s.shot) + ".time", "Shot " + s.shot + " is " + s22(ms.start) + "-" + s22(ms.end) + " s in the measurement; its entry says " + s.time[0] + "-" + s.time[1] + " s.", "Copy the measured time, [" + s22(ms.start) + ", " + s22(ms.end) + ']: entries go by the measured shots. Where the frames show a change the measurement missed, say so in "rebuild".')];
|
|
20371
20474
|
});
|
|
20372
|
-
return [...
|
|
20475
|
+
return [...missing3, ...extra2, ...times];
|
|
20373
20476
|
};
|
|
20374
20477
|
transitionProblems2 = ({ r, m, at: at7 }) => r.elements.shots.flatMap((s) => {
|
|
20375
20478
|
const here = at7(s.shot) + ".transitionIn", t = s.transitionIn;
|
|
@@ -29988,7 +30091,7 @@ var init_generate = __esm({
|
|
|
29988
30091
|
});
|
|
29989
30092
|
|
|
29990
30093
|
// src/video/generate/cloud.ts
|
|
29991
|
-
var GenerateError, MINUTE_MS, POLL_MS2, DEFAULT_WAIT_MIN, DEFAULT_SECONDS, CREATE_TRIES, CREATE_TIMEOUT_SEC, UPLOAD_TIMEOUT_MS,
|
|
30094
|
+
var GenerateError, MINUTE_MS, POLL_MS2, DEFAULT_WAIT_MIN, DEFAULT_SECONDS, CREATE_TRIES, CREATE_TIMEOUT_SEC, UPLOAD_TIMEOUT_MS, DOWNLOAD_TIMEOUT_SEC2, MAX_CLIP_BYTES, RETRY_HINT, setting, numberSetting, keysOf, cloudSettings, agreeToPrice, requestKey, LISTS2, has, mediaType, readReference3, readReferences, recordFile, readRecord2, save2, keyOf4, stillValid, text6, putBytes, upload2, ensureUploads2, specOf, ensureQuote, taskOf3, createTask2, submit, getTask, findTask, ENDED, PASSING2, waitFor, NEXT_AFTER, ended, fetchClip, gateOf, modelFacts, wavSeconds, checkReferenceSounds, makeClip, listModels;
|
|
29992
30095
|
var init_cloud2 = __esm({
|
|
29993
30096
|
"src/video/generate/cloud.ts"() {
|
|
29994
30097
|
"use strict";
|
|
@@ -30019,7 +30122,7 @@ var init_cloud2 = __esm({
|
|
|
30019
30122
|
CREATE_TRIES = 3;
|
|
30020
30123
|
CREATE_TIMEOUT_SEC = 120;
|
|
30021
30124
|
UPLOAD_TIMEOUT_MS = 10 * MINUTE_MS;
|
|
30022
|
-
|
|
30125
|
+
DOWNLOAD_TIMEOUT_SEC2 = 900;
|
|
30023
30126
|
MAX_CLIP_BYTES = 1024 * 1024 * 1024;
|
|
30024
30127
|
RETRY_HINT = "Run the same command again: it sends the same idempotency key, so it is never paid twice.";
|
|
30025
30128
|
setting = (rt, name) => rt.env[name]?.trim() || void 0;
|
|
@@ -30250,7 +30353,7 @@ var init_cloud2 = __esm({
|
|
|
30250
30353
|
const url = task.video?.url;
|
|
30251
30354
|
if (typeof url !== "string") throw new GenerateError("popost.ai says the clip of task " + task.id + " is made but gives no link to it. Run the command again later.");
|
|
30252
30355
|
try {
|
|
30253
|
-
const data = await downloadResult(rt, url, out2, MAX_CLIP_BYTES,
|
|
30356
|
+
const data = await downloadResult(rt, url, out2, MAX_CLIP_BYTES, DOWNLOAD_TIMEOUT_SEC2, labels);
|
|
30254
30357
|
const bytes = task.video?.bytes;
|
|
30255
30358
|
if (typeof bytes === "number" && data.length !== bytes) {
|
|
30256
30359
|
await rt.fs.rm(out2);
|
|
@@ -32287,9 +32390,9 @@ var init_readback_kept = __esm({
|
|
|
32287
32390
|
const who = readerOf(rt);
|
|
32288
32391
|
const [hashes2, kept2] = await Promise.all([Promise.all(frames.map(async (f) => sha256(await rt.fs.readFile(f.file)))), keptLines(rt, file, who)]);
|
|
32289
32392
|
const old = hashes2.map((h) => Array.isArray(kept2[h]) ? kept2[h] : void 0);
|
|
32290
|
-
const
|
|
32291
|
-
onKept?.(frames.length -
|
|
32292
|
-
const read2 = new Map((
|
|
32393
|
+
const missing3 = frames.filter((_f, i) => old[i] === void 0);
|
|
32394
|
+
onKept?.(frames.length - missing3.length, frames.length);
|
|
32395
|
+
const read2 = new Map((missing3.length ? await reader.read(missing3) : []).map((s) => [s.frame, s.lines]));
|
|
32293
32396
|
const found = frames.flatMap((f, i) => {
|
|
32294
32397
|
const lines = old[i] ?? read2.get(f.frame);
|
|
32295
32398
|
return lines ? [{ hash: hashes2[i], sample: { frame: f.frame, lines } }] : [];
|
|
@@ -33513,7 +33616,7 @@ var init_check5 = __esm({
|
|
|
33513
33616
|
fileProblems = async (rt, pkg, fill4, dir, lengths) => {
|
|
33514
33617
|
const exists3 = async (p) => await rt.fs.stat(p) !== null;
|
|
33515
33618
|
const out2 = [];
|
|
33516
|
-
const
|
|
33619
|
+
const missing3 = (at7, file) => error(at7, quote13(file) + " does not exist in " + dir + ".", "Put the file there, or correct the path (it is relative to the project directory).");
|
|
33517
33620
|
for (const [k, raw] of fill4.shots.entries()) {
|
|
33518
33621
|
const s = raw;
|
|
33519
33622
|
if (k >= pkg.template.shots.length || kindsOf2(s).length !== 1) continue;
|
|
@@ -33522,7 +33625,7 @@ var init_check5 = __esm({
|
|
|
33522
33625
|
if (typeof file !== "string" || !file.trim() || isOutside(file)) continue;
|
|
33523
33626
|
const full = rt.path.resolve(dir, file);
|
|
33524
33627
|
if (!await exists3(full)) {
|
|
33525
|
-
out2.push(
|
|
33628
|
+
out2.push(missing3("shots[" + k + "]." + key2, file));
|
|
33526
33629
|
continue;
|
|
33527
33630
|
}
|
|
33528
33631
|
if (key2 === "picture" && !PICTURES3.includes(rt.path.extname(file).toLowerCase())) out2.push(error("shots[" + k + "].picture", quote13(file) + " is not a picture file (" + PICTURES3.join(", ") + ").", "Convert it to WebP or PNG."));
|
|
@@ -33532,8 +33635,8 @@ var init_check5 = __esm({
|
|
|
33532
33635
|
}
|
|
33533
33636
|
out2.push(...await itemFileProblems(rt, pkg, s, k, dir, lengths));
|
|
33534
33637
|
}
|
|
33535
|
-
if (typeof fill4.sound === "string" && !await exists3(rt.path.resolve(dir, fill4.sound))) out2.push(
|
|
33536
|
-
for (const [i, bed] of (Array.isArray(fill4.beds) ? fill4.beds : []).entries()) if (typeof bed?.footage === "string" && !isOutside(bed.footage) && !await exists3(rt.path.resolve(dir, bed.footage))) out2.push(
|
|
33638
|
+
if (typeof fill4.sound === "string" && !await exists3(rt.path.resolve(dir, fill4.sound))) out2.push(missing3("sound", fill4.sound));
|
|
33639
|
+
for (const [i, bed] of (Array.isArray(fill4.beds) ? fill4.beds : []).entries()) if (typeof bed?.footage === "string" && !isOutside(bed.footage) && !await exists3(rt.path.resolve(dir, bed.footage))) out2.push(missing3("beds[" + i + "].footage", bed.footage));
|
|
33537
33640
|
out2.push(...await stillProblems(rt, pkg, fill4, dir, lengths));
|
|
33538
33641
|
for (const p of await slotPictures(rt, fill4, dir)) out2.push(...await slotPictureProblems(rt, p, dir));
|
|
33539
33642
|
return out2;
|
|
@@ -40708,11 +40811,11 @@ var init_findings2 = __esm({
|
|
|
40708
40811
|
};
|
|
40709
40812
|
unseenProblem = (shot, mine, longer, theirs, picture3) => {
|
|
40710
40813
|
const shown3 = theirs.filter((t) => t.visible).map((t) => t.index);
|
|
40711
|
-
const
|
|
40712
|
-
if (!
|
|
40814
|
+
const missing3 = outermost(mine.filter((t) => !t.visible && shown3.includes(t.index))).slice(0, 3);
|
|
40815
|
+
if (!missing3.length) return void 0;
|
|
40713
40816
|
return warning(
|
|
40714
40817
|
at4(shot.k),
|
|
40715
|
-
"In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted3(
|
|
40818
|
+
"In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted3(missing3.map((t) => t.text)) + (missing3.length > 1 ? " are" : " is") + " never visible (" + picture3 + '), though segment "' + longer.id + '" (' + s2(longer.seconds) + ") shows " + (missing3.length > 1 ? "them" : "it") + " with the same scene file: the entrance starts after this shorter shot has ended.",
|
|
40716
40819
|
'Time the entrances for the shortest shot that shows "' + shot.src + '": every text visible by ' + s2(readBy(shot.seconds)) + ", then held. Or give this segment a scene file of its own."
|
|
40717
40820
|
);
|
|
40718
40821
|
};
|
|
@@ -42416,9 +42519,9 @@ var init_speech_check = __esm({
|
|
|
42416
42519
|
const a = comparedWords(script), b = comparedWords(heard);
|
|
42417
42520
|
const pairs = commonPairs(a, b);
|
|
42418
42521
|
const saidA = new Set(pairs.map(([i]) => i)), saidB = new Set(pairs.map(([, j]) => j));
|
|
42419
|
-
const
|
|
42522
|
+
const missing3 = a.filter((_w, i) => !saidA.has(i)), extra2 = b.filter((_w, j) => !saidB.has(j));
|
|
42420
42523
|
const n = a.length, matched = pairs.length;
|
|
42421
|
-
return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing:
|
|
42524
|
+
return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing: missing3.slice(0, 12), extra: extra2.slice(0, 12) };
|
|
42422
42525
|
};
|
|
42423
42526
|
lineTimes = (lines, words) => {
|
|
42424
42527
|
const perLine = lines.map((l) => comparedWords(l));
|
|
@@ -44127,8 +44230,8 @@ var init_hosted3 = __esm({
|
|
|
44127
44230
|
lengthOf = async (rt, o, known2) => {
|
|
44128
44231
|
const had = known2 ?? await audioSeconds(rt, o.out).catch(() => void 0);
|
|
44129
44232
|
if (had === void 0) return { seconds: null };
|
|
44130
|
-
const seconds7 = round22(had),
|
|
44131
|
-
return { seconds: seconds7, ...
|
|
44233
|
+
const seconds7 = round22(had), missing3 = round22((o.fit ?? o.seconds) - had);
|
|
44234
|
+
return { seconds: seconds7, ...missing3 > SHORT_TOLERANCE ? { short: { seconds: seconds7, missing: missing3 } } : {} };
|
|
44132
44235
|
};
|
|
44133
44236
|
written = async (rt, o, receipt, job) => {
|
|
44134
44237
|
if (job.state !== "ready" || !job.audioUrl) throw new ToolError("The popost.ai music is " + (job.state || "not ready") + "; run the same command again.");
|
|
@@ -44213,7 +44316,7 @@ var init_media = __esm({
|
|
|
44213
44316
|
const account = connected(rt);
|
|
44214
44317
|
const tools2 = { ...named, transcribe: named.transcribe ?? (account ? HOSTED : null), speak: named.speak ?? (account ? HOSTED : null), music: musicEnabled(rt) ? HOSTED : null };
|
|
44215
44318
|
const offers = account ? { hosted: HOSTED_NOTE } : { connect: CONNECT };
|
|
44216
|
-
const
|
|
44319
|
+
const missing3 = [
|
|
44217
44320
|
...rt.programs ? [] : ["this host cannot run local programs, so no video command works here"],
|
|
44218
44321
|
...rt.programs && version === null ? ['ffmpeg was not found: install it or set POPOST_FFMPEG (asked for "' + ffmpegPath(rt) + '")'] : [],
|
|
44219
44322
|
...browser === true ? [] : [browser]
|
|
@@ -44221,8 +44324,8 @@ var init_media = __esm({
|
|
|
44221
44324
|
const budget = rt.programs ? cpuBudgetOf(rt) : void 0;
|
|
44222
44325
|
const cpus = budget ? { budget: budget.cpus, from: budget.source } : null;
|
|
44223
44326
|
const reading = named.readText !== null || named.transcribe !== null;
|
|
44224
|
-
printJson(rt, { ok:
|
|
44225
|
-
return
|
|
44327
|
+
printJson(rt, { ok: missing3.length === 0, ffmpeg: version, browser: browser === true, cpus, tools: tools2, ...offers, ...reading ? { note: FIRST_RUN } : {}, ...missing3.length ? { missing: missing3 } : {} });
|
|
44328
|
+
return missing3.length ? 2 : 0;
|
|
44226
44329
|
}
|
|
44227
44330
|
);
|
|
44228
44331
|
soundOnly = async (rt, file, e) => {
|
|
@@ -44571,8 +44674,8 @@ var init_music = __esm({
|
|
|
44571
44674
|
lengthLine = (made, file, of) => {
|
|
44572
44675
|
if (made.seconds === null) return "The length of " + file + " could not be read here (ffmpeg): check it against the video's " + of.toFixed(2) + " s before the music is placed.\n";
|
|
44573
44676
|
if (!made.short) return void 0;
|
|
44574
|
-
const { seconds: seconds7, missing:
|
|
44575
|
-
return "The music is " + seconds7.toFixed(2) + " s long, " +
|
|
44677
|
+
const { seconds: seconds7, missing: missing3 } = made.short;
|
|
44678
|
+
return "The music is " + seconds7.toFixed(2) + " s long, " + missing3.toFixed(2) + " s shorter than the " + of.toFixed(2) + " s it is for: the last " + missing3.toFixed(2) + " s of the video would have no music. Order a longer track (this command with --seconds " + musicSeconds(of + missing3 + MARGIN_SECONDS) + " is a new order, priced and agreed anew; the music is faded out at the end of the video), or end the video with the music (shorten its last scene by " + missing3.toFixed(2) + " s).\n";
|
|
44576
44679
|
};
|
|
44577
44680
|
overLimit = (e, items, max) => {
|
|
44578
44681
|
if (!(e instanceof PopostApiError && e.code === "CREDIT_LIMIT_EXCEEDED")) throw e;
|
|
@@ -45206,7 +45309,7 @@ var init_sfx = __esm({
|
|
|
45206
45309
|
});
|
|
45207
45310
|
|
|
45208
45311
|
// src/video/sound/analysis.ts
|
|
45209
|
-
var MAX_ANALYSIS_SECONDS, MAX_ANALYSIS_BYTES, POLL_MS5, WAIT_LIMIT_MS3, heardSound, measureFile,
|
|
45312
|
+
var MAX_ANALYSIS_SECONDS, MAX_ANALYSIS_BYTES, POLL_MS5, WAIT_LIMIT_MS3, heardSound, measureFile, missing2, firstLine, planAnalysis, untilDone3, runAnalysis;
|
|
45210
45313
|
var init_analysis = __esm({
|
|
45211
45314
|
"src/video/sound/analysis.ts"() {
|
|
45212
45315
|
"use strict";
|
|
@@ -45237,7 +45340,7 @@ var init_analysis = __esm({
|
|
|
45237
45340
|
const m = measureSound(pcm, 22050, picture3);
|
|
45238
45341
|
return loudness === void 0 ? m : { ...m, loudness };
|
|
45239
45342
|
};
|
|
45240
|
-
|
|
45343
|
+
missing2 = (e) => e instanceof PopostApiError && (e.status === 404 || e.code === "NOT_FOUND");
|
|
45241
45344
|
firstLine = (e) => (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "failed";
|
|
45242
45345
|
planAnalysis = async (rt, sound2, o = {}) => {
|
|
45243
45346
|
if (!sound2) return { kind: "none", record: { status: "silent" } };
|
|
@@ -45250,7 +45353,7 @@ var init_analysis = __esm({
|
|
|
45250
45353
|
const credits = await quoteSoundAnalysis(rt, sound2.seconds);
|
|
45251
45354
|
return { kind: "run", credits, item: { kind: "sound-analysis", what: o.what ?? "the sound of the reference (music, ambience, effects)", credits, seconds: sound2.seconds } };
|
|
45252
45355
|
} catch (e) {
|
|
45253
|
-
if (
|
|
45356
|
+
if (missing2(e)) return { kind: "none", record: { status: "unavailable" } };
|
|
45254
45357
|
if (e instanceof PopostApiError) return { kind: "none", record: { status: "failed", why: "its price could not be read: " + firstLine(e) } };
|
|
45255
45358
|
throw e;
|
|
45256
45359
|
}
|
|
@@ -45283,7 +45386,7 @@ var init_analysis = __esm({
|
|
|
45283
45386
|
if (done2.state !== "ready" || !done2.result) return { status: "failed", id: done2.id, chargedCredits: 0, why: done2.failure ?? "the analysis ended " + (done2.state || "without a result") };
|
|
45284
45387
|
return { status: "done", id: done2.id, chargedCredits: charged, result: done2.result };
|
|
45285
45388
|
} catch (e) {
|
|
45286
|
-
if (
|
|
45389
|
+
if (missing2(e)) return { status: "unavailable" };
|
|
45287
45390
|
if (e instanceof AmbiguousSubmitError || e instanceof ToolError || e instanceof PopostApiError) return { status: "failed", why: firstLine(e) };
|
|
45288
45391
|
throw e;
|
|
45289
45392
|
}
|
|
@@ -46733,11 +46836,11 @@ var init_review2 = __esm({
|
|
|
46733
46836
|
const seconds7 = Math.round(v.frames / v.fps * 1e3) / 1e3;
|
|
46734
46837
|
const audio = rebind(old?.audio, [{ kind: "observed", detail: "The sound of the final video, all " + seconds7 + " s: its voices, music and effects against the reference.", file: v.file, sha256: v.fingerprint, media: "video", at: [0, seconds7] }], v, old?.artifactFingerprint, changed2);
|
|
46735
46838
|
const visual = rebind(old?.visual, o.visual.map((f) => frameEvidence(v, f, "its medium, finish and layout against the reference.")), v, old?.artifactFingerprint, changed2);
|
|
46736
|
-
const
|
|
46839
|
+
const missing3 = [];
|
|
46737
46840
|
const events = c.events.map((e) => {
|
|
46738
46841
|
const planned = o.plan?.events.find((p) => p.id === e.id);
|
|
46739
46842
|
const frames = o.events[e.id] ?? (planned ? spanFrames2(planned.span, v.frames) : void 0);
|
|
46740
|
-
if (!frames)
|
|
46843
|
+
if (!frames) missing3.push(e.id);
|
|
46741
46844
|
const names = ["lead-in", "middle", "resolved state"];
|
|
46742
46845
|
const bound = (frames ?? []).map((f, k, all) => frameEvidence(v, f, (all.length === 3 ? names[k] : "a state") + ' of "' + short(e.description) + '" (' + e.id + ")."));
|
|
46743
46846
|
return { id: e.id, ...rebind(old?.events?.find((x) => x.id === e.id), bound, v, old?.artifactFingerprint, changed2), frames: frames ?? [] };
|
|
@@ -46753,7 +46856,7 @@ var init_review2 = __esm({
|
|
|
46753
46856
|
events: events.map(({ frames: _frames, ...finding }) => finding),
|
|
46754
46857
|
...old?.audioUses ? { audioUses: old.audioUses } : o.audioUses ? { audioUses: o.audioUses } : {}
|
|
46755
46858
|
};
|
|
46756
|
-
return { review: review3, changed: changed2, missing:
|
|
46859
|
+
return { review: review3, changed: changed2, missing: missing3, frames: [{ name: "audio", frames: [] }, { name: "visual", frames: o.visual }, ...events.map((e) => ({ name: e.id, frames: e.frames }))] };
|
|
46757
46860
|
};
|
|
46758
46861
|
withVerdicts = (r, passed, failed4) => {
|
|
46759
46862
|
const names = /* @__PURE__ */ new Set(["audio", "visual", ...(r.events ?? []).map((e) => e.id)]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Runtime } from '../runtime';
|
|
2
2
|
import { type JsonRecord } from './base';
|
|
3
3
|
import { PopostApiError } from './errors';
|
|
4
|
+
import type { SavedVideo } from './link-video';
|
|
4
5
|
export interface RemoteImage {
|
|
5
6
|
readonly url: string;
|
|
6
7
|
readonly mimeType?: string;
|
|
@@ -10,6 +11,8 @@ export interface RemoteImage {
|
|
|
10
11
|
}
|
|
11
12
|
export interface PostPlan {
|
|
12
13
|
readonly platform: string;
|
|
14
|
+
/** `video`: the pictures are the cover only, the file is fetched separately (link-video.ts); null when the server did not say */
|
|
15
|
+
readonly kind: 'images' | 'video' | null;
|
|
13
16
|
readonly sourceUrl: string;
|
|
14
17
|
readonly title: string;
|
|
15
18
|
readonly text: string;
|
|
@@ -49,5 +52,8 @@ export interface Downloaded {
|
|
|
49
52
|
* ones before it. `retry` is what the user is told to do about a failure.
|
|
50
53
|
*/
|
|
51
54
|
export declare const downloadPictures: (rt: Runtime, images: readonly RemoteImage[], outDir: string, retry: string) => Promise<Downloaded>;
|
|
52
|
-
/**
|
|
53
|
-
|
|
55
|
+
/**
|
|
56
|
+
* The PostBundle for a downloaded post; its resources are the files in `saved` and the post's `video`, as paths relative
|
|
57
|
+
* to the bundle file. Pages (`pageOrder`) are the pictures only: a video post's one picture is its cover.
|
|
58
|
+
*/
|
|
59
|
+
export declare const buildBundle: (rt: Runtime, plan: PostPlan, saved: readonly SavedImage[], video?: SavedVideo) => JsonRecord;
|