@optima-chat/browser-cli 0.10.2 → 0.11.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.
Files changed (2) hide show
  1. package/dist/index.js +52 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -378,6 +378,9 @@ var BrowserAPI = class {
378
378
  body: JSON.stringify({ src, dest })
379
379
  });
380
380
  }
381
+ async listVideos() {
382
+ return request("/api/files/videos");
383
+ }
381
384
  };
382
385
  var api = new BrowserAPI();
383
386
 
@@ -1096,6 +1099,7 @@ function registerZiNiaoCommands(program2) {
1096
1099
  // src/commands/recipes.ts
1097
1100
  import { writeFileSync as writeFileSync4 } from "fs";
1098
1101
  import { resolve as resolve2 } from "path";
1102
+ var PUBLISH_TIMEOUT_MS = 144e4;
1099
1103
  async function runExport(script, params, out, timeoutMs) {
1100
1104
  const outPath = resolve2(out);
1101
1105
  const result = await api.runRecipeScript(script, { ...params, out_path: outPath }, 2e3, timeoutMs);
@@ -1131,6 +1135,32 @@ function registerRecipeCommands(program2) {
1131
1135
  process.exit(1);
1132
1136
  }
1133
1137
  });
1138
+ 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
+ "--product-name <text>",
1140
+ "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) => {
1142
+ try {
1143
+ const params = {
1144
+ ziniao_profile_id: opts.ziniaoProfile,
1145
+ video: opts.video,
1146
+ product_query: opts.productQuery,
1147
+ product_name: opts.productName,
1148
+ caption: opts.caption
1149
+ };
1150
+ if (opts.hashtags) params.hashtags = opts.hashtags;
1151
+ if (opts.publishUrl) params.publish_url = opts.publishUrl;
1152
+ const result = await api.runRecipeScript(
1153
+ "tiktok_video_publish",
1154
+ params,
1155
+ 2e3,
1156
+ PUBLISH_TIMEOUT_MS
1157
+ );
1158
+ console.log(result.detail);
1159
+ } catch (err) {
1160
+ console.error(formatError(err));
1161
+ process.exit(1);
1162
+ }
1163
+ });
1134
1164
  }
1135
1165
 
1136
1166
  // src/commands/bitbrowser.ts
@@ -1196,6 +1226,19 @@ function registerFeikuaCommands(program2) {
1196
1226
  }
1197
1227
 
1198
1228
  // src/commands/files.ts
1229
+ function formatVideoList(videos) {
1230
+ if (videos.length === 0) {
1231
+ return `No videos found. Put your videos in:
1232
+ macOS/Linux: ~/Downloads/OptimaConnect/videos
1233
+ Windows: C:\\Users\\<\u7528\u6237\u540D>\\Downloads\\OptimaConnect\\videos
1234
+ Then try again.`;
1235
+ }
1236
+ return videos.map((v) => {
1237
+ const mb = (v.size / 1024 / 1024).toFixed(1);
1238
+ const time = v.mtime.slice(0, 19).replace("T", " ") + " UTC";
1239
+ return `${v.name} \u2014 ${mb} MB, ${time}`;
1240
+ }).join("\n");
1241
+ }
1199
1242
  function registerFileCommands(program2) {
1200
1243
  program2.command("send-file").description("Send a file from your workspace to your local download folder").requiredOption("--src <path>", "Source path in your workspace (e.g. ~/output/report.pdf)").requiredOption("--dest <path>", "Destination path relative to the download folder").action(async (opts) => {
1201
1244
  try {
@@ -1206,6 +1249,15 @@ function registerFileCommands(program2) {
1206
1249
  process.exit(1);
1207
1250
  }
1208
1251
  });
1252
+ program2.command("list-videos").description("List videos in your local video folder (requires Desktop app online)").action(async () => {
1253
+ try {
1254
+ const { videos } = await api.listVideos();
1255
+ console.log(formatVideoList(videos));
1256
+ } catch (err) {
1257
+ console.error(formatError(err));
1258
+ process.exit(1);
1259
+ }
1260
+ });
1209
1261
  }
1210
1262
 
1211
1263
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/browser-cli",
3
- "version": "0.10.2",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {