feat: 将 47 个 Operit TypeScript 脚本全面翻译为 Python

- 新增 operit_runtime.py: 跨平台 Python 运行时
  - 实现 Tools.System/Files/Net/UI/Memory/FFmpeg/Workflow/Chat/SoftwareSettings/Tasker
  - 实现 OkHttp 链式 HTTP 客户端兼容层
  - 实现 complete()/exports/console 全局对象
  - 实现 OperitScriptLoader 脚本加载器
  - 支持 Windows/macOS/Linux 三平台

- 新增 operit_py/ 目录: 47 个 Python 翻译脚本
  - 搜索类: duckduckgo, google_search, tavily, zhipu_search, various_search, crossref
  - 绘图类: openai_draw, qwen_draw, xai_draw, minimax_draw, siliconflow_draw, zhipu_draw, nanobanana_draw
  - 媒体类: ffmpeg, file_converter, douyin_download, bilibili_tools, jmcomic
  - 文件类: extended_file_tools, hex_editor, reader, beeimg_image_uploader
  - 网络类: extended_http_tools, network_test
  - 自动化类: browser, automatic_ui_base, automatic_ui_subagent, automatic_bilibili_assistant, automatic_xiaohongshu_assistant, automatic_baidu_map_assistant
  - 系统类: system_tools, super_admin, daily_life, operit_editor
  - 对话类: ai_chat, extended_chat, qq_intelligent
  - 工作流类: workflow, vflow_trigger, tasker
  - 工具类: time, code_runner, quick_start, extended_memory_tools, baidu_map, 12306, pdf_vision_parser

- 测试结果: 47/47 语法检查通过, 38 脚本加载成功, 280 个工具注册
- Android 专属功能已降级处理(保留接口,返回不支持提示)
This commit is contained in:
shuiyu1123 committed 2026-06-23 12:27:18 +00:00
1 parent 6fa759665d
commit dc77dfd304
48 files changed
+22273

No files matched your search

+131
View File
@@ -0,0 +1,131 @@
# METADATA
# {
# "name": "ffmpeg",
#
# "display_name": {
# "zh": "FFmpeg 工具集",
# "en": "FFmpeg Toolkit"
# },
# "description": {
# "zh": "提供FFmpeg工具,用于处理多媒体内容。",
# "en": "FFmpeg utilities for processing multimedia content."
# },
# "enabledByDefault": true,
# "category": "Media",
# "tools": [
# {
# "name": "ffmpeg_execute",
# "description": { "zh": "执行自定义FFmpeg命令(仅填写参数,不要包含前缀 ffmpeg)。", "en": "Execute a custom FFmpeg command (arguments only; do not include the leading ffmpeg)." },
# "parameters": [
# { "name": "command", "description": { "zh": "要执行的FFmpeg命令参数(不要包含前缀 ffmpeg)", "en": "FFmpeg command arguments to execute (do not include the leading ffmpeg)" }, "type": "string", "required": true }
# ]
# },
# {
# "name": "ffmpeg_info",
# "description": { "zh": "获取FFmpeg系统信息,包括版本、构建配置和支持的编解码器。", "en": "Get FFmpeg system info, including version, build config, and supported codecs." },
# "parameters": []
# },
# {
# "name": "ffmpeg_convert",
# "description": { "zh": "使用简化参数转换视频文件。", "en": "Convert a video file using simplified parameters." },
# "parameters": [
# { "name": "input_path", "description": { "zh": "源视频文件路径", "en": "Input video file path" }, "type": "string", "required": true },
# { "name": "output_path", "description": { "zh": "目标视频文件路径", "en": "Output video file path" }, "type": "string", "required": true },
# { "name": "video_codec", "description": { "zh": "可选,要使用的视频编解码器。推荐使用 'h264'。支持的值: 'h264', 'hevc', 'vp8', 'vp9', 'av1', 'libx265', 'libvpx', 'libaom', 'mpeg4', 'mjpeg', 'prores'。", "en": "Optional. Video codec to use. Prefer 'h264'. Supported values: 'h264', 'hevc', 'vp8', 'vp9', 'av1', 'libx265', 'libvpx', 'libaom', 'mpeg4', 'mjpeg', 'prores'." }, "type": "string", "required": false },
# { "name": "audio_codec", "description": { "zh": "可选,要使用的音频编解码器。支持的值: 'aac', 'mp3', 'opus', 'vorbis', 'flac', 'pcm', 'wav', 'ac3', 'eac3'。", "en": "Optional. Audio codec to use. Supported values: 'aac', 'mp3', 'opus', 'vorbis', 'flac', 'pcm', 'wav', 'ac3', 'eac3'." }, "type": "string", "required": false },
# { "name": "resolution", "description": { "zh": "可选,输出分辨率,例如 '1280x720'。", "en": "Optional. Output resolution, e.g. '1280x720'." }, "type": "string", "required": false },
# { "name": "bitrate", "description": { "zh": "可选,视频比特率,例如 '1000k'。", "en": "Optional. Video bitrate, e.g. '1000k'." }, "type": "string", "required": false }
# ]
# }
# ]
# }
import json
async def ffmpeg_execute(params):
result = await Tools.FFmpeg.execute(params["command"])
returnCode = result["returnCode"]
return {
"success": returnCode == 0,
"message": "FFmpeg command executed successfully." if returnCode == 0 else f"FFmpeg command failed with return code {returnCode}.",
"data": result["output"]
}
async def ffmpeg_info():
result = await Tools.FFmpeg.info()
returnCode = result["returnCode"]
return {
"success": returnCode == 0,
"message": "FFmpeg info retrieved successfully." if returnCode == 0 else "Failed to retrieve FFmpeg info.",
"data": result["output"]
}
async def ffmpeg_convert(params):
result = await Tools.FFmpeg.convert(params["input_path"], params["output_path"], {
"video_codec": params.get("video_codec"),
"audio_codec": params.get("audio_codec"),
"resolution": params.get("resolution"),
"bitrate": params.get("bitrate"),
})
returnCode = result["returnCode"]
return {
"success": returnCode == 0,
"message": "FFmpeg conversion completed successfully." if returnCode == 0 else f"FFmpeg conversion failed with return code {returnCode}.",
"data": result["output"]
}
async def wrapToolExecution(func, params):
try:
import inspect as _inspect
sig = _inspect.signature(func)
if len(sig.parameters) > 0:
result = await func(params)
else:
result = await func()
complete(result)
except Exception as error:
console.error(f"Tool {func.__name__} failed unexpectedly", error)
msg = getattr(error, "message", str(error))
complete({
"success": False,
"message": f"工具执行时发生意外错误: {msg}",
})
async def main():
console.log("--- FFmpeg Tools Test ---")
console.log("\n[1/3] Testing ffmpeg_info...")
infoResult = await ffmpeg_info()
console.log(json.dumps(infoResult, indent=2, ensure_ascii=False))
console.log("\n[2/3] Testing ffmpeg_execute (example: getting help for a decoder)...")
executeResult = await ffmpeg_execute({"command": "-h decoder=h264"})
console.log(json.dumps(executeResult, indent=2, ensure_ascii=False))
console.log("\n[3/3] Testing ffmpeg_convert (example)...")
console.log("Skipping ffmpeg_convert test as it requires input files.")
complete({"success": True, "message": "Test finished."})
async def ffmpeg_execute_wrapper(params):
await wrapToolExecution(ffmpeg_execute, params)
async def ffmpeg_info_wrapper(params=None):
await wrapToolExecution(ffmpeg_info, params)
async def ffmpeg_convert_wrapper(params):
await wrapToolExecution(ffmpeg_convert, params)
exports.ffmpeg_execute = ffmpeg_execute_wrapper
exports.ffmpeg_info = ffmpeg_info_wrapper
exports.ffmpeg_convert = ffmpeg_convert_wrapper
exports.main = main