A previous release had provenance metadata, but this release does not. View details.
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、许可证和发布记录等)。历史查询 --history 不创建目录或文件。同一系统用户下的所有 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 恢复,已成功的平台保留原链接。恢复会在上传前核验原账号身份,同账号正常刷新登录态可以继续;换号或无法核验当前身份返回 AUTH-003。旧任务或未保存原身份的条目返回 RUN-006,先在原账号核对,不能用当前账号补证。结果不明的提交仍阻止重发。--start-from 仅选择新任务的目录起始序号,不保护已成功的平台。
使用 opub --history 查看最近 20 个任务,opub --history RUN_ID 查看原素材 / 文案、逐平台状态、记录链接、原账号绑定和恢复条件。列表可加 --limit 5(1–200),两种查询都支持 --output json,无需许可或浏览器。查询只读本地历史,不读取当前素材或账号、不登录或投稿、不改写未知结果;记录链接的公开访问 / 播放仍需独立核对。详见 只读查询与核对步骤。
AI Agent 技能
Agent 的完整接口契约由公开的 opub Skill 提供,安装、配置、调用、读取结果所需信息全部包含在 Skill 中。
付费许可
opub 0.x 创始版售价 ¥9.90,通过 Agent 内的支付宝付款请求购买,付款核验后自动激活当前设备。一次购买绑定一台设备,无订阅;已安装的 0.x 版本可永久离线验签使用。许可不迁移、不解绑、不提供换机重置,新电脑重新购买,未来大版本需要单独购买。opub 自身不设账号。公开 Python 包是诚实用户门禁,属于非强 DRM。
支付依赖检查
先检查本机许可;只有需要购买或继续付款时才检查支付依赖。有效许可、只读历史、--dry-run 和环境修复不以支付技能或钱包为前提。
| 依赖 | 用途与检查方式 |
|---|---|
alipay-payment-skill |
支付宝官方支付技能;必须能在当前 Agent 会话中发现并加载,用其 references/402-payment.md 处理 opub 的账单 |
alipay-authenticate-wallet |
支付宝官方钱包技能;一并安装,在用户明确要求钱包开通/授权或支付命令明确要求独立钱包流程时才调用 |
alipay-bot |
官方买方支付 CLI;在 Agent 实际执行命令的环境中检查 PATH(macOS/Linux 用 command -v alipay-bot,Windows 用 Get-Command alipay-bot),再运行 alipay-bot --version |
缺少技能时,通过宿主支持的技能安装方式,从支付宝官方仓库导入上述两个同名目录,保留完整的 SKILL.md、references/ 和 .signature/。WorkBuddy 的用户级安装位置为 ~/.workbuddy/skills/<技能名>/;不要安装到其他 Agent 的目录。安装后刷新技能或开启新会话,确认宿主能发现并加载,不能仅凭磁盘存在文件就宣称可用。
技能可加载但 CLI 缺失时,读取官方技能的 references/cli-setup.md,按其指定 npm 包版本和完整性校验步骤安装;缺少 Node.js/npm 时先补齐该安装前提。pip install opub 和 opub --repair-env 不会安装这些支付依赖。安装失败或宿主无法加载时,保留原发布输入和购买记录,明确报告缺失依赖及恢复步骤,停止购买后的发布流程,不把“没有支付能力”当作免付费。
支付前加载官方支付技能并遵循其流程;不要自行拼装支付命令,也不要把 check-wallet 作为每次付款的前置步骤。钱包授权和本人付款确认由官方流程处理;已有授权不重复申请。
购买与恢复
Agent 先保留已确认的发布输入,并运行 opub --license-status。尚未激活时运行:
opub --activate --output json
读取 JSON 的 mode: activation 和 activation.status:
payment_required:向用户说明商品、¥9.90 价格和单设备买断规则,取得本次购买确认并完成支付依赖检查后,调用支付宝官方支付技能alipay-payment-skill。原样使用payment_needed_file中的账单和request.url、request.method、request.body,不改写账单,也不重新生成订单。支付技能负责钱包授权、本人付款确认和待付款状态查询。付款完成后重试同一激活命令,直到客户端返回licensed;支付工具显示成功不等于本机已激活。pending_confirmation:已验付,正在确认交付。重试同一激活命令恢复;不得再次发起付款。licensed:许可证已经在本机验签并安装。确认opub --license-status成功,再自动继续同一个发布任务,不重复询问素材、文案或平台。unavailable或LIC-xxx:保留原购买记录,按错误建议恢复。不得把网络错误当成未付款,也不得删除本地购买状态来重复下单。
用户亲自在支付宝确认付款。不得索取验证码、支付密码或账号密码,不以用户口头“已付款”代替官方验付。不得读取、复制或展示 activation-purchase.json 中的领取凭据,也不展示设备哈希、支付凭证和签名许可证原文。
许可检查未成功前,不得执行实际发布、改用底层上传器、修改许可状态,或用 --dry-run 冒充已发布。支付依赖缺失不允许改用个人收款码、手工订单号验付、微信或其他未接入的付款渠道。若官方提示“买家和卖家不能相同”,停止同账号重试,说明需由另一位真实买家本人付款;保留原订单,不擅自换绑钱包或新建订单。
激活只在需要联网购买或恢复时联网;安装后的许可验证保持离线。
许可错误统一输出 [opub] LIC-xxx: <描述>。建议: <动作>。常见错误及建议:
| 错误码 | 含义 | 建议 |
|---|---|---|
LIC-001 |
尚未激活 | 执行激活命令 |
LIC-002 |
损坏签名 | 联系支持并提供错误码 |
LIC-003 |
许可属于其他设备 | 新电脑重新购买 |
LIC-004 |
稳定设备标识不可用 | 联系支持并提供错误码 |
LIC-011 |
服务不可用 | 稍后重试 |
LIC-013 |
激活码无效 | 检查激活码后重新激活 |
LIC-014 |
激活码已绑定其他设备 | 当前电脑重新购买 |
LIC-015 |
当前客户端版本不适用 | 升级或切换到 opub 0.x 后重试 |
退出码 13(exit 13)表示当前尚未完成激活;待付款和待确认交付通过 activation.status 区分。显示 LIC-xxx 时按表中建议处理。
完整 CLI 说明见 docs/CLI.md。
技能与运行时分发相互独立:Agent 平台安装技能时即获得 SKILL.md,运行时依赖由 Agent 按 SKILL.md 指引自行动 pip install opub 安装。
致谢
- Bilibili 上传能力基于开源项目 biliup 接入与封装。
- 本项目基于 dreammis/social-auto-upload 重构而来,感谢原作者及贡献者。
代码许可证
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
Metadata
Release files for opub 0.9.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Loss of provenance
These files do not have provenance metadata, despite files in a prior release including this data.
We recommend further investigation before installing these files. View details.
Built distributions (wheels)
Total release size: 51.2 MB
Release files / opub-0.9.13-cp313-cp313-win_amd64.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.2 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
fdd5f9a7f26c11e15c3c149b96dcf3a25b02606de9f0f6f10c4c49075d384afc
|
|
BLAKE2b-256 checksum How to use checksums |
67a3c26c1d8ed73fe4e31c7fcffe6ca53fa07307a7e627c2b61adc13ed2b3071
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
19f3a6aeaa794b2f4af97c6d6d7ee489f79ab21d34883b2269cf142828352332
|
|
BLAKE2b-256 checksum How to use checksums |
f2522b5c3966ff9dc7795ff9f075fbf96b6c5533d475322c61f33a1552967fd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp313-cp313-macosx_10_13_universal2.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp313-cp313-macosx_10_13_universal2.whl |
|---|---|
| Size | 9.1 MB |
| Tags | CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
fb5b4480c808a68e3221b975c1ed26a771dc7263e8c841c01d99dce4f282344c
|
|
BLAKE2b-256 checksum How to use checksums |
7d7221b3e3ee6daca7f3ab4e689ed3036f569348b47240e26abe5c120d308873
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp312-cp312-win_amd64.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.2 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
cebedbc0b90cd862d282b141333bde683ec4ec300ed2379ad1abf5e1ee36a4cd
|
|
BLAKE2b-256 checksum How to use checksums |
1fd9286634c4bde21b8aa74dc62ee49937594899b6839dc75250eecb832464f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
da3c9e56d847c5e15dca21a2ea4ad54e2b5433f2192b01ed7534d4c4e7735577
|
|
BLAKE2b-256 checksum How to use checksums |
788bfc076236ed301fc7f3fbdedc4a1efbe19c49f72169b399f1475f5a3cc48a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp312-cp312-macosx_10_13_universal2.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp312-cp312-macosx_10_13_universal2.whl |
|---|---|
| Size | 9.1 MB |
| Tags | CPython 3.12 macOS 10.13+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
f91032683daccd1fdf91e32c1ef5e1c9c0607b776a9a0575aa30e3c1d6c04d9c
|
|
BLAKE2b-256 checksum How to use checksums |
baa1c2418570ae15fa49e3867f993c3e8f131a21a5b4c1757777bf92198e404c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp311-cp311-win_amd64.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
22e8ebc06ee5dc6561eb7e56861316ebe5320dae66119dd7a52df072d18fd5a5
|
|
BLAKE2b-256 checksum How to use checksums |
09e48e9ed991f24e755479809119a28587d9758ef7c404dfe69f7b682a3f692a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
bf02b604a10489afcc2ad675b463d578f97a5211bee5472ba2f45c8fe6e28104
|
|
BLAKE2b-256 checksum How to use checksums |
a4ff1a91c9317d6cdf234da523a660acb16a7d2292f989856c3aa7a446ffc70c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Release files / opub-0.9.13-cp311-cp311-macosx_10_9_universal2.whl
Loss of provenance
This file belongs to a release without provenance metadata, despite a prior release including this data.
We recommend further investigation before installing this file. View details.
| Download URL | opub-0.9.13-cp311-cp311-macosx_10_9_universal2.whl |
|---|---|
| Size | 8.2 MB |
| Tags | CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
23e99c8e7837e52ff306a5b12766b56679dfeb1a33b5aef66c6fb31320af257b
|
|
BLAKE2b-256 checksum How to use checksums |
ae89efdc85053f1ce7e5eea7b196a95ab00382055b16e11bb5220263fb22fafc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.12
|
Security for opub 0.9.13
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.
Loss of provenance
A previous release of these files had provenance metadata, but this release does not.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Release comparison
- Removed 0.9.12 9 files With provenance
- Added 0.9.13 9 files Without provenance
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.