feat: 同步 Media CLI 对标素材与文件管理更新

同步 LightCore d14de92a4 中的 CLI 变更。
This commit is contained in:
2026-11-22 17:06:49 +08:00
parent c19c26ec2c
commit 2d4659291d
5 changed files with 208 additions and 39 deletions
+38 -14
View File
@@ -4,7 +4,7 @@ from pathlib import Path
import re
from .api import format_response
from .media import positive_int
from .media import folder_id, positive_int
from .media_schema import CASES, DESCRIPTIONS, enum_for, example_body, request_schema
from .transport import ClientError, compact, reject_constant
@@ -46,14 +46,20 @@ GROUPS = {
"contentId requestId expectedUpdatedAt fileId text prompt referenceFileIds notes", "json"),
("download", "downloadAsset", "下载与稿件关联的文件", "contentId* fileId*", "download"),
]),
"references": ("参考内容", SOCIAL, [
("list", "getReferenceList", "查询参考内容", f"{PAGINATION} keyword platform contentType"),
("get", "getReferenceDetail", "查看参考内容详情", "referenceId*"),
("save", "saveReference", "新建或更新参考内容",
"requestId referenceId platform contentType creatorName creatorHandle creatorProfileUrl "
"sourceContentUrl title bodyMarkdown coverFileIds mediaFileIds expectedUpdatedAt", "json"),
("delete", "deleteReference", "删除参考内容记录", "referenceId requestId expectedUpdatedAt", "json"),
("download", "downloadReferenceAsset", "下载与参考内容关联的文件", "referenceId* fileId*", "download"),
"references": ("对标素材", SOCIAL, [
("list", "getReferenceList", "查询作品与评估。Agent 选题使用 --for-topic-selection true",
f"{PAGINATION} keyword platform contentType creatorId publishedFrom publishedTo transcriptStatus assessment forTopicSelection sort"),
("get", "getReferenceDetail", "读取作品详情和转写全文", "referenceId*"),
("save", "saveReference", "按平台作品 ID 写入采集数据",
"requestId platform platformContentId sourceUrl videoFileUrl audioFileUrl contentType title description publishedAt durationSeconds "
"coverFileId viewCount likeCount favoriteCount commentCount shareCount collectedAt creator", "json"),
("save-transcript", "saveReferenceTranscript", "保存作品转写",
"requestId referenceId expectedUpdatedAt transcriptStatus transcriptText transcriptSegments "
"transcriptLanguage transcriptModel transcribedAt", "json"),
("save-assessment", "saveReferenceAssessment", "保存人工选题评估、参考点和备注",
"requestId referenceId expectedUpdatedAt assessment referencePoints topicNotes", "json"),
("delete", "deleteReference", "删除作品记录及其评论", "referenceId requestId expectedUpdatedAt", "json"),
("download", "downloadReferenceAsset", "下载与作品关联的封面", "referenceId* fileId*", "download"),
]),
"publications": ("人工发布记录", SOCIAL, [
("list", "getPublicationList", "查询已登记的发布记录", f"{PAGINATION} contentId accountKey"),
@@ -61,10 +67,12 @@ GROUPS = {
"requestId contentId accountKey publishedAt publicUrl", "json"),
]),
"documents": ("通用文档和产品资料", DOCUMENT, [
("list", "getDocumentList", "查询文档", f"{PAGINATION} keyword excludeKeyword searchScope matchMode projectId"),
("list", "getDocumentList", "查询文档,省略文件夹编号时搜索全库", f"{PAGINATION} keyword excludeKeyword searchScope matchMode projectId folderId"),
("get", "getDocumentDetail", "读取文档正文和附件", "documentId*"),
("save", "saveDocument", "新建或更新文档以及附件关联",
"requestId documentId expectedUpdatedAt title bodyMarkdown fileIds", "json"),
("save", "saveDocument", "新建、编辑或移动文档以及更新附件关联",
"requestId documentId expectedUpdatedAt title bodyMarkdown fileIds folderId", "json"),
("folders", "getFolderTree", "列出文档文件夹及其父目录", ""),
("save-folder", "saveFolder", "新建、重命名或移动文档文件夹", "requestId folderId parentId expectedUpdatedAt name", "json"),
("delete", "deleteDocument", "删除文档记录", "documentId requestId expectedUpdatedAt", "json"),
]),
"projects": ("短剧项目", SCRIPT, [
@@ -99,6 +107,12 @@ GROUPS = {
("image-prompt", "getReferenceImagePrompt", "读取指定参考图的生成提示词", "videoId* key*"),
("download", "downloadReferenceImage", "下载与视频关联的图片", "videoId* fileId*", "download"),
]),
"memos": ("Media 备忘录", "/memo", [
("check", "checkMemos", "检查已到提醒时间及已逾期的备忘", PAGINATION),
("list", "getMemoList", "按状态或标题查找备忘", f"{PAGINATION} status keyword excludeMemoId"),
("get", "getMemo", "查看备忘详情和备注", "memoId*"),
("save", "saveMemo", "新建、编辑或完成备忘", "requestId memoId expectedUpdatedAt title notes status priority dueAt remindAt remindDaysBefore relatedMemoIds fileIds", "json"),
]),
"storage": ("Media 存储绑定", "/storage", [
("get", "getConfig", "查看 Media 存储配置", ""),
("save", "saveConfig", "保存 Media 存储配置", "bucket clientSecret", "private"),
@@ -132,8 +146,10 @@ def add_field(parser, endpoint, spec):
options["type"] = positive_int if field == "pageNo" else page_size
options["default"] = 1 if field == "pageNo" else 20
options["help"] += f",默认 {options['default']}"
elif field == "isValid":
elif field in ("isValid", "forTopicSelection"):
options.update(type=parse_bool, metavar="true|false")
elif field == "folderId":
options["type"] = folder_id
elif field == "id" or field.endswith("Id"):
options["type"] = positive_int
parser.add_argument(flag, **options)
@@ -209,4 +225,12 @@ def add_commands(commands, file_actions):
)
for operation in operations:
add_operation(actions, prefix, *operation)
add_operation(file_actions, SOCIAL, "search", "getFileList", "按文件名查找素材台账", f"{PAGINATION} keyword type")
library = "/content/file"
add_operation(file_actions, library, "search", "searchFiles", "按文件名查找素材,省略文件夹编号时搜索全库", f"{PAGINATION} keyword type folderId")
add_operation(file_actions, library, "folders", "getFolderTree", "列出文件夹及其父目录", "")
add_operation(file_actions, library, "info", "getFile", "按文件编号查看描述和文本内容", "fileId*")
add_operation(file_actions, library, "preview", "previewFile", "获取临时预览地址", "fileId*")
add_operation(file_actions, library, "download", "downloadFile", "按文件编号下载原件", "fileId*", "download")
add_operation(file_actions, library, "update", "saveFile", "编辑文件名、描述或文本内容", "requestId fileId expectedUpdatedAt fileName description textContent", "json")
add_operation(file_actions, library, "save-folder", "saveFolder", "新建、重命名或移动文件夹", "requestId folderId parentId expectedUpdatedAt name", "json")
add_operation(file_actions, library, "move", "moveFiles", "移动一个或多个文件", "requestId folderId files", "json")