Install
openclaw skills install feishu-message-download从飞书消息中下载文件(视频、图片、文档等)到本地
openclaw skills install feishu-message-download从飞书消息中下载文件(视频、图片、文档等)到本地。
本 Skill 用于从飞书聊天消息中下载附件到本地,支持视频、图片、文件等多种类型。
下载后的文件可以用于:
# 安装依赖
pip install -r requirements.txt
本 Skill 需要以下飞书应用凭证,可通过以下方式配置:
在 OpenClaw 配置文件中设置:
{
"channels": {
"feishu": {
"appId": "your_app_id",
"appSecret": "your_app_secret"
}
}
}
export FEISHU_APP_ID="your_app_id"
export FEISHU_APP_SECRET="your_app_secret"
from download import FeishuMessageDownloader
downloader = FeishuMessageDownloader()
downloader.download_from_message_url(
message_url="https://open.feishu.cn/im/xxx",
output_dir="~/Downloads"
)
from download import FeishuMessageDownloader
downloader = FeishuMessageDownloader()
downloader.download_file(
message_id="om_xxxxxxxx",
file_key="file_xxxxxxxx",
output_dir="~/Downloads",
filename="my_video.mp4"
)
# 通过消息链接下载
python download.py --url "https://open.feishu.cn/im/xxx" --output ~/Downloads
# 通过消息 ID 和 file_key 下载
python download.py --message-id "om_xxxxxxxx" --file-key "file_xxxxxxxx" --output ~/Downloads
# 指定保存文件名
python download.py --message-id "om_xxxxxxxx" --file-key "file_xxxxxxxx" --output ~/Downloads --filename "video.mp4"
| 参数 | 说明 | 必填 |
|---|---|---|
--url | 飞书消息链接 | 可选 |
--message-id | 消息 ID (om_xxx) | 可选 |
--file-key | 文件 key (file_xxx) | 可选 |
--output | 输出目录,默认为当前目录 | 可选 |
--filename | 保存的文件名 | 可选 |
本 Skill 需要以下飞书应用权限:
im:resource - 访问消息资源用户发送视频到飞书 → 下载到本地 → 发布到抖音/小红书/B 站
# 下载视频
python download.py --message-id "om_xxx" --file-key "file_xxx" --output ~/Videos
# 然后使用视频发布工具发布到各平台
收到飞书文档 → 下载到本地 → 编辑处理 → 重新上传或转发
python download.py --url "https://open.feishu.cn/im/xxx" --output ~/Documents
收集飞书群里的图片 → 批量下载 → 用于设计或存档
from download import FeishuMessageDownloader
downloader = FeishuMessageDownloader()
for msg in messages:
downloader.download_file(
message_id=msg['id'],
file_key=msg['file_key'],
output_dir="~/Pictures/Collection"
)
下载飞书文件 → AI 分析/处理 → 生成报告或内容
# 下载视频
downloader = FeishuMessageDownloader()
result = downloader.download_file(message_id, file_key, "~/AI_Input")
# 使用 AI 处理
# ... AI 处理代码 ...
GET https://open.feishu.cn/open-apis/im/v1/messages/{message_id}/resources/{file_key}?type=file
成功下载后返回保存的文件路径:
{
"success": True,
"file_path": "/path/to/downloaded/file.mp4",
"file_size": 1234567,
"filename": "file.mp4"
}
可能的错误情况:
本 Skill 可以与以下类型的 Skill 配合使用:
| 配合 Skill 类型 | 使用场景 |
|---|---|
| 视频发布 Skill | 下载飞书视频 → 发布到抖音/小红书/B 站 |
| 视频处理 Skill | 下载视频 → 剪辑/转码/压缩 |
| AI 分析 Skill | 下载文件 → AI 分析/总结/提取 |
| 文档处理 Skill | 下载文档 → 编辑/转换/合并 |
| 云存储 Skill | 下载文件 → 上传到云盘/网盘 |
# 步骤 1:从飞书下载视频
python download.py \
--message-id "om_x100b523c2b77fd30c24abb58a94deee" \
--file-key "file_v3_0010e_dc672f40-87b6-4d67-b69d-e40290032c2g" \
--output ~/.openclaw/workspace \
--filename "douyin_video.mp4"
# 步骤 2:(可选)视频处理
# ffmpeg -i douyin_video.mp4 -c:v libx264 -c:a aac output.mp4
# 步骤 3:发布到抖音
# 使用抖音发布工具或手动上传
from download import FeishuMessageDownloader
import os
# 初始化下载器
downloader = FeishuMessageDownloader()
# 批量下载多个文件
messages = [
{"message_id": "om_xxx1", "file_key": "file_xxx1", "type": "video"},
{"message_id": "om_xxx2", "file_key": "file_xxx2", "type": "image"},
{"message_id": "om_xxx3", "file_key": "file_xxx3", "type": "document"},
]
output_base = "~/Downloads/Feishu_Files"
for msg in messages:
# 按类型分类保存
type_dir = os.path.join(output_base, msg['type'])
os.makedirs(type_dir, exist_ok=True)
result = downloader.download_file(
message_id=msg['message_id'],
file_key=msg['file_key'],
output_dir=type_dir
)
if result['success']:
print(f"✅ 下载成功:{result['file_path']}")
else:
print(f"❌ 下载失败:{result.get('error')}")
勇哥的小飞侠 🧚🏻♀️🌸🧚🏻