@muqian/xiangsu-mcp-plus 0.6.1 → 0.7.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 +39 -22
- package/editor-plugin/features/assets.cjs +1 -1
- package/editor-plugin/features/community.cjs +153 -39
- package/editor-plugin/features/menu.cjs +8 -3
- package/editor-plugin/features/music.cjs +1 -1
- package/editor-plugin/features/preview.cjs +9 -4
- package/editor-plugin/features/search.cjs +2 -2
- package/editor-plugin/features/square.cjs +2 -2
- package/editor-plugin/features/works.cjs +7 -7
- package/editor-plugin/library.cjs +4 -1
- package/package.json +1 -1
- package/src/bridge.mjs +30 -7
- package/src/calllog.mjs +32 -0
- package/src/outputs.mjs +122 -0
- package/src/server.mjs +195 -128
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
像塑(Douyin AR,macOS)的 MCP 扩展:**一个 MCP 服务**同时提供像塑官方 MCP 的全部工具,以及官方 MCP 够不到的编辑器能力。
|
|
6
6
|
|
|
7
|
-
- 官方工具原样转发(`get_scene`、`edit_by_dsl`、`capture_preview`、`save_project` 等),像塑重启后自动重连,官方工具列表变化时通知客户端刷新。唯一的例外是 `capture_preview`:9.8.1 起官方截图是给窗口里的预览区域拍照,窗口最小化或不可见时是黑的,这时改为重置预览、等到重载后的画面,从预览的渲染结果截取并缩小到官方的 320×569
|
|
7
|
+
- 官方工具原样转发(`get_scene`、`edit_by_dsl`、`capture_preview`、`save_project` 等),像塑重启后自动重连,官方工具列表变化时通知客户端刷新。唯一的例外是 `capture_preview`:9.8.1 起官方截图是给窗口里的预览区域拍照,窗口最小化或不可见时是黑的,这时改为重置预览、等到重载后的画面,从预览的渲染结果截取并缩小到官方的 320×569(不含界面元素);窗口可见时照旧转发,这时刚改完场景或换了预览视频可能还是旧画面(工具说明里写了这一点),要确认新画面用 `preview_frames`。
|
|
8
8
|
- 官方素材库:浏览、搜索、看封面、应用(脸部变形、美型、AI 实时变脸、美妆、滤镜、贴纸、画面特效等),流程与素材库面板相同;包括「素材广场」(其他创作者分享的现成 AI 图片、AI 妆容、自定义实时变脸、贴纸和素材包,应用时不重新生成、不扣额度)和自己的「收藏」。
|
|
9
9
|
- 「添加对象」菜单:工具栏美妆 / 美型 / AI 实时变脸里的全部官方功能项(美容、面部生成、表情生成、性别年龄、五官处理、身体换装等),可看示意图后按菜单项 ID 添加。
|
|
10
10
|
- AI 组合效果(用户拍照后在云端按工作流出图或出视频):像 AI 效果窗口的「新建工作流」一样建工作流,交给官方工作流工具编辑,再像「应用」一样放进场景。
|
|
11
11
|
- 首页作品:浏览、搜索、看封面,下载完整工程到本地或直接在编辑器里打开(官方工程和已发布的作品),供 agent 读取场景、脚本和资源,学习别人的做法;下载的东西都有登记,用完即删,最长保留 24 小时。
|
|
12
12
|
- 交付:设置并上传图标、特效检测(和编辑器里点「特效检测」一样,云端检测)、填好提交窗口(名称、触发提示、摄像头方向、灵感、任务,一直走到「提交审核」页并等检测跑完;最后的「提交审核」由你来点)、手机预览二维码、把已领取的任务或创作灵感绑定到工程。
|
|
13
13
|
- 抖音音乐:按分类或关键词找歌,设为特效音乐。
|
|
14
|
-
- 灵感、任务、排行榜:首页「灵感」页签和活动中心的任务(征集任务、成长任务),以及像塑移动版才有的排行榜(年轻 / 男生 /
|
|
14
|
+
- 灵感、任务、排行榜:首页「灵感」页签和活动中心的任务(征集任务、成长任务),以及像塑移动版才有的排行榜(年轻 / 男生 / 女生喜爱榜、每日投稿榜、热玩互动榜、跟拍榜,各榜按两级分类细分;热点榜;专题合集里两百多期主题特效榜和模板榜;创新计划月榜和官方精选)和成长之路(特效师等级、奖励和各目标进度),用编辑器里登录的账号读取;可收藏灵感、领取任务。
|
|
15
15
|
- 我的特效审核:自己提交过的特效和审核状态,审核不通过的具体原因和完整审核记录(编辑器里只显示「审核未通过」,原因原本只能在像塑移动版的审核记录页看到)。
|
|
16
16
|
- 塑型画笔(FaceWarpX)强度:官方能读不能写,这里按检查器滑块的方式改。
|
|
17
17
|
- 工程窗口:新建空白工程(首次保存到指定目录)、打开、关闭。
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
| 编辑器插件 `XiangsuMcpExt` | `editor-plugin/` | 像塑用户插件。每个工程窗口里开一个只监听 `127.0.0.1`、带随机令牌的 RPC 服务,调用编辑器自身的模块 |
|
|
29
29
|
| MCP 服务 | `src/server.mjs` | stdio MCP。转发官方 MCP(`http://127.0.0.1:17320/mcp`),并把插件能力包装成工具 |
|
|
30
30
|
|
|
31
|
-
插件把 `{pid, port, token, startedAt}` 写到 `~/.xiangsu-mcp-ext/instances/<pid>.json`(权限 600)。窗口崩溃或被强退时这份记录会留下来,所以只有该 pid 的进程还在、并且启动时间不晚于 `startedAt` 时才算开着的窗口;pid
|
|
31
|
+
插件把 `{pid, port, token, startedAt}` 写到 `~/.xiangsu-mcp-ext/instances/<pid>.json`(权限 600)。窗口崩溃或被强退时这份记录会留下来,所以只有该 pid 的进程还在、并且启动时间不晚于 `startedAt` 时才算开着的窗口;pid 被后来的进程复用时不算。插件日志在 `~/.xiangsu-mcp-ext/logs/plugin.log`;MCP 服务每次工具调用(名称、耗时、报错、是否发了进度)和异常退出记在 `~/.xiangsu-mcp-ext/logs/server.log`,超过 5 MB 时旧的移到 `server.log.1`;导入记录在 `~/.xiangsu-mcp-ext/imports/`。
|
|
32
|
+
|
|
33
|
+
按工程找窗口时,同时询问各窗口开着哪个工程,卡住或正在关闭的窗口(5 秒没回应)不影响找到其它窗口,并记住每个工程上次所在的窗口,下次先问它。客户端请求带进度令牌时,工具调用期间每 5 秒发一次进度,避免长调用(连续截帧、等提交页检测)被当成空闲掐断。
|
|
32
34
|
|
|
33
35
|
## 工具
|
|
34
36
|
|
|
@@ -38,11 +40,11 @@
|
|
|
38
40
|
| --- | --- |
|
|
39
41
|
| `ext_status` | 官方 MCP 连接状态;每个工程窗口的 pid、工程路径、instance_id、编辑器接口自检 |
|
|
40
42
|
| `project_open` / `project_new` / `project_close` | 打开已有工程、新建空白工程并保存到指定目录、关闭工程窗口(有未保存改动时默认拒绝) |
|
|
41
|
-
| `image_view` |
|
|
42
|
-
| `
|
|
43
|
+
| `image_view` | 看图:列表类工具返回的引用(`cover_ref`、`gif_ref`、任务内容块的 `image_refs` 等,形如 `img:12`)、详情类工具返回的地址(灵感 `images`、菜单示意图)或本机图片路径都交给它;视频和音频引用(`video:3`、`audio:5`)返回原地址;一次最多 8 张,动图等大图一次给不完时把没给的列在 `not_returned` 里(单次响应不超过 MCP stdio 的 10 MiB 上限) |
|
|
44
|
+
| `library_list` / `library_search` | 官方素材库面板清单(不传 `panel_key`,含素材广场、收藏)和面板里的分页列表、关键词搜索:逐个面板查标题以拿全结果;词正好是面板名或子分类名时也带出那里的素材(「滤镜」「腮红」「复古滤镜」),按标题匹配程度排序,`queries` 一次搜多个词,返回各面板条数和展开了哪些分类,结果缓存 10 分钟供翻页;每条素材带 `kind`、封面 `cover_ref` 和命中方式 `matched` |
|
|
43
45
|
| `library_images` | 一张 AI 图片卡片的整组结果图地址(按 `image_index` 编号) |
|
|
44
46
|
| `library_apply` | 下载素材包、校验 MD5、导入并放进场景(可撤销);素材广场卡片按 `kind` 走编辑器自己的应用流程(AI 图片可用 `image_index` 选第几张);返回新增对象和素材包文件夹 |
|
|
45
|
-
| `
|
|
47
|
+
| `works_list` / `works_search` | 首页作品分页列表(每页带上全部分类:推荐、官方工程、新手必做、游戏、妆容、AI玩法…;可按推荐 / 最新 / 使用量排序,`next_cursor` 原样传回翻页)、按作品名搜索(默认搜全部分类并合并去重,每条带 `found_in`;`queries` 一次搜多个词;按 `offset` 分页,结果缓存 10 分钟) |
|
|
46
48
|
| `works_by_effect` | 按特效 ID 查排行榜等处的特效在首页有没有工程(一次最多 20 个),逐个返回 `found` / `same_name` / `not_on_homepage` |
|
|
47
49
|
| `works_download` | 下载并解压完整工程(与首页点开作品同一流程,但不开窗口),返回工程目录和文件清单;`dest` 给定时把工程放到该目录 |
|
|
48
50
|
| `works_open` | 下载并在新窗口里按首页的方式打开(不弹版本升级提示,工程处于未保存状态),返回 pid 和 instance_id |
|
|
@@ -51,24 +53,25 @@
|
|
|
51
53
|
| `effect_check` | 和工具栏「特效检测」按钮一样:打开特效检测窗口做云端检测(会上传特效包做测试,不是发布),等待结果,并读出检测页的详情一起返回(页面结论、每项结论、包体积和安卓 / iOS 帧率对上限、没通过的项的改进建议),然后关掉窗口;详情读不出时窗口留着并返回 `details_error`;超时时窗口留着,下次调用先关掉它 |
|
|
52
54
|
| `submit_prepare` | 本地检查包体上限、是否原样套用模板、登录、图标,通过后先关掉还开着的提交窗口(之前调用留下的),再走「提交特效」按钮的入口打开一个新的,逐页填写:名称(必填)、触发提示、默认摄像头方向、灵感、任务和赛道(可用 `icon_image` 先设图标),翻到「提交审核」页并等页面检测跑完,返回摘要、检测结果、协议是否已同意和 `next`(你还要做什么)。每一项都从页面读回核对,页面截断、报错、没选上或翻页被拦时报 `SUBMIT_*` 错误,窗口保持打开。不勾协议,也不点「提交审核」 |
|
|
53
55
|
| `mobile_preview` | 按手机预览方式打包上传到抖音预览服务,返回和编辑器一样的二维码(7 天有效),抖音 App 扫码真机看;二维码同时存成文件(`~/.xiangsu-mcp-ext/mobile-qr/`),到期自动删除 |
|
|
54
|
-
| `
|
|
56
|
+
| `inspiration_list` / `inspiration_detail` | 灵感分页列表(每页带上全部分类,每条带关联热点)、详情(说明、图片、奖励、关联热点的热度和标签、同灵感特效、示例视频的播放地址和封面、贴纸、是否已收藏) |
|
|
55
57
|
| `inspiration_collect` | 收藏或取消收藏灵感(写账号),之后重新查询确认生效 |
|
|
56
58
|
| `inspiration_bind` | 把灵感绑定到当前工程,提交时带上 |
|
|
57
|
-
| `tasks_list` / `task_detail` | 活动与特效征集任务(`kind=effect`)、成长任务(`kind=growth
|
|
59
|
+
| `tasks_list` / `task_detail` | 活动与特效征集任务(`kind=effect`)、成长任务(`kind=growth`)的列表(按 `offset` / `count` 分页)与详情(状态和状态说明、奖励、整理过的任务说明:每个内容块的条目、参考图和视频引用、奖项金额和名额、链接,`save_to` 另存原始返回;征集任务详情还有自己提交到这个任务的特效 `my_effects`:审核状态、拍摄 / 播放 / 投稿峰值、获奖金额、是否符合主题) |
|
|
60
|
+
| `growth_route` | 移动版「成长之路」:当前特效师等级,每一级的奖励、状态和目标进度(如「绑定灵感上线 0/3 个作品 ¥10」),最高级的权益 |
|
|
58
61
|
| `task_receive` | 领取一个待领取(`WAIT_RECEIVE`)的征集任务(写账号,不能撤销),其它状态直接拒绝 |
|
|
59
62
|
| `task_bind` | 已领取的任务按任务详情页「去创作」的方式重开工程绑定 |
|
|
60
|
-
| `
|
|
61
|
-
| `rank_hotspots` |
|
|
63
|
+
| `rank_list` | 分页读移动版排行榜(榜单和筛选项写在参数说明里),可按日期、每级一个分类、特效等级、面板、偏好、来自工具、年轻喜爱度过滤;每页带上该榜当天的两级分类(大类如人像美化、细类如美妆) |
|
|
64
|
+
| `rank_hotspots` | 热点榜(按 `offset` / `count` 分页);带 `topic_id` 时返回该热点下的灵感 |
|
|
62
65
|
| `rank_subjects` | 专题合集里按主题的特效榜(`kind=effect`,如「热爆美妆特效榜」「熊出没IP特效榜」)和模板榜(`kind=template`,如「歌词玩法模板榜」),分页或按 `keyword` 搜榜名;带 `subject_id` 时返回该榜全部特效 |
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
66
|
+
| `rank_innovation` | 创新计划官方精选(`kind=template` / `effect`)和创作者月榜(`kind=creators`) |
|
|
67
|
+
| `my_effects` | 自己提交过的特效,最新的在前:审核状态、绑定的任务和灵感、能否编辑 / 申诉;审核未通过、测试未通过、申诉审核未通过的带上最近一条审核记录(去掉标记的原因正文、分条原因、链接) |
|
|
68
|
+
| `my_effect_reviews` | 一个自己的特效的完整审核记录:「上线审核」和「精选审核」两条时间线 |
|
|
69
|
+
| `music_list` / `music_apply` | 抖音音乐分类(不带参数时)、按分类列出或搜索(带版权标记),按音乐库「使用」套用,可截取片段 |
|
|
67
70
|
| `scene_tree` | 场景结构的缩进文本:渲染组、对象 guid、名称、是否隐藏、组件类型;可只看子树、控制层数。传 `project_dir` 时不开窗口,直接读工程的 `Assets/main.scene`(如 `works_download` 下载的作品),对象写成 `#序号` |
|
|
68
71
|
| `inspect_many` | 一次查看多个对象的组件参数,可按组件类型、属性名片段过滤,`{type, data}` 包装直接展开,绑定的资源和对象换成名称;`preset="key"` 只留关键参数(变换、显隐、强度/不透明度/颜色类、文字内容、绑定、脚本参数)。同样支持 `project_dir` |
|
|
69
72
|
| `makeup_layers` | 读工程目录里的全部美妆层(妆容层和美瞳),逐层给出区域、部位、平均色、男女强度、是否生效;部位先看层名,看不出时按贴图像素判断。`groups` 按眉、眼妆、美瞳、颊、轮廓、唇汇总,`absent` 列出整套妆没有的部位 |
|
|
70
73
|
| `preview_frames` | 按间隔连续截取预览,720×1280 原始分辨率(官方截图是 320×569),取自渲染结果,窗口在后台或最小化时也能截;默认先重置预览并等到重载后的画面再计时,截图期间临时恢复正常帧率(后台窗口平时 6 fps);可依次换几个预览视频各截一组、截完切回,可按比例裁出局部;每帧存成文件并返回,默认 24 小时后删除。这四个工具都可传 `save_to` 把结果另存到目录长期保留 |
|
|
71
|
-
| `menu_list` / `
|
|
74
|
+
| `menu_list` / `menu_add` | 「添加对象」菜单项列表(`details=true` 时带说明和示意图,一次最多 8 项)、按菜单项添加(可撤销);云端 AI 生成项不暴露(AI 组合效果用下面两个工具) |
|
|
72
75
|
| `ai_combine_new` | 新建一张「AI 组合效果」工作流,等同 AI 效果窗口的「新建工作流」:本地建 AI Graph,只有「输入图」「效果组合」两个节点且未连线,不联网、不扣额度、不建云端草稿;返回 `ai_graph_id` 和各节点的 `node_id`(与官方 `get_workflow_context` 的节点 ID 相同) |
|
|
73
76
|
| `ai_combine_apply` | 把一张 AI 工作流放进场景,等同「应用」(可撤销):编辑器编译工作流、上传工作流文件,再添加「AI 组合效果」对象(没有 2D 前景时一并建「2D 前景」「2D 摄像机」);不扣额度、不建草稿,生成过预览视频时一并上传供审核;编辑器拒绝时返回它的提示原文(如「请先连接效果组合器」);返回新增对象和 `draft_id` |
|
|
74
77
|
| `face_warp_list` / `face_warp_set_intensity` | 列出塑型画笔、改强度(保留笔刷数据,可撤销) |
|
|
@@ -77,27 +80,41 @@
|
|
|
77
80
|
|
|
78
81
|
使用顺序示例:
|
|
79
82
|
|
|
80
|
-
- 套用官方素材:`library_search` → `image_view` 看 `
|
|
81
|
-
- 读别人的工程:`works_search`(或 `works_list`)→ `image_view` 看 `
|
|
83
|
+
- 套用官方素材:`library_search` → `image_view` 看 `cover_ref` → `library_apply` → `capture_preview` → `save_project`。
|
|
84
|
+
- 读别人的工程:`works_search`(或 `works_list`)→ `image_view` 看 `cover_ref` / `gif_ref` → `works_download` → 按返回的 `outline.files` 读 `effect.dyehpj`、`Assets/` 下的场景和 `Graph/` 下的脚本 → `works_cleanup`。
|
|
82
85
|
- 在编辑器里看别人的效果:`works_open` → `get_scene` / `capture_preview` → `project_close`(`discard_changes=true`)→ `works_cleanup`。
|
|
83
86
|
- 交付:`icon_set` → `effect_check` → `mobile_preview` 真机看 → `save_project` → `submit_prepare`(`name`、`trigger_hint` 等),检查返回的摘要和 `next`,在窗口里点「提交审核」。要参加任务的,`tasks_list` → `task_receive` → 再 `tasks_list` → `task_bind`,或者直接在 `submit_prepare` 里传 `task`。
|
|
84
|
-
- 找选题:`
|
|
87
|
+
- 找选题:`rank_list`(如 `rank_type=1` 年轻喜爱榜、`categories=["人像美化","美妆"]`、`levels=["S","A+"]`)看什么在火;`rank_subjects`(`keyword="测一测"` 或 `kind="template"`)看各期主题榜;`rank_hotspots` → 带 `topic_id` 看热点灵感 → `inspiration_detail` → `image_view` 看图;`tasks_list` → `task_detail` 看征集要求和奖项 → `image_view` 看内容块里的参考图。
|
|
85
88
|
- 看榜上特效的工程:`rank_list` → 把这页的 `effect_id` 和 `name` 交给 `works_by_effect` → `status=found` 的用返回的 `template_id` 走 `works_download` / `works_open`。
|
|
86
|
-
- 查审核结果:`
|
|
89
|
+
- 查审核结果:`my_effects` 看哪些没过、`review.text` 是原因 → 要看整条时间线用 `my_effect_reviews`;`can_edit=true` 的在编辑器「拍摄特效管理」里点「编辑」改完重新提交。
|
|
87
90
|
- 拆别人的妆:`works_download` → `makeup_layers` 看用了哪些部位、什么颜色、多浓;自己的工程 `save_project` 后同样用 `makeup_layers` 查缺了哪些部位。
|
|
88
91
|
- 做 AI 组合效果:`ai_combine_new` → 官方 `get_workflow_capabilities`(选生图基模)→ `apply_workflow_patch`(加生图节点、写 prompt、连「输入图 → 生图 → 效果组合」)→ 要看效果时官方 `generate_workflow`(扣额度)→ `ai_combine_apply` → `save_project`。别人的作品怎么搭的,用 `works_download` 下载「AI玩法」分类里的工程,看 `Assets/AI 组合效果/*.oAICombineTextureJSA` 里的 `workflow` 和 `Graph/graph.json` 里的 AI Graph。
|
|
89
92
|
|
|
93
|
+
相近工具的分工(每个工具只做一件事,这些也写进了工具说明;和官方工具重叠的,在官方工具的说明末尾补了一句指向这里):
|
|
94
|
+
|
|
95
|
+
- 看场景:`scene_tree` 先摸清结构(紧凑文本,也能读下载的工程目录)→ `inspect_many` 一次看多个对象的参数;要完整 JSON 才用官方 `get_scene` / `inspect`。
|
|
96
|
+
- 删对象:只删对象用官方 `edit_by_dsl`;要知道删完哪些资源没人用了、连带清理,用 `object_remove`(→ `resource_delete_unused`)。
|
|
97
|
+
- 绑灵感:`inspiration_bind` 按 ID 写进工程,提交窗口自动带出;只在提交时选,给 `submit_prepare` 传 `inspiration`(在收藏的灵感和热点里按名称选)。
|
|
98
|
+
- 绑任务:`task_bind` 重开窗口把任务写进工程;只在提交时选,给 `submit_prepare` 传 `task`,不用重开窗口。
|
|
99
|
+
- 成长:`tasks_list` 的 `kind=growth` 是活动中心里一个个成长任务(参考工程、教程);特效师等级和每级目标进度看 `growth_route`。
|
|
100
|
+
- 素材库:知道要找什么用 `library_search`;按面板和子分类浏览用 `library_list`。
|
|
101
|
+
|
|
90
102
|
几点约定:
|
|
91
103
|
|
|
92
104
|
- `library_apply` / `library_images` 只接受本会话里 `library_list` / `library_search` 返回过的 `template_id`;`works_download` / `works_open` 只接受本会话里 `works_list` / `works_search` / `works_by_effect` 返回过的作品(记录在 MCP 服务里,不受工程窗口开关影响,重启服务后需重新搜索)。
|
|
93
105
|
- 像塑最多同时开 2 个工程窗口(编辑器的 `CHILD_PROCESS_LIMIT`)。都占满时 `project_open` / `project_new` / `works_open` 返回 `WINDOW_LIMIT`(首页进程答复 `reuseCurrent`,工具不会把工程换进当前窗口),先 `project_close` 一个。
|
|
94
106
|
- 素材的 `kind`:`package` 素材包、`ai_image` AI 图片、`ai_makeup` AI 妆容(按部位建多个对象)、`custom_gan` 自定义实时变脸、`foreground_sticker` / `face_sticker` 图片贴纸、`filter` 滤镜。素材广场里没有可应用内容的卡片(编辑器点应用也没反应)不列出,只在 `unsupported` 里计数。素材广场单个关键词最多返回 1000 条。广场卡片是异步应用的,工具等对象出现在场景里(最长 60 秒)才返回;新建的渲染组(如「2D 前景」「AI 实时变脸 (1)」)会作为新增对象报告,删除它们用官方的 `delete_render_group`。
|
|
95
107
|
- 素材库的搜索接口只匹配标题,很多素材的名字里没有人们会搜的词(美妆 › 腮红里是「雾堇胭」「红玫瑰」,没有素材叫「滤镜」),所以 `library_search` 还会展开名字与搜索词相同的面板或子分类,以及「子分类 + 面板」组合(「复古滤镜」);「面板 + 其它词」(「韩系滤镜」)只在该面板里按标题搜「韩系」。名字只是包含搜索词的子分类不展开,列在 `related_categories`。每个面板或子分类最多取 300 条(实测子分类 17–125 条)。什么都没匹配到时返回 `hint`。
|
|
96
|
-
- `works_*`、`inspiration_*`、`task_*`、`rank_*`、`
|
|
97
|
-
-
|
|
108
|
+
- `works_*`、`inspiration_*`、`task_*`、`rank_*`、`my_effects`、`my_effect_reviews`、`library_list` / `library_search` / `library_images`、`menu_list` 与当前工程无关,任意一个工程窗口开着即可;不指定工程时由 pid 最小的窗口处理。
|
|
109
|
+
- 返回资料的方式:
|
|
110
|
+
- 列表默认每页 20 条(服务端上限更小的按上限),只给挑选时要看的字段;要细节用对应的详情工具。
|
|
111
|
+
- 列表里的图片、视频、音频不给地址,给短引用 `*_ref` / `*_refs`(`img:12`、`video:3`、`audio:5`),交给 `image_view`:一个签名 CDN 地址有几百字,实测占列表每条的 43%–93%。引用记在 MCP 服务里,这次运行期间有效(最多记 2 万个,超出时忘掉最久没用的);详情工具(`inspiration_detail`、`menu_list` 的 `details`)给的是这个对象自己的图,仍给地址。
|
|
112
|
+
- 我们自己的工具回答超过 3 万字时,全文写进 `~/.xiangsu-mcp-ext/outputs/`(24 小时后删除),回答换成文件路径和结构概要(每个字段的值或条数,列表给每条有哪些字段),用读文件的工具按需读,或用分页参数分几次取。3 万是拍的:`task_detail` 原来一次回 4.8 万字,读不全。官方工具原样转发,不受影响。
|
|
113
|
+
- 字段命名:投稿量统一叫 `publish_*`(`publish_count`、`publish_peak`、`publish_total`),跟拍量叫 `follow_shoot`,页面原样给的展示文字(如「1.2万」「¥50」)以 `_text` 结尾,换算过的金额以 `_yuan` 结尾;看不出单位的数(任务奖项的 `money`、`award_amount`)原样给,不换算。
|
|
114
|
+
- 灵感、任务、排行榜按编辑器首页活动中心的方式请求(编辑器的登录 Cookie 和签名请求头),读写的都是编辑器里登录的账号。排行榜和成长之路用的是像塑移动版的接口,榜单名和筛选项取值与移动版一致,后端改版时可能失效。灵感和任务详情的接口移动版和编辑器是同一个(2026-11-08 对照移动版 v17.7.0 安装包里的接口逐个实测,返回完全相同),移动版看到的内容都在工具的返回里;活动详情、热点内容流、任务筛选、每日任务、创新任务这几个移动版接口暂未接入(参数未知,或当前账号没有内容可核对)。
|
|
98
115
|
- 几处上限是在服务端实测的:`rank_list` 和 `rank_subjects` 每页最多 20、`inspiration_list` 每页最多 50(100 会报错)、专题榜详情一次最多 20。移动版的「特效优秀视频榜」接口对所有榜单都返回空,没有提供。
|
|
99
116
|
- 审核记录:编辑器的「拍摄特效管理」(`/creator/v1/effect_list`)只有状态码,原因在像塑移动版的审核记录页(站内信「点击查看未过审原因」打开的 `effect.douyin.com/m/detail?showReviewList=1`)。工具按那个页面的方式取:「上线审核」先读 `review_nodes`(`review_type=1`),没有记录再读 `effect_reviews`;「精选审核」读 `review_nodes`(`review_type=2`)。2026-11-07 实测,被驳回的特效 `review_nodes` 不返回记录,原因来自 `effect_reviews`,如「特效不符合规范:特效中可能含有涉及展示或宣扬不同群体攻击对立类内容」。正文里的 `|<b>…<b>|`、`|<a><href>链接<href>文字<a>|` 等标记按页面的规则去掉,链接放进 `links`。分条原因 `refuse_reasons` 的结构取自页面代码,实测的特效还没带过。别人的特效和不存在的 ID,服务端一律报 `code=1301`(「参数不正确,请正确访问」)。
|
|
100
|
-
- `
|
|
117
|
+
- `my_effects` 翻页要把上一页返回的 `sort` 原样传回,`next_cursor` 就是它(传 `cursor` 或 `offset` 都只会拿到第一页,2026-11-07 实测)。服务端不给「还有没有」,工具按「这页满了就还有」判断,所以最后一页正好满页时 `has_more` 仍是 `true`,再翻一页得到空列表。每页上限 50 是拍的:每个未通过的特效要多一到两次请求。
|
|
101
118
|
- 只有作者分享到首页的特效才有工程可下载。排行榜的 `effect_id` 和首页作品的 `effect_id` 是同一套编号,`works_by_effect` 按 ID 精确匹配(与首页搜索框的「特效ID」搜索同一个接口,默认在「推荐」里查,首页在「官方工程」里不提供按 ID 搜)。按 ID 搜时「推荐」也能查到只出现在其它分类的作品(2026-11-07 实测 8 个全中,在它们自己的分类里按 ID 搜反而一个都查不到),所以不用跨分类查。
|
|
102
119
|
- 首页翻页除了 cursor 还要带上一页返回的 `sortingPosition` 和 `version`(编辑器首页就是这样翻的),只带 cursor 每一页都是第一页;`works_list` 的 `next_cursor` 把三者编在一起。按作品名搜索时,「推荐」翻到底只有约 300 条,「美化」「友友天地」等分类里还有它没有的(「头套」多 46 条、「美妆」多 87 条),所以 `works_search` 默认搜全部分类。服务端偶尔会提前结束一轮翻页(6 轮里有 1 轮停在 249 条),没到 300 条上限的分类会再翻一轮合并;服务端一直给同一页时停下,并把分类列在 `incomplete`。每个特效要一到两次请求(查不到 ID 且给了名字时再按名字搜一次),实测查一页 20 个用了约 10 秒。结果分三种:`found` 首页有这个特效的工程;`same_name` 首页没有它,只有同名作品,`effect_id` 不同,可能是别人的作品,不能当成同一个特效;`not_on_homepage` 作者没公开工程,没有正规途径能拿到(编辑器「我的特效」里的工程下载只对自己的特效开放)。2026-11-07 实测年轻喜爱榜第一页 20 个特效:10 个 `found`,1 个 `same_name`,9 个 `not_on_homepage`。
|
|
103
120
|
- 提交窗口是抖音特效平台的网页(`effect.douyin.com/ac/submit-orion`,每次在线加载,安装包里的离线版本较旧,字段也不同)。`submit_prepare` 按页面上的类名和文案找元素,页面改版后找不到时报 `SUBMIT_PAGE_CHANGED`,不会跳过。名称框会在页面的 `aiName` 配置请求回来时重新挂载,先填的内容会被清空(2026-11-07 实测,配置在表单出现约 1 秒后才回来),所以工具等这个请求完成再填,最后再用「提交审核」页的摘要核对一遍。灵感下拉只列当前账号收藏的灵感和热点,每次加载 10 条,不在列表里的用页面的搜索框找;选了和灵感所带任务不一致的任务时,页面会清掉灵感,工具会报 `SUBMIT_BINDING_NOT_APPLIED`。「特效发布设置」页上按账号出现的其它设置(活动、创新声明、作品授权)不填,列在 `other_sections`。
|
|
@@ -239,7 +239,7 @@ class Library {
|
|
|
239
239
|
return { panels: this.navEntries().filter((e) => e.applicable).map(({ applicable, ...e }) => e) };
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
async list({ panel_key, category_id, cursor, count =
|
|
242
|
+
async list({ panel_key, category_id, cursor, count = 20 }) {
|
|
243
243
|
this.ensureCompatible();
|
|
244
244
|
const panels = this.nav().panels;
|
|
245
245
|
const panel = panels.find((p) => p.panel_key === panel_key);
|
|
@@ -30,12 +30,19 @@ const LEVEL_LABELS = Object.fromEntries(Object.entries(RANK_FILTERS.levels.optio
|
|
|
30
30
|
const CATEGORY_PARAMS = { 1: 'material_labels3_first', 2: 'material_labels3_second', 3: 'material_labels3_third' };
|
|
31
31
|
// Innovation plan picks by artwork type (the app's ArtworkType index); the app itself shows templates.
|
|
32
32
|
const PICK_KINDS = { template: 2, effect: 0 };
|
|
33
|
+
// rank_innovation kinds: the creator month board, or the picks of one artwork type.
|
|
34
|
+
const INNOVATION_KINDS = ['creators', ...Object.keys(PICK_KINDS)];
|
|
33
35
|
// Topic collection tabs of the app's 专题合集 page (topic_type).
|
|
34
36
|
const SUBJECT_KINDS = { effect: 1, template: 2 };
|
|
35
37
|
// subjects and subject_detail answer code 1 for larger counts.
|
|
36
38
|
const SUBJECT_MAX = 20;
|
|
37
39
|
// The editor's task window page reads task details with this mobile app version.
|
|
38
40
|
const TASK_PAGE_APP_VERSION = '11.3.0';
|
|
41
|
+
// The 像塑 mobile app version whose endpoints growth_route reads (v17.7.0 Android package, 2026-11-08).
|
|
42
|
+
const MOBILE_APP_VERSION = '17.7.0';
|
|
43
|
+
// 成长之路 states, read off a live answer: the finished goal (1/1) was 1, the current level and its open goals
|
|
44
|
+
// 2, every later level 3.
|
|
45
|
+
const GROWTH_STATES = { 1: 'done', 2: 'in_progress', 3: 'locked' };
|
|
39
46
|
// Statuses the effect list page colours as failures (its 审核未通过, 测试未通过, 申诉审核未通过).
|
|
40
47
|
const FAILED_STATUSES = [101, 112, 119];
|
|
41
48
|
// The review record page's review types: 上线审核 and 精选审核.
|
|
@@ -115,10 +122,16 @@ function slimInspiration(i) {
|
|
|
115
122
|
collect_count: i.total_collection ?? null,
|
|
116
123
|
collected: !!i.is_collect,
|
|
117
124
|
ai: !!i.is_ai_ins,
|
|
125
|
+
hotspot: i.hotspot_data && i.hotspot_data.title ? { id: str(i.hotspot_data.id), title: i.hotspot_data.title } : null,
|
|
118
126
|
cover_url: first(i.cover_img && i.cover_img.urlList),
|
|
119
127
|
};
|
|
120
128
|
}
|
|
121
129
|
|
|
130
|
+
// The example videos an inspiration page plays: Douyin videos made from the idea.
|
|
131
|
+
function slimVideo(v) {
|
|
132
|
+
return { url: v.video_url || null, cover_url: v.video_img || null, author: v.video_username || null, likes: str(v.video_digg), width: v.width ?? null, height: v.height ?? null };
|
|
133
|
+
}
|
|
134
|
+
|
|
122
135
|
function tagNames(tags) {
|
|
123
136
|
if (typeof tags === 'string') return tags.split(',').filter(Boolean);
|
|
124
137
|
return (tags || []).map((t) => (t && t.name) || t).filter(Boolean);
|
|
@@ -136,6 +149,7 @@ function slimTask(lib, t, kind) {
|
|
|
136
149
|
title: t.title || t.name || '',
|
|
137
150
|
status: kind === 'task' ? lib.taskStatus(t.process_status) : null,
|
|
138
151
|
status_text: t.process_status_text || null,
|
|
152
|
+
status_desc: t.process_status_desc || null,
|
|
139
153
|
received: kind === 'task' ? !!t.designer_task_id : null,
|
|
140
154
|
bindable: !!bindId,
|
|
141
155
|
tags: tagNames(t.tags),
|
|
@@ -148,6 +162,88 @@ function slimTask(lib, t, kind) {
|
|
|
148
162
|
};
|
|
149
163
|
}
|
|
150
164
|
|
|
165
|
+
// An effect submitted to a task, as the task page lists it under 我的作品.
|
|
166
|
+
function slimTaskEffect(e) {
|
|
167
|
+
return {
|
|
168
|
+
effect_id: str(e.effect_id),
|
|
169
|
+
name: e.effect_name,
|
|
170
|
+
type: e.type_desc || null,
|
|
171
|
+
status: e.effect_status_desc || null,
|
|
172
|
+
status_code: e.effect_status ?? null,
|
|
173
|
+
fits_theme: e.is_fit_theme === 1,
|
|
174
|
+
track: e.sub_track_name || null,
|
|
175
|
+
shoots: str(e.shoot_num),
|
|
176
|
+
views: str(e.vv_num),
|
|
177
|
+
publish_peak: str(e.pub_peak_num),
|
|
178
|
+
award_amount: e.award_amount || null,
|
|
179
|
+
icon_url: first(e.icon && e.icon.url_list),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Task page text marks a link as $A$$HREF$url$HREF$$TEXT$label$TEXT$$A$.
|
|
184
|
+
const TASK_LINK = /\$A\$\$HREF\$(.*?)\$HREF\$\$TEXT\$(.*?)\$TEXT\$\$A\$/g;
|
|
185
|
+
// The lists a task content block holds its entries in (参与要求, 奖项详情, 近期热门, 任务说明 and the like).
|
|
186
|
+
const TASK_LISTS = ['demandList', 'awardList', 'inspirationList', 'baseList'];
|
|
187
|
+
|
|
188
|
+
function readTaskText(src, links) {
|
|
189
|
+
return String(src || '')
|
|
190
|
+
.replace(TASK_LINK, (_, url, label) => (links.push({ text: label, url }), label))
|
|
191
|
+
.trim();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// mediaType 1 marks mp4 videos; pictures come with 0 or none. Empty and blob: addresses do not show on
|
|
195
|
+
// the task page either, so they are only counted. Award amounts pass as the page sends them: no page
|
|
196
|
+
// code was found to tell their unit.
|
|
197
|
+
function taskItem(it) {
|
|
198
|
+
const links = [];
|
|
199
|
+
const out = {};
|
|
200
|
+
const title = readTaskText(it.tit, links);
|
|
201
|
+
const text = readTaskText(it.desc, links);
|
|
202
|
+
if (title) out.title = title;
|
|
203
|
+
if (text) out.text = text;
|
|
204
|
+
const urls = (it.source || []).map((s) => (s && typeof s.url === 'string' ? s.url : ''));
|
|
205
|
+
const media = urls.filter((u) => /^https?:\/\//.test(u));
|
|
206
|
+
if (media.length) out[it.mediaType === 1 ? 'videos' : 'images'] = media;
|
|
207
|
+
if (urls.length > media.length) out.unusable_media = urls.length - media.length;
|
|
208
|
+
if (it.money !== undefined) {
|
|
209
|
+
out.money = it.money;
|
|
210
|
+
out.money_mode = it.money_mode ?? null;
|
|
211
|
+
out.people = it.people_mode === 'infinite' ? 'unlimited' : (it.peope ?? null);
|
|
212
|
+
}
|
|
213
|
+
if (links.length) out.links = links;
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// One content block of the task page, read into its entries and links. Fields this reader does not
|
|
218
|
+
// know are kept as they came under `unread`, not dropped.
|
|
219
|
+
function taskBlock(b) {
|
|
220
|
+
const out = { name: b.contentBlockName || '' };
|
|
221
|
+
const links = [];
|
|
222
|
+
const unread = {};
|
|
223
|
+
for (const [key, v] of Object.entries(b)) {
|
|
224
|
+
if (key === 'type' || key === 'contentBlockName') continue;
|
|
225
|
+
if (TASK_LISTS.includes(key)) out.items = (v || []).map(taskItem).filter((x) => Object.keys(x).length);
|
|
226
|
+
else if (key === 'link' && v && v.url) links.push({ text: v.desc || '', url: v.url });
|
|
227
|
+
else if (key === 'statement' && v && v.link && v.link.url) links.push({ text: b.contentBlockName || '', url: v.link.url });
|
|
228
|
+
else if (key === 'recommendProject') out.project_ids = ((v && v.ids) || []).map(String);
|
|
229
|
+
else unread[key] = v;
|
|
230
|
+
}
|
|
231
|
+
if (links.length) out.links = links;
|
|
232
|
+
if (Object.keys(unread).length) out.unread = unread;
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function slimGrowthLevel(l) {
|
|
237
|
+
const level = { level: l.layer, name: l.layer_name, award_text: l.award || null, status: GROWTH_STATES[l.status] ?? l.status };
|
|
238
|
+
if (l.sub_tasks) {
|
|
239
|
+
level.goals = l.sub_tasks.flatMap((t) =>
|
|
240
|
+
(t.progresses || []).map((p) => ({ text: p.goal_text, current: p.curr_num, target: p.goal_num, reward_text: p.desc_text || null, status: GROWTH_STATES[t.status] ?? t.status })),
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
if (l.rights) level.rights = l.rights.flatMap((r) => (r.right_cards || []).map((c) => c.title));
|
|
244
|
+
return level;
|
|
245
|
+
}
|
|
246
|
+
|
|
151
247
|
// What the task detail window passes as launch extras when it opens a project for a task.
|
|
152
248
|
function activityExtra(lib, t, kind) {
|
|
153
249
|
const model = { ...t, display_type: EFFECT_ACTIVITY, task_type: kind === 'task' ? 'Normal' : 'Growup', id: kind === 'task' ? t.designer_task_id : t.id };
|
|
@@ -173,8 +269,8 @@ function slimRankItem(e, rank) {
|
|
|
173
269
|
icon_url: e.effect_icon || null,
|
|
174
270
|
level: LEVEL_LABELS[e.effect_lv] ?? null,
|
|
175
271
|
is_new: e.is_new_inc ?? null,
|
|
176
|
-
|
|
177
|
-
|
|
272
|
+
publish_peak: e.peak_pub_val ?? null,
|
|
273
|
+
publish_total: e.all_pub_val ?? null,
|
|
178
274
|
follow_shoot: e.follow_shoot_pub_val ?? null,
|
|
179
275
|
follow_shoot_30d: e.follow_shoot_pub_val_30d ?? null,
|
|
180
276
|
follow_shoot_60d: e.follow_shoot_pub_val60d ?? null,
|
|
@@ -266,7 +362,7 @@ function slimArtwork(e) {
|
|
|
266
362
|
can_delete: !!e.can_delete,
|
|
267
363
|
can_appeal: !!e.can_appeal,
|
|
268
364
|
appeal_types: (e.appeal_types || []).map((t) => t.appeal_type_text),
|
|
269
|
-
|
|
365
|
+
publish_count: e.pub_num ?? null,
|
|
270
366
|
icon_url: e.icon || null,
|
|
271
367
|
};
|
|
272
368
|
}
|
|
@@ -309,7 +405,7 @@ const methods = {
|
|
|
309
405
|
const d = await request(this, 'GET_INSPIRATIONS', '/creator_api/inspiration/v1/list', {
|
|
310
406
|
query: { flag: cursor === 0 ? 1 : 2, cursor, count, tab_name: name },
|
|
311
407
|
});
|
|
312
|
-
return { tab: name, items: (d.list || []).map(slimInspiration), next_cursor: d.cursor ?? null, has_more: !!d.has_more };
|
|
408
|
+
return { tab: name, tabs, items: (d.list || []).map(slimInspiration), next_cursor: d.cursor ?? null, has_more: !!d.has_more };
|
|
313
409
|
},
|
|
314
410
|
|
|
315
411
|
async inspirationCollected(id) {
|
|
@@ -343,11 +439,17 @@ const methods = {
|
|
|
343
439
|
bonus_text: base.bonus_text || null,
|
|
344
440
|
images: (base.imgs || []).map((i) => first(i.urlList)).filter(Boolean),
|
|
345
441
|
author: d.designer ? { uid: str(d.designer.uid), name: d.designer.name } : null,
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
442
|
+
// The award times come as numbers whose unit no live answer has shown yet (all were 0), so they pass as they are.
|
|
443
|
+
award:
|
|
444
|
+
d.award && d.award.amount
|
|
445
|
+
? { amount: d.award.amount, text: d.award.text || '', desc: d.award.desc || '', start_time: d.award.start_time ?? null, end_time: d.award.end_time ?? null, award_time: d.award.award_time ?? null, icon_url: d.award.icon_url || null }
|
|
446
|
+
: null,
|
|
447
|
+
hotspot: hot.title ? { id: str(hot.id), title: hot.title, score: str(hot.score), tags: hot.tags || [] } : null,
|
|
448
|
+
project: d.project_info && d.project_info.title ? { title: d.project_info.title, desc: d.project_info.desc || '', icon_url: d.project_info.icon || null } : null,
|
|
449
|
+
// Effects made from the idea; fields beyond name and total_pub_num pass through, none having been seen live yet.
|
|
450
|
+
effects: (d.effects || []).map(({ name, total_pub_num, ...rest }) => ({ name, published: total_pub_num ?? null, ...rest })),
|
|
451
|
+
videos: (d.videos || []).map(slimVideo),
|
|
452
|
+
stickers: d.stickers || [],
|
|
351
453
|
collected,
|
|
352
454
|
collect_count,
|
|
353
455
|
};
|
|
@@ -435,6 +537,7 @@ const methods = {
|
|
|
435
537
|
request(this, 'GET_EFFECT_TASK', '/effectcam/v2/effect_task_detail', { query }),
|
|
436
538
|
request(this, 'GET_EFFECT_TASK_CONTENT', '/effectcam/v2/effect_task_content', { query }),
|
|
437
539
|
]);
|
|
540
|
+
const modules = (c.modules || []).map((m) => JSON.parse(m.render_content));
|
|
438
541
|
return {
|
|
439
542
|
kind,
|
|
440
543
|
title: d.title,
|
|
@@ -445,7 +548,11 @@ const methods = {
|
|
|
445
548
|
reward_end: d.reward_end || null,
|
|
446
549
|
offline_at: iso(d.offline_at_unix),
|
|
447
550
|
can_finish_times: d.can_fin_times ?? null,
|
|
448
|
-
|
|
551
|
+
finish_status: d.fin_status || null,
|
|
552
|
+
level_task: !!d.is_level_task,
|
|
553
|
+
my_effects: (d.task_effect_list || []).map(slimTaskEffect),
|
|
554
|
+
content: modules.map(taskBlock),
|
|
555
|
+
raw: { detail: d, content: modules },
|
|
449
556
|
};
|
|
450
557
|
}
|
|
451
558
|
if (kind === 'growth') {
|
|
@@ -463,6 +570,15 @@ const methods = {
|
|
|
463
570
|
throw Error(`INVALID_KIND: ${kind}; valid: task, growth`);
|
|
464
571
|
},
|
|
465
572
|
|
|
573
|
+
// The mobile app's 成长之路: designer levels with their cash awards, each goal with its progress.
|
|
574
|
+
async growthRoute() {
|
|
575
|
+
const d = await request(this, 'GET_GROWTH_ROUTE', '/cam_api/designer/v6/growth_route', { query: { app_version: MOBILE_APP_VERSION } });
|
|
576
|
+
const entries = Array.isArray(d) ? d : [];
|
|
577
|
+
if (!entries.length) throw Error('NO_GROWTH_ROUTE: the 成长之路 answer has no levels');
|
|
578
|
+
const levels = entries.flatMap((e) => e.layer_task || []).map(slimGrowthLevel);
|
|
579
|
+
return { current_level: entries[0].cur_layer ?? null, levels };
|
|
580
|
+
},
|
|
581
|
+
|
|
466
582
|
// Same request as the activity center's 领取 button, which it only offers while the task waits to be received.
|
|
467
583
|
async taskReceive({ item_id } = {}) {
|
|
468
584
|
const id = requireId(item_id, 'INVALID_ITEM_ID');
|
|
@@ -485,18 +601,6 @@ const methods = {
|
|
|
485
601
|
return d.map((t) => ({ name: t.tagName, level: t.level, count: t.num }));
|
|
486
602
|
},
|
|
487
603
|
|
|
488
|
-
async rankNav({ rank_type = 1, date } = {}) {
|
|
489
|
-
const rt = rankType(rank_type);
|
|
490
|
-
checkDate(date);
|
|
491
|
-
const filters = Object.fromEntries(Object.entries(RANK_FILTERS).map(([key, f]) => [key, Object.keys(f.options)]));
|
|
492
|
-
return {
|
|
493
|
-
rank_types: Object.entries(RANK_TYPES).map(([k, name]) => ({ rank_type: Number(k), name })),
|
|
494
|
-
filters: { ...filters, young_like_scores: YOUNG_LIKE_SCORES },
|
|
495
|
-
rank_type: rt,
|
|
496
|
-
categories: await this.rankCategories(rt, date),
|
|
497
|
-
};
|
|
498
|
-
},
|
|
499
|
-
|
|
500
604
|
async rankList(params = {}) {
|
|
501
605
|
const { rank_type = 1, date, categories, young_like_scores, cursor = 0, count = 20 } = params;
|
|
502
606
|
const rt = rankType(rank_type);
|
|
@@ -509,8 +613,9 @@ const methods = {
|
|
|
509
613
|
for (const s of young_like_scores) if (!YOUNG_LIKE_SCORES.includes(s)) throw Error(`INVALID_FILTER(young_like_scores): ${s}; valid: 1-10`);
|
|
510
614
|
query.young_like_score = young_like_scores.join(',');
|
|
511
615
|
}
|
|
616
|
+
// The board's categories for that day go back with every page, for picking `categories` next time.
|
|
617
|
+
const known = await this.rankCategories(rt, date);
|
|
512
618
|
if (categories && categories.length) {
|
|
513
|
-
const known = await this.rankCategories(rt, date);
|
|
514
619
|
for (const name of categories) {
|
|
515
620
|
const hit = known.find((c) => c.name === name);
|
|
516
621
|
if (!hit) throw Error(`INVALID_CATEGORY: ${name}; valid: ${known.map((c) => c.name).join(', ')}`);
|
|
@@ -531,10 +636,12 @@ const methods = {
|
|
|
531
636
|
items: list.map((e, i) => slimRankItem(e, cursor + i + 1)),
|
|
532
637
|
next_cursor: d.cursor,
|
|
533
638
|
has_more: d.cursor < d.total,
|
|
639
|
+
categories: known,
|
|
534
640
|
};
|
|
535
641
|
},
|
|
536
642
|
|
|
537
|
-
|
|
643
|
+
// The board is one short list (79 hotspots, measured), read whole and paged here.
|
|
644
|
+
async rankHotspots({ offset = 0, count = 20, topic_id } = {}) {
|
|
538
645
|
if (topic_id !== undefined) {
|
|
539
646
|
const id = requireId(topic_id, 'INVALID_TOPIC_ID');
|
|
540
647
|
const d = await request(this, 'GET_HOTSPOT_INSPIRATIONS', '/cam_api/hotspot/v1/insp_tabs', { query: { topic_id: id } });
|
|
@@ -550,9 +657,9 @@ const methods = {
|
|
|
550
657
|
}));
|
|
551
658
|
return { topic_id: id, tabs };
|
|
552
659
|
}
|
|
553
|
-
const d = await request(this, 'GET_HOTSPOTS', '/cam_api/hotspot/v1/rank'
|
|
660
|
+
const d = await request(this, 'GET_HOTSPOTS', '/cam_api/hotspot/v1/rank');
|
|
554
661
|
// Hotspots arrive ordered by heat; rank_num is not their position.
|
|
555
|
-
const
|
|
662
|
+
const all = (d.hotspots || []).map((h, i) => ({
|
|
556
663
|
rank: i + 1,
|
|
557
664
|
topic_id: String(h.topic_id),
|
|
558
665
|
title: h.title,
|
|
@@ -562,7 +669,8 @@ const methods = {
|
|
|
562
669
|
inspirations_text: h.subtitle_text || null,
|
|
563
670
|
cover_url: first(h.cover && h.cover.urlList),
|
|
564
671
|
}));
|
|
565
|
-
|
|
672
|
+
const next = offset + count;
|
|
673
|
+
return { rank_time: d.rank_time || null, subtitle: d.subtitle || null, total: all.length, items: all.slice(offset, next), next_offset: next, has_more: next < all.length };
|
|
566
674
|
},
|
|
567
675
|
|
|
568
676
|
async subjectPage(kind, cursor, count) {
|
|
@@ -604,8 +712,8 @@ const methods = {
|
|
|
604
712
|
name: u.username,
|
|
605
713
|
avatar_url: u.avatar || null,
|
|
606
714
|
material_count: u.material_cnt ?? null,
|
|
607
|
-
|
|
608
|
-
|
|
715
|
+
follow_shoot: u.follow_pub_val ?? null,
|
|
716
|
+
follow_shoot_text: u.display_follow_pub ?? null,
|
|
609
717
|
award_text: u.display_val || null,
|
|
610
718
|
// fen: 300000 comes with 「预计奖3000元」
|
|
611
719
|
award_yuan: u.award_num != null ? u.award_num / 100 : null,
|
|
@@ -624,7 +732,7 @@ const methods = {
|
|
|
624
732
|
name: e.name,
|
|
625
733
|
icon_url: e.icon || null,
|
|
626
734
|
label: e.label || null,
|
|
627
|
-
|
|
735
|
+
publish_count: e.pub_val ?? null,
|
|
628
736
|
revenue_total: e.total_rev ?? null,
|
|
629
737
|
reviewed_on: e.review_date || null,
|
|
630
738
|
cover_url: e.cover_img || null,
|
|
@@ -634,6 +742,14 @@ const methods = {
|
|
|
634
742
|
return { kind, date: d.date || null, total: d.total, items, next_offset: offset + count, has_more: !!d.has_more };
|
|
635
743
|
},
|
|
636
744
|
|
|
745
|
+
// The creator board arrives whole; it is paged here like the picks.
|
|
746
|
+
async rankInnovation({ kind = 'template', offset = 0, count = 20 } = {}) {
|
|
747
|
+
if (!INNOVATION_KINDS.includes(kind)) throw Error(`INVALID_KIND: ${kind}; valid: ${INNOVATION_KINDS.join(', ')}`);
|
|
748
|
+
if (kind !== 'creators') return this.rankInnovationPicks({ kind, offset, count });
|
|
749
|
+
const { items } = await this.rankCreatorsMonth();
|
|
750
|
+
return { kind, total: items.length, items: items.slice(offset, offset + count), next_offset: offset + count, has_more: offset + count < items.length };
|
|
751
|
+
},
|
|
752
|
+
|
|
637
753
|
// The 上线审核 records of the review record page: review_nodes when it has them, otherwise effect_reviews.
|
|
638
754
|
async onlineReviews(id) {
|
|
639
755
|
const nodes = await send(this, 'GET_REVIEW_NODES', '/cam_api/effect/v1/review_nodes', { query: { effect_id: id, review_type: REVIEW_TYPES.online } });
|
|
@@ -642,7 +758,7 @@ const methods = {
|
|
|
642
758
|
},
|
|
643
759
|
|
|
644
760
|
// The mobile app's 作品 list, newest first. Pages chain through the `sort` key each page returns.
|
|
645
|
-
async
|
|
761
|
+
async myEffects({ cursor, count = 20 } = {}) {
|
|
646
762
|
const d = await request(this, 'GET_MY_EFFECTS', '/effectcam/v1/artworks', { query: { count, sort: cursor } });
|
|
647
763
|
const effects = d.effects || [];
|
|
648
764
|
const items = await Promise.all(
|
|
@@ -657,7 +773,7 @@ const methods = {
|
|
|
657
773
|
return { total: d.total, items, next_cursor: next, has_more: next !== null };
|
|
658
774
|
},
|
|
659
775
|
|
|
660
|
-
async
|
|
776
|
+
async myEffectReviews({ effect_id } = {}) {
|
|
661
777
|
const id = requireId(effect_id, 'INVALID_EFFECT_ID');
|
|
662
778
|
const [detail, online, innovation] = await Promise.all([
|
|
663
779
|
request(this, 'GET_EFFECT_DETAIL', '/effectcam/v2/effect_detail', { query: { effect_id: id } }),
|
|
@@ -679,22 +795,20 @@ const methods = {
|
|
|
679
795
|
};
|
|
680
796
|
|
|
681
797
|
const METHODS = {
|
|
682
|
-
inspiration_nav: 'inspirationNav',
|
|
683
798
|
inspiration_list: 'inspirationList',
|
|
684
799
|
inspiration_detail: 'inspirationDetail',
|
|
685
800
|
inspiration_collect: 'inspirationCollect',
|
|
686
801
|
inspiration_bind: 'inspirationBind',
|
|
802
|
+
growth_route: 'growthRoute',
|
|
687
803
|
tasks_list: 'tasksList',
|
|
688
804
|
task_detail: 'taskDetail',
|
|
689
805
|
task_receive: 'taskReceive',
|
|
690
|
-
rank_nav: 'rankNav',
|
|
691
806
|
rank_list: 'rankList',
|
|
692
807
|
rank_hotspots: 'rankHotspots',
|
|
693
808
|
rank_subjects: 'rankSubjects',
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
effect_reviews: 'effectReviews',
|
|
809
|
+
rank_innovation: 'rankInnovation',
|
|
810
|
+
my_effects: 'myEffects',
|
|
811
|
+
my_effect_reviews: 'myEffectReviews',
|
|
698
812
|
};
|
|
699
813
|
|
|
700
|
-
module.exports = { methods, METHODS,
|
|
814
|
+
module.exports = { methods, METHODS, INNOVATION_KINDS, SUBJECT_KINDS, RANK_TYPES, RANK_FILTERS };
|
|
@@ -48,11 +48,16 @@ const methods = {
|
|
|
48
48
|
return out;
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
// details adds each item's hover description and picture, which is one lookup per item, so it takes a
|
|
52
|
+
// query narrow enough to match at most MAX_MENU_PREVIEW items.
|
|
53
|
+
menuList({ query, details = false } = {}) {
|
|
52
54
|
const all = this.menuEntries();
|
|
53
55
|
const q = typeof query === 'string' ? query.trim().toLowerCase() : '';
|
|
54
56
|
const items = q ? all.filter((e) => `${e.path}/${e.name}/${e.menu_id}`.toLowerCase().includes(q)) : all;
|
|
55
|
-
return { total: all.length, items };
|
|
57
|
+
if (!details) return { total: all.length, items };
|
|
58
|
+
if (items.length > MAX_MENU_PREVIEW) throw Error(`MENU_DETAILS_TOO_MANY: ${items.length} items match; narrow the query to at most ${MAX_MENU_PREVIEW} for details`);
|
|
59
|
+
const tips = items.length ? this.menuPreview({ menu_ids: items.map((e) => e.menu_id) }) : [];
|
|
60
|
+
return { total: all.length, items: items.map((e, i) => ({ ...e, description: tips[i].description, image_url: tips[i].image_url, image_file: tips[i].image_file })) };
|
|
56
61
|
},
|
|
57
62
|
|
|
58
63
|
menuEntry(menu_id) {
|
|
@@ -119,6 +124,6 @@ const methods = {
|
|
|
119
124
|
},
|
|
120
125
|
};
|
|
121
126
|
|
|
122
|
-
const METHODS = { menu_list: 'menuList', menu_add: 'menuAdd'
|
|
127
|
+
const METHODS = { menu_list: 'menuList', menu_add: 'menuAdd' };
|
|
123
128
|
|
|
124
129
|
module.exports = { methods, METHODS, MENU_DENY, MAX_MENU_PREVIEW };
|
|
@@ -50,7 +50,7 @@ const methods = {
|
|
|
50
50
|
if (typeof query !== 'string' || !query.trim()) throw Error('INVALID_QUERY: query must be a non-empty string');
|
|
51
51
|
return { query: query.trim(), ...page(await withTimeout(list.getNextSearchMusicListForDouyin(query.trim()), 'search')) };
|
|
52
52
|
}
|
|
53
|
-
if (typeof category_code !== 'string' || !category_code) throw Error('INVALID_CATEGORY: pass category_code from
|
|
53
|
+
if (typeof category_code !== 'string' || !category_code) throw Error('INVALID_CATEGORY: pass category_code from music_list called without arguments, or query');
|
|
54
54
|
categories.setSelectedCategory({ codeCategory: category_code });
|
|
55
55
|
return { category_code, ...page(await withTimeout(list.getNextMusicListForDouyin(), 'list')) };
|
|
56
56
|
},
|
|
@@ -48,14 +48,19 @@ const methods = {
|
|
|
48
48
|
let frames = 0;
|
|
49
49
|
try {
|
|
50
50
|
await new Promise((resolve, reject) => {
|
|
51
|
-
const fail = (code, ms, what) => {
|
|
52
|
-
timer = setTimeout(() => reject(Error(`${code}: ${what} within ${ms} ms`)), ms);
|
|
51
|
+
const fail = (code, ms, what, advice) => {
|
|
52
|
+
timer = setTimeout(() => reject(Error(`${code}: ${what} within ${ms} ms${advice}`)), ms);
|
|
53
53
|
};
|
|
54
54
|
onReloaded = () => {
|
|
55
55
|
if (reloadedAt !== null) return;
|
|
56
56
|
reloadedAt = Date.now();
|
|
57
57
|
clearTimeout(timer);
|
|
58
|
-
fail(
|
|
58
|
+
fail(
|
|
59
|
+
'NO_FRESH_PREVIEW_FRAME',
|
|
60
|
+
frameTimeoutMs,
|
|
61
|
+
`the preview did not draw ${FRESH_FRAMES} frames after reloading`,
|
|
62
|
+
'; the preview video is most likely not playing (it stalls when its file is replaced while in use): switch to another video with set_preview_video, or close and reopen the project',
|
|
63
|
+
);
|
|
59
64
|
};
|
|
60
65
|
onTexture = () => {
|
|
61
66
|
if (reloadedAt === null) return;
|
|
@@ -64,7 +69,7 @@ const methods = {
|
|
|
64
69
|
};
|
|
65
70
|
PreviewSyncer.addListener(RELOADED, onReloaded);
|
|
66
71
|
bus.on(TEXTURE, onTexture);
|
|
67
|
-
fail('PREVIEW_RELOAD_TIMEOUT', reloadTimeoutMs, 'the preview did not reload');
|
|
72
|
+
fail('PREVIEW_RELOAD_TIMEOUT', reloadTimeoutMs, 'the preview did not reload', '; the window may be busy or stuck: check it, or close and reopen the project');
|
|
68
73
|
PreviewSyncer.getInstance().requestReloadSticker();
|
|
69
74
|
});
|
|
70
75
|
} finally {
|
|
@@ -20,7 +20,7 @@ const CACHE_ENTRIES = 20;
|
|
|
20
20
|
// term in the title (it matches loosely now and then) comes last.
|
|
21
21
|
const TIER = { exact: 0, prefix: 1, contains: 2, category: 3, server: 4 };
|
|
22
22
|
|
|
23
|
-
const NO_MATCH_HINT = '没有标题、面板名或子分类名对得上的素材:换更短或更具体的词(如「复古」而不是「复古风格滤镜」),用 queries 一次试几个近义词,或用
|
|
23
|
+
const NO_MATCH_HINT = '没有标题、面板名或子分类名对得上的素材:换更短或更具体的词(如「复古」而不是「复古风格滤镜」),用 queries 一次试几个近义词,或用 library_list 按面板和子分类浏览';
|
|
24
24
|
|
|
25
25
|
const norm = (s) => String(s || '').toLowerCase().replace(/\s+/g, '');
|
|
26
26
|
|
|
@@ -135,7 +135,7 @@ const methods = {
|
|
|
135
135
|
return { hits, expanded, related };
|
|
136
136
|
},
|
|
137
137
|
|
|
138
|
-
async search({ query, queries, panel_key, offset = 0, count =
|
|
138
|
+
async search({ query, queries, panel_key, offset = 0, count = 20 }) {
|
|
139
139
|
this.ensureCompatible();
|
|
140
140
|
const list = queries !== undefined ? queries : query !== undefined ? [query] : [];
|
|
141
141
|
if (query !== undefined && queries !== undefined) throw Error('INVALID_QUERY: pass query or queries, not both');
|