4 tables: publisher_platform/content/task/log 10 platforms: weibo/douyin/bilibili/kuaishou/wechat/xiaohongshu/toutiao/youtube/twitter Sage-compliant: DSPY no-import delegation, init.py→ServerEnv, scripts/load_path.py Content types: article/video/audio/image with per-platform format adapters
2.0 KiB
2.0 KiB
| name | description | category |
|---|---|---|
| publisher-module | Multi-platform content publishing module for Sage — articles, videos, audio to 10+ social platforms | devops |
Publisher Module
Multi-platform content publishing for Sage. When working with the publisher module, load this skill.
Architecture
- Repo:
/Users/ymq/devops/publisher→git@git.opencomputing.cn:yumoqing/publisher.git - Tables (4):
publisher_platform,publisher_content,publisher_task,publisher_log - Platforms (10): weibo, douyin, bilibili, kuaishou, wechat, xiaohongshu, toutiao, youtube, twitter
- Content types: article, video, audio, image
Adding a Platform
Edit publisher/platforms.py:
from publisher.platforms import register
def publish_newplat(platform, content):
headers = {'Authorization': 'Bearer ' + platform['access_token']}
body = {'text': content.get('title', '')}
return ('POST', 'https://api.newplat.com/publish', headers, body, content['content_type'])
register('newplat', '新平台', publish_newplat, ['article', 'image', 'video'])
DSPY → Python Delegation
All .dspy files follow the pattern:
import json
env = request._run_ns
async with get_sor_context(env, 'sage') as sor:
result = await env.run_scheduled(sor)
return json.dumps(result, ensure_ascii=False)
Deployment Checklist
cp -r publisher $SAGE_ROOT/cp json/publisher_*.json $SAGE_ROOT/json/cp -r wwwroot/publisher $SAGE_ROOT/wwwroot/- Execute
ddl/mysql.sql - Run
scripts/load_path.py - Add
from publisher.init import load_publisher+load_publisher()in sage.py - Restart Sage
Pitfalls
- Platform APIs require real credentials — access_token expires, need refresh flow
- Content format differs per platform (Weibo max 2000 chars, WeChat title max 64 chars)
- Network errors auto-retry 3 times before marking failed
sorparameter allows DSPY context reuse — don't open extra DB connections when sor is provided