Skip to main content

opub

opub 是一个 Python 工具包,把视频/图文一键发布到国内主流社交媒体平台,支持定时发布。

已支持 抖音、小红书、快手、Bilibili、视频号、百家号、微博 共 7 个平台。 项目以 AI Agent 技能(skill)为核心使用形态,也可以直接作为 CLI 使用。

功能特性

平台标识 名称 视频上传 图文上传 定时发布 说明
douyin 抖音 ✅ ✅ ✅
xiaohongshu 小红书 ✅ ✅ ✅ 浏览器自动化
kuaishou 快手 ✅ ✅ ✅ 浏览器自动化
bilibili B站 ✅ ❌ ❌ 当前接口仅立即发布,自动抓取BV号
tencent 视频号 ✅ ❌ ✅ 分享短链通过 API 自动抓取
baijiahao 百家号 ✅ ❌ ✅ 浏览器自动化
weibo 微博 ✅ ✅ ✅ 单账号自动发现

所有平台通过统一入口 opub 调用,自动完成运行环境预检、账号登录校验、发布和结果汇总。

安装

python -m pip install --only-binary=:all: opub
opub --repair-env

0.9.0 支持 CPython 3.11、3.12、3.13,以及 macOS arm64/x86_64、Windows x86_64、Linux x86_64。正式发行只提供编译 wheel;没有匹配 wheel 时不会回退到源码构建。

系统依赖:

# 浏览器驱动(--repair-env 会安装;也可以单独执行以下命令)
PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST="https://cdn.playwright.dev" patchright install chromium

# ffmpeg(仅"图文转视频"功能需要)
# macOS: brew install ffmpeg
# Ubuntu/Debian: sudo apt-get install ffmpeg

# B站上传程序(发布到 B站前需安装)
opub --repair-env --with-bilibili

首次运行会自动在当前系统用户的 ~/.opub/ 创建数据目录(cookies、许可证和发布记录等)。同一系统用户下的所有 Agent 固定使用这一目录;源码目录和环境变量不会改变数据位置。

发布时只检查环境,不再自动安装或更新依赖。需要图文转视频时,运行 opub --repair-env --with-video,或安装 python -m pip install --only-binary=:all: "opub[video]"。发布到 B站需要本地 biliup 程序:发布与 --dry-run 只做只读检查,缺失时返回 ENV-007,用 opub --repair-env --with-bilibili 显式安装。修复命令使用 opub 当前解释器,不需要付费激活,也不会发布内容。

快速开始

opub 的新任务通过命令行参数接收全部配置,发布结果会保存到本地供恢复使用。每个平台只自动发现一个规范账号文件;未发现账号时,发布流程会引导扫码并写入对应上传器目录的 account.json。

# 视频发布(必填:--platforms + --video)
opub --platforms douyin,weibo --video videos/demo.mp4 --title "标题" --tags "标签1,标签2"

# 图文发布
opub --platforms xiaohongshu --note --images img1.jpg,img2.jpg --title "标题"

# 图文转视频(视频号/百家号等不支持图文的平台)
opub --platforms tencent --note --images img1.jpg --convert-to-video --video-duration 5

# 定时 / 从目录第 2 个视频开始 / 强制重新生成
opub --platforms weibo --video videos/ --title "标题" --schedule "2027-01-01 12:00" --start-from 2 --force

# 有头模式排查(发布默认无头不弹窗;扫码登录始终显示窗口)
opub --platforms douyin --video videos/demo.mp4 --title "标题" --no-headless

opub --version                        # 查看已安装版本
opub --help                           # 全部参数说明

Agent 可在发布命令后加 --output json:stdout 只返回一份 JSON 结果,过程日志写入 stderr。结果包含各平台成败、素材、错误码、链接及是否允许重试,详见 CLI 说明。

发布前可添加 --dry-run 检查素材、标题、平台能力、时间和环境,不需要激活,不登录、不发布或生成素材。批量任务会先检查全部素材和标题,再开始发布。

每次实际发布输出任务编号;失败或中断后使用 opub --resume RUN_ID 恢复,已成功的平台保留原链接。结果不明的提交会被阻止重发,需先核对平台作品。--start-from 仅选择新任务的目录起始序号,不保护已成功的平台。

AI Agent 技能

Agent 的完整接口契约由公开的 opub Skill 提供,安装、配置、调用、读取结果所需信息全部包含在 Skill 中。

付费许可

opub 0.x 创始版售价 ¥9.90,在爱发电商品页购买:https://afdian.com/item/69bf71f0a9f511f1bc065254001e7c00。opub 自身不设账号。购买时无需提前注册爱发电;请使用你自己的手机号或邮箱完成验证,首次购买时爱发电会自动生成账号。付款后复制爱发电发放的激活码;请勿向 Agent 提供验证码或账号密码。激活码首次兑换后绑定一个设备;许可不迁移、不解绑、不提供换机重置,新电脑重新购买。该许可覆盖 0.x,已安装的 0.x 版本可永久离线使用;未来大版本需要单独购买。支付方式由用户在爱发电页面选择。公开 Python 包是诚实用户门禁,属于非强 DRM。

opub --license-status
opub --activate
opub --activate --code OPUB0-ABCDE-FGHJK-MNPQR-STVWX-YZ234-56789

交互运行 opub --activate 会打开购买页并提示输入激活码;Agent 应保留已经确认的发布输入,激活成功后自动继续同一个发布任务,不重复问参数。不要在输出或 internal log 中展示完整激活码或设备 hash。

错误码 含义 建议
LIC-001 尚未激活 执行激活命令
LIC-002 损坏签名 联系支持并提供错误码
LIC-003 许可属于其他设备 新电脑重新购买
LIC-004 稳定设备标识不可用 联系支持并提供错误码
LIC-011 服务不可用 稍后重试
LIC-013 激活码无效 检查激活码后重新激活
LIC-014 激活码已绑定其他设备 当前电脑重新购买
LIC-015 当前客户端版本不适用 升级或切换到 opub 0.x 后重试

完整 CLI 说明见 docs/CLI.md。

技能与运行时分发相互独立:Agent 平台安装技能时即获得 SKILL.md,运行时依赖由 Agent 按 SKILL.md 指引自行动 pip install opub 安装。

致谢

代码许可证

0.9.0 的新增私有运行时部分采用 opub 商业代码许可证;继承的 MIT 代码和随包资源保留原授权,详见 第三方声明。这不会撤销 0.8.21 及更早版本已经授予的 MIT 权利。

自动检查

私有发行流程在 Python 3.11 / 3.12 / 3.13 上检查依赖锁文件,运行客户端与许可服务测试,构建并审计 macOS universal2、Windows x86_64 和 Linux x86_64 编译 wheel,再在独立环境安装验证 CLI。正式发行不构建源码包。测试不需要真实账号或发布内容。

uv sync --locked
uv pip install "pytest>=8,<9" pip build "setuptools>=77.0.3" wheel -r license_server/requirements.txt
.venv/bin/python -m pytest tests license_server/tests -q

Release files for opub 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for opub 0.9.0
File
opub-0.9.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
opub-0.9.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
opub-0.9.0-cp313-cp313-macosx_10_13_universal2.whl CPython 3.13 CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64) Details
opub-0.9.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
opub-0.9.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
opub-0.9.0-cp312-cp312-macosx_10_13_universal2.whl CPython 3.12 CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) Details
opub-0.9.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
opub-0.9.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64, Linux glibc 2.28+ x86-64 Details
opub-0.9.0-cp311-cp311-macosx_10_9_universal2.whl CPython 3.11 CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size: 42.8 MB

Release files / opub-0.9.0-cp313-cp313-win_amd64.whl

Download URL opub-0.9.0-cp313-cp313-win_amd64.whl
Size 2.7 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
3c3410af4f4039164ef47684add57c78decb8a94d66394bc76c4dc57067e36c5
BLAKE2b-256 checksum
How to use checksums
5db29f40572396f91ce857e60c3e6b8109b3e6ac859da1327c9f742eed9986ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL opub-0.9.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
938703af266bfc2d857331805bfe4c6f2c35f3a46e38f25f667c808507256eec
BLAKE2b-256 checksum
How to use checksums
7384ee8126174524c3a52cee12b1c1faf28ea2d32fedbe25fc135d091bf87eb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp313-cp313-macosx_10_13_universal2.whl

Download URL opub-0.9.0-cp313-cp313-macosx_10_13_universal2.whl
Size 7.6 MB
Tags CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
8ffe988707a98b030a052df6905be4ec3df86068a974c4d3b03fb6760bc50fba
BLAKE2b-256 checksum
How to use checksums
ad4ec2ae9832d892278a9ef0981058f1a8d6b01db71e7f163d7020281ce576d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp312-cp312-win_amd64.whl

Download URL opub-0.9.0-cp312-cp312-win_amd64.whl
Size 2.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
ec4c03df1a8106f4db8d8dec16f5b3e89b49059fb8d99407d78b2308f2183f14
BLAKE2b-256 checksum
How to use checksums
0a88faf19f33f3e857b88508a0d12083481903d1fb0b5973d78909780d7aed99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL opub-0.9.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 4.4 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
b7dfadef25dd773504ada4ac1b170dbbec1927d1ead39c43e8b28a29d2fa06f5
BLAKE2b-256 checksum
How to use checksums
531cb3f0fc5583818ef7eb1c943343ca1c05a2ad68c83ab8bb2a21c0b85ed881
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp312-cp312-macosx_10_13_universal2.whl

Download URL opub-0.9.0-cp312-cp312-macosx_10_13_universal2.whl
Size 7.6 MB
Tags CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
1f60a91ace90333a57da8de006f11aee5457198d07a15a9b83f348a47389f664
BLAKE2b-256 checksum
How to use checksums
db7fbeae78d98d4ada1ddb6b0cd4fe4cd5c7b3ec04b20c7c5169befd782e8f5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp311-cp311-win_amd64.whl

Download URL opub-0.9.0-cp311-cp311-win_amd64.whl
Size 2.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
96e34cdfa3087e44eaa2bf463514647567c64aa86dd0f4a42d18bf549816130b
BLAKE2b-256 checksum
How to use checksums
b3f6ea69959c76cbcd5b7192cc732ad34108e3158fffeda75ce12a72ae74de81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL opub-0.9.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 3.9 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
dc8f368151595c1198e45fccc1b6b3c425c56420d9d57119db06db1b760f5196
BLAKE2b-256 checksum
How to use checksums
8db58148796fc507f1e47d4fb0755e46d8fcab5f4244ca05ba91573147b09acb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / opub-0.9.0-cp311-cp311-macosx_10_9_universal2.whl

Download URL opub-0.9.0-cp311-cp311-macosx_10_9_universal2.whl
Size 6.8 MB
Tags CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
f1f2a3c7be8ffa45d42a328e88c6541e959ddb6382dffd6859db22b9a9c7c3b1
BLAKE2b-256 checksum
How to use checksums
7fe2130ecb82e4b7422c6ce822935ff076c6eb86a78001a84f2669e606b60e4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.9.0 This release

9 release files

0.8.21

2 release files

0.8.20

2 release files

0.8.19

2 release files

0.8.18

2 release files

0.8.17

2 release files

0.8.16

2 release files

0.8.15

2 release files

0.8.14

2 release files

0.8.13

2 release files

0.8.12

2 release files

0.8.11

2 release files

0.8.10

2 release files

0.8.9

2 release files

0.8.8

2 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page