@optima-chat/browser-cli 0.11.0 → 0.13.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/dist/index.js +38 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -274,7 +274,7 @@ var BrowserAPI = class {
|
|
|
274
274
|
async getScreenshot(sessionId) {
|
|
275
275
|
return requestBinary(`/api/sessions/${sessionId}/screenshot`);
|
|
276
276
|
}
|
|
277
|
-
async runRecipeScript(name, params, pollMs = 2e3, timeoutMs = 36e4) {
|
|
277
|
+
async runRecipeScript(name, params, pollMs = 2e3, timeoutMs = 36e4, timeoutHint) {
|
|
278
278
|
const started = await request(`/api/scripts/${name}/run`, {
|
|
279
279
|
method: "POST",
|
|
280
280
|
body: JSON.stringify({ params })
|
|
@@ -295,7 +295,7 @@ var BrowserAPI = class {
|
|
|
295
295
|
}
|
|
296
296
|
if (Date.now() >= deadline) {
|
|
297
297
|
throw new Error(
|
|
298
|
-
`recipe ${name} did not finish within ${Math.round(timeoutMs / 1e3)}s (task ${started.id})`
|
|
298
|
+
`recipe ${name} did not finish within ${Math.round(timeoutMs / 1e3)}s (task ${started.id})` + (timeoutHint ? ` \u2014\u2014 ${timeoutHint}` : "")
|
|
299
299
|
);
|
|
300
300
|
}
|
|
301
301
|
await new Promise((r) => setTimeout(r, pollMs));
|
|
@@ -1099,7 +1099,8 @@ function registerZiNiaoCommands(program2) {
|
|
|
1099
1099
|
// src/commands/recipes.ts
|
|
1100
1100
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
1101
1101
|
import { resolve as resolve2 } from "path";
|
|
1102
|
-
var PUBLISH_TIMEOUT_MS =
|
|
1102
|
+
var PUBLISH_TIMEOUT_MS = 18e5;
|
|
1103
|
+
var PUBLISH_TIMEOUT_HINT = "\u4EFB\u52A1\u4ECD\u5728\u540E\u7AEF\u8FD0\u884C,\u89C6\u9891\u53EF\u80FD\u5DF2\u7ECF\u53D1\u51FA\u53BB\u4E86\u3002\u53D1\u5E03\u72B6\u6001\u672A\u77E5 \u2014\u2014 \u8BF7\u5230\u5356\u5BB6\u540E\u53F0\u786E\u8BA4,\u4E0D\u8981\u91CD\u8DD1\u672C\u547D\u4EE4(\u4F1A\u53D1\u51FA\u91CD\u590D\u89C6\u9891)\u3002";
|
|
1103
1104
|
async function runExport(script, params, out, timeoutMs) {
|
|
1104
1105
|
const outPath = resolve2(out);
|
|
1105
1106
|
const result = await api.runRecipeScript(script, { ...params, out_path: outPath }, 2e3, timeoutMs);
|
|
@@ -1135,10 +1136,39 @@ function registerRecipeCommands(program2) {
|
|
|
1135
1136
|
process.exit(1);
|
|
1136
1137
|
}
|
|
1137
1138
|
});
|
|
1139
|
+
program2.command("publish-video-global").description("Publish one shoppable video to a TikTok Shop CROSS-BORDER store (one region per run)").requiredOption("--ziniao-profile <id>", "ZiNiao browser profile ID").requiredOption("--video <name>", "Video file name (from list-videos)").requiredOption("--account <username>", "Publishing account username; it also picks the region (one region per run)").requiredOption("--product-query <keyword>", "Product search keyword or product ID, narrow enough to hit exactly one product (ask the user)").requiredOption(
|
|
1140
|
+
"--product-name <text>",
|
|
1141
|
+
"Display name on the video: max 30 chars, letters/digits/spaces only (ask the user)"
|
|
1142
|
+
).requiredOption("--caption <text>", "Video caption").option("--dry-run", "Fill everything, run the pre-publish checks, then STOP before clicking publish (nothing is published; the browser window stays open for you to inspect)").option("--hashtags <text>", "Comma-separated hashtags, bare words (the page adds the # itself)").option("--publish-url <url>", "Video publish page URL (include the right ?shop_region=)").action(async (opts) => {
|
|
1143
|
+
try {
|
|
1144
|
+
const params = {
|
|
1145
|
+
ziniao_profile_id: opts.ziniaoProfile,
|
|
1146
|
+
video: opts.video,
|
|
1147
|
+
account: opts.account,
|
|
1148
|
+
product_query: opts.productQuery,
|
|
1149
|
+
product_name: opts.productName,
|
|
1150
|
+
caption: opts.caption
|
|
1151
|
+
};
|
|
1152
|
+
if (opts.dryRun) params.dry_run = "1";
|
|
1153
|
+
if (opts.hashtags) params.hashtags = opts.hashtags;
|
|
1154
|
+
if (opts.publishUrl) params.publish_url = opts.publishUrl;
|
|
1155
|
+
const result = await api.runRecipeScript(
|
|
1156
|
+
"tiktok_video_publish_global",
|
|
1157
|
+
params,
|
|
1158
|
+
2e3,
|
|
1159
|
+
PUBLISH_TIMEOUT_MS,
|
|
1160
|
+
PUBLISH_TIMEOUT_HINT
|
|
1161
|
+
);
|
|
1162
|
+
console.log(result.detail);
|
|
1163
|
+
} catch (err) {
|
|
1164
|
+
console.error(formatError(err));
|
|
1165
|
+
process.exit(1);
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1138
1168
|
program2.command("publish-video").description("Publish one shoppable video to TikTok Shop").requiredOption("--ziniao-profile <id>", "ZiNiao browser profile ID").requiredOption("--video <name>", "Video file name (from list-videos)").requiredOption("--product-query <keyword>", "Product search keyword, narrow enough to hit exactly one product (ask the user)").requiredOption(
|
|
1139
1169
|
"--product-name <text>",
|
|
1140
1170
|
"Display name on the video: max 30 chars, letters/digits/spaces only (ask the user)"
|
|
1141
|
-
).requiredOption("--caption <text>", "Video caption").option("--hashtags <text>", "Comma-separated hashtags").option("--publish-url <url>", "Video publish page URL").action(async (opts) => {
|
|
1171
|
+
).requiredOption("--caption <text>", "Video caption").option("--account <username>", "Publishing account username (default: the shop's official account; pass a marketing sub-account to post as it)").option("--dry-run", "Fill everything, run the pre-publish checks, then STOP before clicking publish (nothing is published; the browser window stays open for you to inspect)").option("--hashtags <text>", "Comma-separated hashtags, bare words (the page adds the # itself)").option("--publish-url <url>", "Video publish page URL").action(async (opts) => {
|
|
1142
1172
|
try {
|
|
1143
1173
|
const params = {
|
|
1144
1174
|
ziniao_profile_id: opts.ziniaoProfile,
|
|
@@ -1147,13 +1177,16 @@ function registerRecipeCommands(program2) {
|
|
|
1147
1177
|
product_name: opts.productName,
|
|
1148
1178
|
caption: opts.caption
|
|
1149
1179
|
};
|
|
1180
|
+
if (opts.account) params.account = opts.account;
|
|
1181
|
+
if (opts.dryRun) params.dry_run = "1";
|
|
1150
1182
|
if (opts.hashtags) params.hashtags = opts.hashtags;
|
|
1151
1183
|
if (opts.publishUrl) params.publish_url = opts.publishUrl;
|
|
1152
1184
|
const result = await api.runRecipeScript(
|
|
1153
1185
|
"tiktok_video_publish",
|
|
1154
1186
|
params,
|
|
1155
1187
|
2e3,
|
|
1156
|
-
PUBLISH_TIMEOUT_MS
|
|
1188
|
+
PUBLISH_TIMEOUT_MS,
|
|
1189
|
+
PUBLISH_TIMEOUT_HINT
|
|
1157
1190
|
);
|
|
1158
1191
|
console.log(result.detail);
|
|
1159
1192
|
} catch (err) {
|