通过 API 向飞书(Lark)发送多媒体内容。适用场景:(1) 向飞书用户/群组发送图片、音频、视频、富文本或卡片,(2) 上传媒体文件...
Send multimedia messages to Feishu with proper formatting: inline images, voice bubbles, video players, rich text, and cards.
ffmpeg at D:\ffmpeg\bin\ffmpeg.exe (for audio conversion, video fix)ffprobe at D:\ffmpeg\bin\ffprobe.exe (for duration detection)Run the script at scripts/feishu_media.py:
python
import sys; sys.path.insert(0, r'<skill_dir>/scripts'); from feishu_media import *
FunctionMessage TypeKey Featuressend_text(text)textPlain textsend_image(filepath)imageInline embed, auto-detect mimesend_audio(filepath)audioVoice bubble, auto→opus, auto durationsend_video(filepath, cover_image=None)mediaInline player, faststart, auto durationsend_rich_text(title, elements)postRich text with embedded mediasend_card(title, elements)interactiveCard with header color
All functions accept optional: open_id, token, app_id, app_secret.
duration (ms). Auto-converts non-opus via ffmpeg.file_type=mp4, must include duration (ms). Script auto-applies -movflags +faststart.msg_type=media (not video), content uses file_key + optional image_key for cover.image_key is the cover thumbnail. Without it, video has no preview frame.{'tag': 'media', 'file_key': '...', 'image_key': '...'} as an independent paragraph.opus (audio), mp4 (video), stream (generic file), pdf, doc, xls, ppt.python
# Image
send_image('minimax-output/kitten.png')
# TTS voice bubble (auto converts mp3→opus)
send_audio('minimax-output/greeting.mp3')
# Video with cover (auto faststart + duration)
send_video('minimax-output/kitten_video.mp4', cover_image='minimax-output/kitten.png')
# Rich text with video
send_rich_text('阿离的报告', [
[{'tag': 'text', 'text': '一舞剑气动四方~'}],
[{'tag': 'media', 'file_key': 'file_xxx', 'image_key': 'img_xxx'}],
])
bash
python scripts/feishu_media.py text "Hello"
python scripts/feishu_media.py image photo.png
python scripts/feishu_media.py audio greeting.mp3
python scripts/feishu_media.py video clip.mp4 --cover thumb.png