From 004fd713b82e9f9a870eed8b01d562f6831d6548 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 4 Aug 2026 08:23:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20WeChat=20Channels=20(=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=8F=B7)=20platform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publisher/platforms.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/publisher/platforms.py b/publisher/platforms.py index c450482..5c4c974 100644 --- a/publisher/platforms.py +++ b/publisher/platforms.py @@ -153,3 +153,21 @@ def publish_twitter(platform, content): return ('POST', 'https://api.twitter.com/2/tweets', headers, body, 'article') register('twitter', 'Twitter/X', publish_twitter, ['article', 'image', 'video']) + +# -- 微信视频号 -- +def publish_channels(platform, content): + headers = _auth_headers(platform) + headers['Content-Type'] = 'application/json' + body = { + 'title': content.get('title', '')[:50], + 'description': content.get('body', '')[:500], + 'cover_url': content.get('cover_url', ''), + } + if content['content_type'] == 'video' and content.get('media_urls'): + body['video_url'] = json.loads(content['media_urls'])[0] + elif content.get('media_urls'): + body['image_urls'] = json.loads(content['media_urls'])[:9] + return ('POST', platform.get('api_endpoint', 'https://channels.weixin.qq.com/api/post/create'), + headers, body, content['content_type']) + +register('channels', '微信视频号', publish_channels, ['video', 'image'])