7.8 KiB
Bilibili CLI Design
Date: 2026-03-25
Summary
This design adds a bilibili platform branch under sau with the same user-facing shape as the existing douyin and kuaishou commands.
The key constraint is that users should not need to install biliup manually. The project will treat biliup as an internal runtime dependency:
sau bilibili ...is the public entrypoint- the program auto-downloads
biliupwhen missing - the program checks GitHub Releases on each run
- when a newer upstream release exists, the program auto-updates first and then continues
This design intentionally keeps the wrapper thin. It reuses the current Bilibili uploader semantics already present in the repository instead of inventing a brand-new parameter model.
Goals
- Keep the user-facing CLI consistent with
sau douyin ...andsau kuaishou ... - Hide
biliupinstallation from users - Reuse current project concepts such as account files,
VideoZoneTypes, scheduled publish, and existing example semantics - Avoid over-abstracting the Bilibili integration
Non-Goals
- Do not vendor
biliupbinaries into the repository - Do not pin or maintain a local release manifest in the first version
- Do not add note/image publishing for Bilibili in the first version
- Do not redesign the existing Bilibili uploader domain model beyond what is needed for CLI integration
Existing Project Context
The repository already has native Bilibili support:
uploader/bilibili_uploader/main.pywrapsbiliup.plugins.bili_webupexamples/upload_video_to_bilibili.pyuses existing upload semanticsutils/constant.pyalready definesVideoZoneTypes
The current local upload model is centered on:
filetitledesctidtagsdtime
This design keeps that shape for the first CLI version.
User-Facing CLI
Supported commands
sau bilibili loginsau bilibili checksau bilibili upload-video
Command contract
sau bilibili login
Purpose:
- ensure
biliupis present and up to date - trigger Bilibili login through
biliup - store account data using the project account-file convention
First version behavior:
- if
biliupis missing, auto-download latest release - if upstream has a newer release, auto-update first
- then invoke the login flow
sau bilibili check
Purpose:
- ensure
biliupis present and up to date - validate whether the configured Bilibili account is usable
First version behavior:
- combines local account-file presence with a practical
biliup-based validation path - keeps output simple and aligned with other platforms:
validinvalid
sau bilibili upload-video
Purpose:
- ensure
biliupis present and up to date - upload one Bilibili video using the current repository semantics
First version parameters:
--accountrequired--filerequired--titlerequired--descrequired--tidrequired--tagsoptional--scheduleoptional
Decision:
tidis required in v1- this matches the current project model and avoids guessing a default zone
Runtime Dependency Strategy
Chosen strategy
biliup is not committed into this repository and is not a user-managed prerequisite.
Instead, sau bilibili ... automatically manages it at runtime:
- locate local
biliup - query upstream GitHub Release state
- if missing or outdated, download latest release
- replace local runtime copy
- continue current command
Why this strategy
- keeps repository size small
- removes manual installation burden from users
- preserves a single public entrypoint through
sau - avoids
git submodule, which is not useful for release assets
Trade-off accepted
This design intentionally accepts upstream instability risk:
- every run checks for updates
- a new upstream release may change CLI behavior
- the wrapper must therefore stay thin and resilient
This trade-off was explicitly accepted in exchange for lower maintenance overhead.
Storage and Resolution
The implementation should use a local runtime tool cache instead of shipping binaries in git.
The exact cache directory can remain implementation-defined, but it should satisfy:
- writable by the current user
- reusable across commands
- isolated from source-controlled files
The resolver should be responsible for:
- discovering the current OS
- choosing the correct upstream release asset
- downloading and replacing the executable
- returning the resolved executable path
Thin Wrapper Architecture
The wrapper should stay minimal and split responsibilities into only a few pieces:
1. Resolver
Responsibilities:
- check whether
biliupexists locally - query upstream release metadata
- download/update executable when needed
- return executable path
2. Runner
Responsibilities:
- invoke the resolved
biliupexecutable - collect exit code, stdout, and stderr
- convert obvious process failures into project-friendly runtime errors
3. CLI adapter in sau_cli.py
Responsibilities:
- parse
sau bilibili ...arguments - map them to the Bilibili runtime invocation
- keep help text consistent with existing platform subcommands
No deeper abstraction layers are required in v1.
Mapping to Existing Project Concepts
The wrapper should align with existing repository behavior instead of inventing a second Bilibili model.
Account files
The Bilibili branch should use the same account alias concept as other platforms:
- user passes
--account <name> - the project resolves the corresponding account file path
Categories
tid remains a first-class parameter.
The existing VideoZoneTypes enum should stay reusable for:
- examples
- documentation
- future helper utilities
Scheduling
--schedule should follow the same sau convention already used by other platforms:
- no
--schedulemeans immediate publish - providing
--schedulemeans scheduled publish
The internal translation to Bilibili-specific runtime arguments happens inside the adapter layer.
Error Handling
The wrapper should prefer simple, direct failure modes:
- download failure: clearly state that
biliupauto-download failed - update failure: clearly state that the latest release could not be prepared
- login failure: surface
biliuplogin failure with project context - check failure: return
invalid - upload failure: return non-zero and show the upstream error summary
The wrapper should not attempt to over-normalize all upstream error text in v1.
Documentation Impact
When implemented, the following documentation should be updated:
README.mddocs/CLI.md- install/update documentation
- a Bilibili skill similar to the Douyin/Kuaishou skills
- Bilibili example scripts
The user-facing messaging should consistently say:
- users interact with
sau bilibili ... biliupis prepared automatically by the program
Testing Strategy
Minimum verification expected once implemented:
sau bilibili login --account <name>sau bilibili check --account <name>sau bilibili upload-video ...- missing-runtime path triggers auto-download
- existing-runtime path reuses local binary
- outdated-runtime path updates before executing
Manual verification is acceptable for first integration because upstream login and upload are external-platform behaviors.
Recommended Implementation Order
- add
bilibilisubcommands tosau_cli.py - add a minimal resolver that can fetch/update
biliup - add a minimal runner for subprocess execution
- wire
login/check/upload-video - update docs, examples, and skill definitions
Final Decisions
- Public entrypoint stays
sau bilibili ... - First version supports
login,check, andupload-video tidis requiredbiliupis auto-downloaded- every run checks GitHub Releases
- if a newer release exists, auto-update first and continue
- wrapper remains intentionally thin