@yixiaoermail/cli 3.2.27 → 3.2.28
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/checksums.txt +6 -6
- package/package.json +1 -1
- package/references/cli/command-reference.md +1 -1
- package/references/domains/publish.md +1 -1
- package/references/get-collections.md +19 -12
- package/references/platforms/article/index.md +2 -1
- package/references/platforms/article/weixingongzhonghao-open.md +86 -0
- package/references/platforms/video/shipinhao.md +1 -0
- package/references/upload-resource.md +72 -72
- package/references/workflows/common-rules.md +291 -291
- package/schemas/platforms/weixin.account-open.article.schema.json +106 -0
- package/skills/yixiaoer/SKILL.md +1 -1
- package/skills/yixiaoer/references/cli/command-reference.md +1 -1
- package/skills/yixiaoer/references/domains/publish.md +1 -1
- package/skills/yixiaoer/references/get-collections.md +19 -12
- package/skills/yixiaoer/references/platforms/article/index.md +2 -1
- package/skills/yixiaoer/references/platforms/article/weixingongzhonghao-open.md +86 -0
- package/skills/yixiaoer/references/platforms/video/shipinhao.md +1 -0
- package/skills/yixiaoer/references/upload-resource.md +72 -72
- package/skills/yixiaoer/references/workflows/common-rules.md +291 -291
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "微信公众号 Open 文章平台表单 (Weixin Gongzhonghao Open Article Platform Form)",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"required": [
|
|
5
|
+
"articles",
|
|
6
|
+
"sendAll",
|
|
7
|
+
"sendIgnoreReprint"
|
|
8
|
+
],
|
|
9
|
+
"properties": {
|
|
10
|
+
"articles": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"minItems": 1,
|
|
13
|
+
"maxItems": 8,
|
|
14
|
+
"items": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"required": [
|
|
17
|
+
"title",
|
|
18
|
+
"content",
|
|
19
|
+
"cover"
|
|
20
|
+
],
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"properties": {
|
|
23
|
+
"title": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"minLength": 1
|
|
26
|
+
},
|
|
27
|
+
"author": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
},
|
|
30
|
+
"digest": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
},
|
|
33
|
+
"content": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"minLength": 1,
|
|
36
|
+
"maxLength": 20000
|
|
37
|
+
},
|
|
38
|
+
"contentSourceUrl": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"format": "uri"
|
|
41
|
+
},
|
|
42
|
+
"thumbUrl": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"format": "uri"
|
|
45
|
+
},
|
|
46
|
+
"cover": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"required": [
|
|
49
|
+
"key",
|
|
50
|
+
"raw"
|
|
51
|
+
],
|
|
52
|
+
"properties": {
|
|
53
|
+
"key": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"minLength": 1
|
|
56
|
+
},
|
|
57
|
+
"pathOrUrl": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"raw": {
|
|
61
|
+
"type": "object"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"needOpenComment": {
|
|
66
|
+
"type": "number",
|
|
67
|
+
"enum": [
|
|
68
|
+
0,
|
|
69
|
+
1
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"onlyFansCanComment": {
|
|
73
|
+
"type": "number",
|
|
74
|
+
"enum": [
|
|
75
|
+
0,
|
|
76
|
+
1
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"picCrop235": {
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"picCrop1": {
|
|
83
|
+
"type": "string"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"sendAll": {
|
|
89
|
+
"type": "number",
|
|
90
|
+
"enum": [
|
|
91
|
+
0,
|
|
92
|
+
1
|
|
93
|
+
],
|
|
94
|
+
"default": 0
|
|
95
|
+
},
|
|
96
|
+
"sendIgnoreReprint": {
|
|
97
|
+
"type": "number",
|
|
98
|
+
"enum": [
|
|
99
|
+
0,
|
|
100
|
+
1
|
|
101
|
+
],
|
|
102
|
+
"default": 0
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"additionalProperties": false
|
|
106
|
+
}
|
package/skills/yixiaoer/SKILL.md
CHANGED
|
@@ -82,7 +82,7 @@ yxer query taobao-guanghe-goods-tabs <account_id> --type video|imageText
|
|
|
82
82
|
yxer query taobao-guanghe-goods <account_id> --type video|imageText --source SOURCE [--filter-value VALUE] [--second-filter-value VALUE] [--query 关键词] [--next-page TOKEN]
|
|
83
83
|
yxer query goods-detail <account_id> --url <product_url>
|
|
84
84
|
yxer query entitlements <account_id>
|
|
85
|
-
yxer query collections <account_id> [--type video|article]
|
|
85
|
+
yxer query collections <account_id> [--type video|article] [--next-page TOKEN]
|
|
86
86
|
yxer query drama-tasks <account_id> [--query 关键词] [--keyword 关键词]
|
|
87
87
|
yxer query members [--page 1] [--size 10] [--status notJoined|pending|joined] [--query 关键词] [--role master|admin|member]
|
|
88
88
|
yxer query friends <account_id> [--red-id 小红书号] [--query 关键词]
|
|
@@ -61,7 +61,7 @@ yxer query locations <account_id> [--query 关键词] [--next-page TOKEN]
|
|
|
61
61
|
yxer query music <account_id> [--query 关键词] [--category-id ID] [--category-name 名称] [--next-page TOKEN]
|
|
62
62
|
yxer query music-categories <account_id>
|
|
63
63
|
yxer query goods <account_id> [--query 关键词] [--next-page TOKEN]
|
|
64
|
-
yxer query collections <account_id> [--type video|article]
|
|
64
|
+
yxer query collections <account_id> [--type video|article] [--next-page TOKEN]
|
|
65
65
|
yxer query drama-tasks <account_id> [--query 关键词]
|
|
66
66
|
yxer query miniapps <account_id> [--query 关键词]
|
|
67
67
|
yxer query syncapps <account_id>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# 获取合集列表 (Get Collections)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
获取账号已创建的合集列表。主要用于抖音、小红书、视频号、今日头条等支持合集的平台。
|
|
4
4
|
|
|
5
5
|
## 调用指令 (Command)
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
yxer query collections ACCOUNT_ID --json
|
|
8
|
+
yxer query collections ACCOUNT_ID [--type video|article] [--next-page TOKEN] --json
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## 参数列表 (Payload Properties)
|
|
@@ -13,22 +13,29 @@ yxer query collections ACCOUNT_ID --json
|
|
|
13
13
|
| 字段名 | 类型 | 是否必填 | 说明 |
|
|
14
14
|
| :--- | :--- | :--- | :--- |
|
|
15
15
|
| `account_id` | `string` | **是** | 蚁小二账号 ID (32位十六进制) |
|
|
16
|
+
| `--type` | `string` | 否 | 发布类型,默认 `video` |
|
|
17
|
+
| `--next-page` | `string` | 否 | 上一页响应中的不透明分页游标 |
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
返回分页对象。发布时必须直接使用 `list` 中查询返回的完整合集对象作为视频表单的 `contentPublishForm.collection` 参数传递给发布流程,不能只保留 ID、名称或 `raw` 的局部字段。存在 `nextPage` 时,将它原样传给下一次查询。
|
|
20
|
+
|
|
21
|
+
当接口省略 `raw` 时,CLI 会将该合集的完整原始查询项保存在 `raw` 中;接口已有的 `raw` 会原样保留,分页游标和其他返回字段也会保留。
|
|
18
22
|
|
|
19
23
|
```json
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
{
|
|
25
|
+
"list": [
|
|
26
|
+
{
|
|
27
|
+
"yixiaoerId": "col_123",
|
|
28
|
+
"yixiaoerName": "美食系列",
|
|
29
|
+
"raw": { ... }
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"nextPage": "opaque-cursor"
|
|
33
|
+
}
|
|
27
34
|
```
|
|
28
35
|
|
|
29
36
|
## CLI / 后端逻辑
|
|
30
37
|
|
|
31
|
-
- **CLI 命令**: `yxer query collections <account_id> [--type video|article] [--json]`
|
|
38
|
+
- **CLI 命令**: `yxer query collections <account_id> [--type video|article] [--next-page TOKEN] [--json]`
|
|
32
39
|
- **功能**: 封装蚁小二标准化合集查询接口 (`GET /platform-accounts/{platformAccountId}/collections`)。
|
|
33
|
-
- **参数映射**: 将 `account_id` 映射为 URL 路径变量,将 `type` 映射为 `publishType` 查询参数。
|
|
40
|
+
- **参数映射**: 将 `account_id` 映射为 URL 路径变量,将 `type` 映射为 `publishType`、`next-page` 映射为 `nextPage` 查询参数。
|
|
34
41
|
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
- 正文内嵌图片也建议先行上传获取 Key(视频号卡片、公众号卡片同理)。
|
|
20
20
|
3. **平台策略分配**:
|
|
21
21
|
- **微信公众号**:必须单独发布,推荐使用 `platformForms` 结构。
|
|
22
|
+
- **微信公众号-Open**:必须使用 Open 专用 `platformForms` 结构;CLI 会在发布时转换为蚁小二 wx/publish 请求,不走通用 /taskSets/v2。
|
|
22
23
|
- **通用平台**(知乎、简书等):使用 `accountForms` 结构进行分发。
|
|
23
24
|
4. **参数装配**:注入 `action: "publish"` 及其余 DTO 字段。
|
|
24
25
|
5. **指令执行**:先执行 `yxer validate <platform> article <payload.json>`,再执行 `yxer publish article <platform> <payload.json> [--publish-channel local --client-id <clientId>]`。
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
> [!IMPORTANT]
|
|
75
76
|
> **配置架构约束**:
|
|
76
77
|
> - **微信公众号专用性**: **微信公众号必须单独发布**。在一个发布请求中,如果包含微信公众号,则不能包含其他任何平台;反之亦然。
|
|
77
|
-
> - **platformForms**:
|
|
78
|
+
> - **platformForms**: **仅限微信公众号及微信公众号-Open 使用**。
|
|
78
79
|
> - **优先级**: 后端将优先尝试从 `platformForms` 中获取对应平台的配置,若不存在则回退至账号级的 `contentPublishForm`。
|
|
79
80
|
|
|
80
81
|
> [!TIP]
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# 微信公众号-Open 文章发布参数 (WeiXinGongZhongHao-Open Article)
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **这是微信公众号 Open 的独立发布契约。** CLI 使用 POST /wx/publish,不使用普通微信公众号文章的 /taskSets/v2 请求体。
|
|
5
|
+
|
|
6
|
+
## 1. 执行约束
|
|
7
|
+
|
|
8
|
+
- 发布类型仅支持 article。
|
|
9
|
+
- 目标平台使用 微信公众号-Open,必须单平台执行。
|
|
10
|
+
- 只支持直接发布;不支持 isDraft=true、平台草稿、定时发布和 --publish-channel local。
|
|
11
|
+
- Open 请求支持多个 platformAccountIds,所有账号共用同一组 articles。
|
|
12
|
+
- 发布前封面必须是通过 yxer upload 得到的资源对象。CLI 会优先使用封面对象中的 url/pathOrUrl,只有存在 key 时才调用 stable-url 查询,并将最终 URL 写入 articles[].thumbUrl。
|
|
13
|
+
|
|
14
|
+
## 2. 标准 CLI Payload
|
|
15
|
+
|
|
16
|
+
业务字段放在 publishArgs.platformForms["微信公众号-Open"],账号只放在 publishArgs.accountForms[]:
|
|
17
|
+
|
|
18
|
+
~~~
|
|
19
|
+
{
|
|
20
|
+
"action": "publish",
|
|
21
|
+
"publishType": "article",
|
|
22
|
+
"platforms": ["微信公众号-Open"],
|
|
23
|
+
"publishChannel": "cloud",
|
|
24
|
+
"publishArgs": {
|
|
25
|
+
"accountForms": [
|
|
26
|
+
{ "platformAccountId": "wx-open-account-001" }
|
|
27
|
+
],
|
|
28
|
+
"platformForms": {
|
|
29
|
+
"微信公众号-Open": {
|
|
30
|
+
"sendAll": 0,
|
|
31
|
+
"sendIgnoreReprint": 0,
|
|
32
|
+
"articles": [
|
|
33
|
+
{
|
|
34
|
+
"title": "文章标题",
|
|
35
|
+
"author": "作者",
|
|
36
|
+
"digest": "文章摘要",
|
|
37
|
+
"content": "<p>HTML 正文</p>",
|
|
38
|
+
"contentSourceUrl": "https://example.com/source",
|
|
39
|
+
"cover": {
|
|
40
|
+
"key": "uploaded-cover-key",
|
|
41
|
+
"pathOrUrl": "https://oss-v2.yixiaoer.cn/cover.jpg",
|
|
42
|
+
"raw": {}
|
|
43
|
+
},
|
|
44
|
+
"needOpenComment": 1,
|
|
45
|
+
"onlyFansCanComment": 0
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
~~~
|
|
53
|
+
|
|
54
|
+
sendAll 和 sendIgnoreReprint 省略时均默认为 0。cover 必须包含 key 和 raw;若没有蚁小二稳定 URL,CLI 会根据 cover.bucket(省略时使用 cloud-publish)查询稳定地址。
|
|
55
|
+
|
|
56
|
+
## 3. 与蚁小二 Open 请求的映射
|
|
57
|
+
|
|
58
|
+
CLI 发布时生成以下官方请求:
|
|
59
|
+
|
|
60
|
+
| CLI 字段 | POST /wx/publish 字段 |
|
|
61
|
+
| :--- | :--- |
|
|
62
|
+
| 根级 publishChannel(固定为 cloud) | publishChannel |
|
|
63
|
+
| accountForms[].platformAccountId | platformAccountIds[] |
|
|
64
|
+
| platformForms.sendAll | sendAll |
|
|
65
|
+
| platformForms.sendIgnoreReprint | sendIgnoreReprint |
|
|
66
|
+
| 首篇 cover.key 或根级 coverKey | coverKey |
|
|
67
|
+
| 根级 desc、首篇标题或摘要 | desc |
|
|
68
|
+
| articles[].title | articles[].title |
|
|
69
|
+
| articles[].author | articles[].author |
|
|
70
|
+
| articles[].digest | articles[].digest |
|
|
71
|
+
| articles[].content | articles[].content |
|
|
72
|
+
| articles[].contentSourceUrl | articles[].contentSourceUrl |
|
|
73
|
+
| articles[].cover 的稳定 URL | articles[].thumbUrl |
|
|
74
|
+
| articles[].needOpenComment | articles[].needOpenComment |
|
|
75
|
+
| articles[].onlyFansCanComment | articles[].onlyFansCanComment |
|
|
76
|
+
|
|
77
|
+
正文中的外链图片仍按文章发布通用规则先转存到稳定地址;Open 后端会继续使用 thumbUrl 和正文资源创建草稿并提交发布。
|
|
78
|
+
|
|
79
|
+
## 4. 推荐命令
|
|
80
|
+
|
|
81
|
+
~~~
|
|
82
|
+
yxer upload <cover-path> --bucket cloud-publish
|
|
83
|
+
yxer validate 微信公众号-Open article <payload.json>
|
|
84
|
+
yxer publish article 微信公众号-Open <payload.json> --dry-run
|
|
85
|
+
yxer publish article 微信公众号-Open <payload.json>
|
|
86
|
+
~~~
|
|
@@ -126,6 +126,7 @@ yxer publish form account publish-form.json --id <online_account_id>
|
|
|
126
126
|
| 目标数据 | 对应 Action | 文档参考 |
|
|
127
127
|
| :--- | :--- | :--- |
|
|
128
128
|
| `location` | `locations` | [获取位置信息](../../get-locations.md) |
|
|
129
|
+
| `collection` | `collections` | [获取合集列表](../../get-collections.md) |
|
|
129
130
|
| `activity` | `activities` | [获取活动列表](../../get-publish-activities.md) |
|
|
130
131
|
| `shopping_cart`| `goods` | [获取商品列表](../../get-goods.md) |
|
|
131
132
|
| `drama` | `drama-tasks` | [获取视频号剧集列表](../../get-drama-tasks.md) |
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
# 上传资源 (Upload Resource)
|
|
2
|
-
|
|
3
|
-
将图片、视频或其它素材上传至蚁小二云端存储 (OSS),并获取用于发布的资源 Key。这是自动化发布的前置步骤。
|
|
4
|
-
|
|
5
|
-
## 触发场景 (Trigger)
|
|
6
|
-
- **意图辨析**:当用户提供原始 URL 或本地路径,并准备进行发布 (publish) 或存入素材库 (material) 之前,必须先将资源“物理上传”以获得系统可识别的 Key。
|
|
7
|
-
- **典型提示词**:
|
|
8
|
-
- “把这个视频传上去”
|
|
9
|
-
- “准备发布,上传封面图”
|
|
10
|
-
- “获取这个短剧资源的 Key”
|
|
11
|
-
|
|
12
|
-
> [!IMPORTANT]
|
|
13
|
-
> **素材库上传特殊说明**: 当用户明确要求“上传到素材库”时,这只是第一步 (`upload`),完成后**必须**紧接着执行第二步 (`material`) 登记入库,否则上传仅停留在临时 OSS 空间。
|
|
14
|
-
|
|
15
|
-
## 参数定义 (Parameters)
|
|
16
|
-
|
|
17
|
-
### 参数列表 (Payload Properties)
|
|
18
|
-
|
|
19
|
-
| 字段名 | 类型 | 是否必填 | 描述 |
|
|
20
|
-
| :--- | :--- | :--- | :--- |
|
|
21
|
-
| `action` | `string` | **是** | 固定值:`upload` |
|
|
22
|
-
| `url` | `string` | **是** | 资源的远程 URL 或本地绝对路径 |
|
|
23
|
-
| `bucket` | `string` | **否** | OSS 存储桶。默认 `cloud-publish`;若后续要调用素材库 `action: "material"`,必须使用 `material-library` |
|
|
24
|
-
| `contentType` | `string` | **是** | 资源的 MIME 类型 (如 `video/mp4`, `image/png`)。**严格要求**: 请求预签名 URL 时声明的 `contentType` 必须与执行 PUT 上传时 Header 中的 `Content-Type` **完全一致**。 |
|
|
25
|
-
| `size` | `number` | 否 | 资源大小 (字节)。 |
|
|
26
|
-
|
|
27
|
-
## 执行逻辑 (Logic Flow)
|
|
28
|
-
1. **源检测**:识别 URL 是远程地址还是本地物理路径。
|
|
29
|
-
2. **目标桶确认**:根据用户是否提到“素材库”决定 `bucket`(`cloud-publish` vs `material-library`)。
|
|
30
|
-
3. **类型嗅探**:尝试根据后缀名自动推断 `contentType`,若失败则提示用户或使用通用流类型。
|
|
31
|
-
4. **指令执行**:调用 `yxer upload <file_path_or_url> [--bucket cloud-publish|material-library]`。
|
|
32
|
-
5. **Key 提取**:获取返回的 `key`,并作为后续发布 Payload 的输入(如 `coverKey`, `video.key`)。
|
|
33
|
-
|
|
34
|
-
视频在上传前会由 CLI 使用 FFmpeg 完整解码视频和音频帧;本地文件在读取期间发生变化、远程地址只返回部分内容、文件损坏或截断时,CLI 会返回结构化错误并停止上传。请确保 `ffmpeg` 可从 `PATH` 找到;如需自动提取视频宽高和时长,再传 `--auto-meta` 并确保 `ffprobe` 可用。
|
|
35
|
-
|
|
36
|
-
> [!IMPORTANT]
|
|
37
|
-
> **视频号 512KB 图片限制**:
|
|
38
|
-
> 上传视频号视频封面或视频号图文图片时,必须带平台用途参数:
|
|
39
|
-
> `yxer upload <图片路径或URL> --platform 视频号 --usage cover` 或 `--usage image`。
|
|
40
|
-
> 当图片超过 512KB 时,CLI 会在内部压缩后再上传,并在 JSON 返回中标记 `compressed: true`、`originalSize` 和压缩后的 `size`;后续 payload 必须使用这次上传返回的完整对象。
|
|
41
|
-
|
|
42
|
-
> [!IMPORTANT]
|
|
43
|
-
> **Instagram / Meta 兼容性**:
|
|
44
|
-
> 若后续要发 Instagram 视频,原视频文件名不要使用中文、空格或其它非 ASCII 字符。Meta 会主动回拉蚁小二返回的媒体 URL;若 URL 路径中带中文,Meta 下载器可能直接返回 HTTP 400,导致“创建发布容器失败 / The media could not be fetched from the provided URI”。
|
|
45
|
-
|
|
46
|
-
## 输出结果 (Output)
|
|
47
|
-
|
|
48
|
-
输出生成的资源标识,供发布脚本引用:
|
|
49
|
-
```json
|
|
50
|
-
{
|
|
51
|
-
"key": "cloud-publish/2026/03/26/66b2xxx/xxx.jpg",
|
|
52
|
-
"name": "xxx.jpg",
|
|
53
|
-
"bucket": "cloud-publish"
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
**注意**: 封面/媒体字段使用返回对象中的 `key`;如果资源要出现在 HTML `<img src>` 中,不能把裸 `key` 当成浏览器地址,必须通过文章导入/正文图片物化流程换成稳定 URL。
|
|
57
|
-
|
|
58
|
-
## 调用指令 (Command)
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
yxer upload https://example.com/image.jpg --bucket cloud-publish
|
|
62
|
-
yxer upload ./cover.png --platform 视频号 --usage cover
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
> [!IMPORTANT]
|
|
66
|
-
> **发布合规性提醒**:
|
|
67
|
-
> 所有的封面图、图文图片、视频文件均**严禁直接使用外部网络 URL**,必须通过本项目提供的上传接口进行处理并获取 `key` 后进行发布。不遵守此规范将直接导致任务失败。
|
|
68
|
-
|
|
69
|
-
> [!CAUTION]
|
|
70
|
-
> **ContentType 签名一致性**:
|
|
71
|
-
> 在上传资源时,必须确保获取上传地址所传入的 `contentType` 参数与 PUT 请求实际发送的 `Content-Type` Header **完全一致**。
|
|
72
|
-
|
|
1
|
+
# 上传资源 (Upload Resource)
|
|
2
|
+
|
|
3
|
+
将图片、视频或其它素材上传至蚁小二云端存储 (OSS),并获取用于发布的资源 Key。这是自动化发布的前置步骤。
|
|
4
|
+
|
|
5
|
+
## 触发场景 (Trigger)
|
|
6
|
+
- **意图辨析**:当用户提供原始 URL 或本地路径,并准备进行发布 (publish) 或存入素材库 (material) 之前,必须先将资源“物理上传”以获得系统可识别的 Key。
|
|
7
|
+
- **典型提示词**:
|
|
8
|
+
- “把这个视频传上去”
|
|
9
|
+
- “准备发布,上传封面图”
|
|
10
|
+
- “获取这个短剧资源的 Key”
|
|
11
|
+
|
|
12
|
+
> [!IMPORTANT]
|
|
13
|
+
> **素材库上传特殊说明**: 当用户明确要求“上传到素材库”时,这只是第一步 (`upload`),完成后**必须**紧接着执行第二步 (`material`) 登记入库,否则上传仅停留在临时 OSS 空间。
|
|
14
|
+
|
|
15
|
+
## 参数定义 (Parameters)
|
|
16
|
+
|
|
17
|
+
### 参数列表 (Payload Properties)
|
|
18
|
+
|
|
19
|
+
| 字段名 | 类型 | 是否必填 | 描述 |
|
|
20
|
+
| :--- | :--- | :--- | :--- |
|
|
21
|
+
| `action` | `string` | **是** | 固定值:`upload` |
|
|
22
|
+
| `url` | `string` | **是** | 资源的远程 URL 或本地绝对路径 |
|
|
23
|
+
| `bucket` | `string` | **否** | OSS 存储桶。默认 `cloud-publish`;若后续要调用素材库 `action: "material"`,必须使用 `material-library` |
|
|
24
|
+
| `contentType` | `string` | **是** | 资源的 MIME 类型 (如 `video/mp4`, `image/png`)。**严格要求**: 请求预签名 URL 时声明的 `contentType` 必须与执行 PUT 上传时 Header 中的 `Content-Type` **完全一致**。 |
|
|
25
|
+
| `size` | `number` | 否 | 资源大小 (字节)。 |
|
|
26
|
+
|
|
27
|
+
## 执行逻辑 (Logic Flow)
|
|
28
|
+
1. **源检测**:识别 URL 是远程地址还是本地物理路径。
|
|
29
|
+
2. **目标桶确认**:根据用户是否提到“素材库”决定 `bucket`(`cloud-publish` vs `material-library`)。
|
|
30
|
+
3. **类型嗅探**:尝试根据后缀名自动推断 `contentType`,若失败则提示用户或使用通用流类型。
|
|
31
|
+
4. **指令执行**:调用 `yxer upload <file_path_or_url> [--bucket cloud-publish|material-library]`。
|
|
32
|
+
5. **Key 提取**:获取返回的 `key`,并作为后续发布 Payload 的输入(如 `coverKey`, `video.key`)。
|
|
33
|
+
|
|
34
|
+
视频在上传前会由 CLI 使用 FFmpeg 完整解码视频和音频帧;本地文件在读取期间发生变化、远程地址只返回部分内容、文件损坏或截断时,CLI 会返回结构化错误并停止上传。请确保 `ffmpeg` 可从 `PATH` 找到;如需自动提取视频宽高和时长,再传 `--auto-meta` 并确保 `ffprobe` 可用。
|
|
35
|
+
|
|
36
|
+
> [!IMPORTANT]
|
|
37
|
+
> **视频号 512KB 图片限制**:
|
|
38
|
+
> 上传视频号视频封面或视频号图文图片时,必须带平台用途参数:
|
|
39
|
+
> `yxer upload <图片路径或URL> --platform 视频号 --usage cover` 或 `--usage image`。
|
|
40
|
+
> 当图片超过 512KB 时,CLI 会在内部压缩后再上传,并在 JSON 返回中标记 `compressed: true`、`originalSize` 和压缩后的 `size`;后续 payload 必须使用这次上传返回的完整对象。
|
|
41
|
+
|
|
42
|
+
> [!IMPORTANT]
|
|
43
|
+
> **Instagram / Meta 兼容性**:
|
|
44
|
+
> 若后续要发 Instagram 视频,原视频文件名不要使用中文、空格或其它非 ASCII 字符。Meta 会主动回拉蚁小二返回的媒体 URL;若 URL 路径中带中文,Meta 下载器可能直接返回 HTTP 400,导致“创建发布容器失败 / The media could not be fetched from the provided URI”。
|
|
45
|
+
|
|
46
|
+
## 输出结果 (Output)
|
|
47
|
+
|
|
48
|
+
输出生成的资源标识,供发布脚本引用:
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"key": "cloud-publish/2026/03/26/66b2xxx/xxx.jpg",
|
|
52
|
+
"name": "xxx.jpg",
|
|
53
|
+
"bucket": "cloud-publish"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
**注意**: 封面/媒体字段使用返回对象中的 `key`;如果资源要出现在 HTML `<img src>` 中,不能把裸 `key` 当成浏览器地址,必须通过文章导入/正文图片物化流程换成稳定 URL。
|
|
57
|
+
|
|
58
|
+
## 调用指令 (Command)
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
yxer upload https://example.com/image.jpg --bucket cloud-publish
|
|
62
|
+
yxer upload ./cover.png --platform 视频号 --usage cover
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
> [!IMPORTANT]
|
|
66
|
+
> **发布合规性提醒**:
|
|
67
|
+
> 所有的封面图、图文图片、视频文件均**严禁直接使用外部网络 URL**,必须通过本项目提供的上传接口进行处理并获取 `key` 后进行发布。不遵守此规范将直接导致任务失败。
|
|
68
|
+
|
|
69
|
+
> [!CAUTION]
|
|
70
|
+
> **ContentType 签名一致性**:
|
|
71
|
+
> 在上传资源时,必须确保获取上传地址所传入的 `contentType` 参数与 PUT 请求实际发送的 `Content-Type` Header **完全一致**。
|
|
72
|
+
|