feat: 同步 Media CLI 对标素材与文件管理更新
同步 LightCore d14de92a4 中的 CLI 变更。
This commit is contained in:
+103
-21
@@ -11,6 +11,7 @@ ENUMS = {
|
||||
"matchMode": ("all", "any"),
|
||||
"role": ("owner", "admin"),
|
||||
"status": ("enabled", "disabled"),
|
||||
"priority": ("hard_deadline", "blocks_followup", "scheduled", "when_available"),
|
||||
"mode": ("omni_reference", "first_last_frame"),
|
||||
"frameRole": ("reference", "first", "last"),
|
||||
}
|
||||
@@ -24,10 +25,18 @@ DESCRIPTIONS = {
|
||||
"pageNo": "页码,从 1 开始",
|
||||
"pageSize": "每页条数,范围 1–100",
|
||||
"keyword": "搜索关键词",
|
||||
"videoFileUrl": "采集得到的视频文件地址,省略时保留现有地址。",
|
||||
"audioFileUrl": "采集得到的音频文件地址,省略时保留现有地址。",
|
||||
"excludeKeyword": "排除关键词,多个词用空格分隔",
|
||||
"searchScope": "搜索范围,all 为标题和正文,默认 all",
|
||||
"matchMode": "多词匹配方式,all 为全部命中,默认 all",
|
||||
"isValid": "社媒账号是否有效",
|
||||
"priority": "备忘优先级。hard_deadline 需要截止时间。",
|
||||
"assessment": "人工选题评估。high / medium / low 对应 A / B / C。",
|
||||
"referencePoints": "本次保存的全部参考点。空数组清空。",
|
||||
"topicNotes": "人工填写的选题备注。空字符串清空。",
|
||||
"forTopicSelection": "只返回 A、B 和评估完整的 C 档,按评估等级排序。",
|
||||
"relatedMemoIds": "关联的 Media 备忘 ID。更新时省略保留,空数组清空。",
|
||||
"bodyMarkdown": "Markdown 正文。",
|
||||
"durationSeconds": "生成时长,1–3600 秒,新建默认 10 秒。",
|
||||
"referenceImages": "参考图数组。修改时提交希望保留的完整数组。",
|
||||
@@ -40,9 +49,16 @@ DESCRIPTIONS = {
|
||||
"sourceKeys": "对应当前稿件 researchSources 内的 key。",
|
||||
"documents": "项目文档关联数组。required 指定是否为本项目必读。",
|
||||
"clientSecret": "Media 存储客户端密钥,使用私有输入文件。",
|
||||
"folderId": "文件夹 ID,0 表示根目录。",
|
||||
"dueAt": "截止时刻,使用带时区的 RFC3339。空字符串清除。",
|
||||
"remindAt": "具体提醒时刻,使用带时区的 RFC3339。空字符串清除提醒及按天设置。",
|
||||
"remindDaysBefore": "按北京时间在截止前 N 天提醒,和 remindAt 二选一。",
|
||||
"textContent": "文件的纯文本内容,例如 OCR 结果。空字符串清除。",
|
||||
}
|
||||
|
||||
ARRAY_OBJECTS = {
|
||||
"transcriptSegments": ("start_ms end_ms text", "start_ms end_ms text"),
|
||||
"files": ("fileId expectedUpdatedAt", "fileId expectedUpdatedAt"),
|
||||
"referenceImages": ("key name purpose prompt resourceIds referenceFileIds fileId frameRole", "name"),
|
||||
"documents": ("documentId required", "documentId"),
|
||||
"imageDetails": ("fileId text prompt referenceFileIds notes", "fileId"),
|
||||
@@ -58,11 +74,9 @@ CASES = {
|
||||
"update": "requestId accountKey platform accountName isValid expectedUpdatedAt",
|
||||
},
|
||||
"saveContent": {"create": "requestId contentType title", "update": "requestId contentId expectedUpdatedAt"},
|
||||
"saveReference": {
|
||||
"create": "requestId platform contentType creatorName title",
|
||||
"update": "requestId referenceId platform contentType creatorName title expectedUpdatedAt",
|
||||
},
|
||||
"saveDocument": {"create": "requestId title", "update": "requestId documentId expectedUpdatedAt"},
|
||||
"saveMemo": {"create": "requestId title", "update": "requestId memoId expectedUpdatedAt"},
|
||||
"saveFolder": {"create": "requestId name", "update": "requestId folderId expectedUpdatedAt"},
|
||||
"saveProject": {"create": "requestId name", "update": "requestId projectId expectedUpdatedAt"},
|
||||
"saveEpisode": {"create": "requestId projectId name", "update": "requestId episodeId expectedUpdatedAt"},
|
||||
"saveResource": {"create": "requestId projectId name type", "update": "requestId resourceId expectedUpdatedAt"},
|
||||
@@ -76,6 +90,9 @@ REQUIRED = {
|
||||
"setAccountValidity": "accountKey requestId isValid expectedUpdatedAt",
|
||||
"saveImageDetail": "contentId requestId expectedUpdatedAt fileId",
|
||||
"deleteReference": "referenceId requestId expectedUpdatedAt",
|
||||
"saveReferenceAssessment": "requestId referenceId expectedUpdatedAt assessment",
|
||||
"saveReference": "requestId platform platformContentId sourceUrl contentType collectedAt creator",
|
||||
"saveReferenceTranscript": "requestId referenceId expectedUpdatedAt transcriptStatus",
|
||||
"markPublication": "requestId contentId accountKey publishedAt",
|
||||
"deleteDocument": "documentId requestId expectedUpdatedAt",
|
||||
"deleteProject": "requestId id expectedUpdatedAt",
|
||||
@@ -83,32 +100,53 @@ REQUIRED = {
|
||||
"deleteResource": "requestId id expectedUpdatedAt",
|
||||
"deleteVideo": "requestId id expectedUpdatedAt",
|
||||
"saveConfig": "bucket clientSecret",
|
||||
"saveFile": "requestId fileId expectedUpdatedAt",
|
||||
"moveFiles": "requestId folderId files",
|
||||
}
|
||||
|
||||
EXAMPLE_FIELDS = {
|
||||
"saveAccount": "brandName",
|
||||
"saveContent": "title body contentFormat mediaFileIds researchSources researchFacts imageDetails",
|
||||
"saveReference": "title bodyMarkdown",
|
||||
"saveDocument": "title bodyMarkdown fileIds",
|
||||
"saveReference": "description viewCount",
|
||||
"saveReferenceTranscript": "transcriptText transcriptSegments transcriptModel transcribedAt",
|
||||
"saveReferenceAssessment": "referencePoints topicNotes",
|
||||
"saveDocument": "title bodyMarkdown fileIds folderId",
|
||||
"saveProject": "name description documents",
|
||||
"saveEpisode": "name sortOrder",
|
||||
"saveResource": "name imageFileIds",
|
||||
"saveVideo": "name mode durationSeconds body referenceImages",
|
||||
"saveImageDetail": "text prompt referenceFileIds",
|
||||
"saveMemo": "dueAt remindDaysBefore priority",
|
||||
"saveFile": "description textContent",
|
||||
"saveFolder": "parentId",
|
||||
}
|
||||
|
||||
UPDATE_EXAMPLE_FIELDS = {
|
||||
"saveAccount": "validityNote",
|
||||
"saveContent": "title",
|
||||
"saveReference": "bodyMarkdown",
|
||||
"saveDocument": "bodyMarkdown",
|
||||
"saveDocument": "bodyMarkdown folderId",
|
||||
"saveProject": "description",
|
||||
"saveEpisode": "sortOrder",
|
||||
"saveResource": "prompt",
|
||||
"saveVideo": "body",
|
||||
"saveMemo": "status relatedMemoIds fileIds",
|
||||
"saveFolder": "name",
|
||||
}
|
||||
|
||||
SAMPLE_VALUES = {
|
||||
"profileUrl": "https://www.tiktok.com/@example",
|
||||
"platformContentId": "7710240323204631829",
|
||||
"platformCreatorId": "7556875931332969479",
|
||||
"referenceId": 1,
|
||||
"topicNotes": "适合护理选题,可参考开头的提问。",
|
||||
"sourceUrl": "https://www.tiktok.com/@example/video/7710240323204631829",
|
||||
"collectedAt": "2026-11-21T00:37:00+08:00",
|
||||
"transcribedAt": "2026-11-21T01:00:00+08:00",
|
||||
"transcriptStatus": "ready",
|
||||
"transcriptText": "示例转写内容。",
|
||||
"transcriptModel": "provider/model",
|
||||
"start_ms": 0,
|
||||
"end_ms": 1000,
|
||||
"accountKey": "example-media-account",
|
||||
"username": "example-admin",
|
||||
"bodyMarkdown": "示例正文",
|
||||
@@ -117,6 +155,8 @@ SAMPLE_VALUES = {
|
||||
"documentId": 7,
|
||||
"episodeId": 3,
|
||||
"expectedUpdatedAt": "2026-01-01T00:00:00Z",
|
||||
"dueAt": "2026-12-23T00:00:00+08:00",
|
||||
"remindDaysBefore": 7,
|
||||
"fileId": 123,
|
||||
"frameRole": "reference",
|
||||
"key": "example-source",
|
||||
@@ -135,11 +175,22 @@ SAMPLE_VALUES = {
|
||||
|
||||
|
||||
def enum_for(endpoint, field):
|
||||
if field == "platform" and endpoint in ("getReferenceList", "saveReference"):
|
||||
return ("tiktok", "douyin", "xiaohongshu")
|
||||
if field == "transcriptStatus":
|
||||
states = ("pending", "ready", "no_audio", "no_speech", "failed")
|
||||
return states if endpoint == "saveReferenceTranscript" else (*states, "not_applicable")
|
||||
if field == "assessment":
|
||||
return ("high", "medium", "low", "excluded", "unrated")
|
||||
if field == "sort" and endpoint == "getReferenceList":
|
||||
return ("updated", "views", "favorites", "published", "assessment")
|
||||
if field == "type":
|
||||
if endpoint in ("getResourceList", "saveResource"):
|
||||
return RESOURCE_TYPES
|
||||
if endpoint == "getFileList":
|
||||
if endpoint in ("getFileList", "searchFiles"):
|
||||
return FILE_TYPES
|
||||
if field == "status" and endpoint in ("getMemoList", "saveMemo"):
|
||||
return ("open", "done")
|
||||
return ENUMS.get(field)
|
||||
|
||||
|
||||
@@ -147,6 +198,18 @@ def field_schema(endpoint, field):
|
||||
values = enum_for(endpoint, field)
|
||||
if values:
|
||||
result = {"type": "string", "enum": list(values)}
|
||||
elif field == "creator" and endpoint == "saveReference":
|
||||
result = object_schema(
|
||||
endpoint,
|
||||
"platformCreatorId handle displayName profileUrl bio followerCount totalLikesCount collectedAt".split(),
|
||||
["platformCreatorId", "collectedAt"],
|
||||
)
|
||||
elif field in ("platformCreatorId", "platformContentId"):
|
||||
result = {"type": "string", "minLength": 1}
|
||||
elif field.endswith("Count") or field in ("start_ms", "end_ms"):
|
||||
result = {"type": "integer", "minimum": 0}
|
||||
elif field == "durationSeconds" and endpoint == "saveReference":
|
||||
result = {"type": "integer", "minimum": 0, "maximum": 2147483647}
|
||||
elif field in ARRAY_OBJECTS:
|
||||
fields, required = ARRAY_OBJECTS[field]
|
||||
items = object_schema(endpoint, fields.split(), required.split())
|
||||
@@ -156,11 +219,17 @@ def field_schema(endpoint, field):
|
||||
result = {"type": "array", "items": items}
|
||||
elif field.endswith("Ids"):
|
||||
result = {"type": "array", "items": {"type": "integer", "minimum": 1}}
|
||||
elif field == "referencePoints":
|
||||
result = {
|
||||
"type": "array",
|
||||
"items": {"type": "string", "enum": ["topic_angle", "opening", "structure", "presentation"]},
|
||||
"uniqueItems": True,
|
||||
}
|
||||
elif field == "sourceKeys":
|
||||
result = {"type": "array", "items": {"type": "string"}}
|
||||
elif field in ("required", "isValid"):
|
||||
elif field in ("required", "isValid", "forTopicSelection"):
|
||||
result = {"type": "boolean"}
|
||||
elif field in ("id", "pageNo", "pageSize", "sortOrder", "durationSeconds") or field.endswith("Id") and field != "requestId":
|
||||
elif field in ("id", "pageNo", "pageSize", "sortOrder", "durationSeconds", "remindDaysBefore") or field.endswith("Id") and field != "requestId":
|
||||
result = {"type": "integer"}
|
||||
if field == "pageSize":
|
||||
result.update(minimum=1, maximum=100, default=20)
|
||||
@@ -169,10 +238,10 @@ def field_schema(endpoint, field):
|
||||
elif field == "durationSeconds":
|
||||
result.update(minimum=1, maximum=3600, default=10)
|
||||
else:
|
||||
result["minimum"] = 0 if field == "sortOrder" else 1
|
||||
result["minimum"] = 0 if field in ("sortOrder", "folderId", "parentId", "remindDaysBefore") else 1
|
||||
else:
|
||||
result = {"type": "string"}
|
||||
if field in ("expectedUpdatedAt", "publishedAt"):
|
||||
if field in ("expectedUpdatedAt", "publishedAt", "publishedFrom", "publishedTo", "collectedAt", "transcribedAt"):
|
||||
result["format"] = "date-time"
|
||||
elif field == "verifiedAt":
|
||||
result["format"] = "date"
|
||||
@@ -182,11 +251,13 @@ def field_schema(endpoint, field):
|
||||
result["writeOnly"] = True
|
||||
if field in DESCRIPTIONS:
|
||||
result["description"] = DESCRIPTIONS[field]
|
||||
if field == "name" or field == "title":
|
||||
result.update(minLength=1, maxLength=240)
|
||||
if endpoint == "saveReference" and field in ("publishedAt", "durationSeconds"):
|
||||
result.pop("description", None)
|
||||
if field in ("name", "title", "fileName") and endpoint != "saveReference":
|
||||
result.update(minLength=1, maxLength=255 if endpoint in ("saveFolder", "saveFile") else 240)
|
||||
if field in ("accountKey", "accountName", "creatorName"):
|
||||
result.update(minLength=1, maxLength=160)
|
||||
if field in ("username", "displayName"):
|
||||
if field in ("username", "displayName") and endpoint != "saveReference":
|
||||
result.update(minLength=3 if field == "username" else 1, maxLength=50)
|
||||
if field in ("newPassword", "password"):
|
||||
result["minLength"] = 8
|
||||
@@ -207,6 +278,15 @@ def request_schema(endpoint, fields):
|
||||
result = object_schema(endpoint, names, required.split() if required else [
|
||||
field[:-1] for field in fields if field.endswith("*")
|
||||
])
|
||||
if endpoint == "saveReferenceTranscript":
|
||||
result["if"] = {"properties": {"transcriptStatus": {"const": "ready"}}}
|
||||
result["then"] = {"required": ["transcriptText", "transcribedAt"]}
|
||||
if endpoint == "saveReferenceAssessment":
|
||||
result["if"] = {"properties": {"assessment": {"const": "low"}}}
|
||||
result["then"] = {
|
||||
"required": ["referencePoints", "topicNotes"],
|
||||
"properties": {"referencePoints": {"minItems": 1}, "topicNotes": {"pattern": r"\S"}},
|
||||
}
|
||||
if endpoint in CASES:
|
||||
case_fields = {mode: values.split() for mode, values in CASES[endpoint].items()}
|
||||
create, update = case_fields["create"], case_fields["update"]
|
||||
@@ -219,10 +299,7 @@ def request_schema(endpoint, fields):
|
||||
result["if"] = {"required": [selector], "properties": {selector: {"minimum": 1}}}
|
||||
result["then"] = {"required": update}
|
||||
result["else"] = {"required": create}
|
||||
if endpoint == "saveReference":
|
||||
result["description"] = "更新时提交希望保留的完整参考内容和附件字段。"
|
||||
else:
|
||||
result["description"] = "更新时省略不打算修改的字段。传入的数组按整组保存。"
|
||||
result["description"] = "更新时省略不打算修改的字段。传入的数组按整组保存。"
|
||||
result["x-required-by-operation"] = case_fields
|
||||
return result
|
||||
|
||||
@@ -259,4 +336,9 @@ def example_body(endpoint, schema, mode):
|
||||
required = schema.get("x-required-by-operation", {}).get(mode, schema["required"])
|
||||
example_fields = UPDATE_EXAMPLE_FIELDS if mode == "update" else EXAMPLE_FIELDS
|
||||
fields = dict.fromkeys((*required, *example_fields.get(endpoint, "").split()))
|
||||
return {field: example_value(field, schema["properties"][field]) for field in fields}
|
||||
result = {field: example_value(field, schema["properties"][field]) for field in fields}
|
||||
if endpoint == "saveReference":
|
||||
result["contentType"] = "video"
|
||||
if endpoint == "saveMemo" and mode == "update":
|
||||
result["status"] = "done"
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user