Principle:869413421 Ai moive studio Content Distribution
| Knowledge Sources | |
|---|---|
| Domains | Distribution, Automation |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
Technique for publishing generated videos to Bilibili via QR-code account login, cookie-based authentication, and CLI-driven video upload with status tracking.
Description
Content Distribution automates the publishing of generated videos to the Bilibili platform. The process involves:
- Account authentication: Users register Bilibili accounts via QR-code login through the biliup CLI. The login session is stored as a cookie JSON file (account-specific path).
- Publish task creation: A PublishTask record links a video task, a Bilibili account, and publishing metadata (title, description, tags, category, cover, copyright type).
- Video upload: The video file is downloaded from MinIO storage and uploaded via the biliup CLI subprocess. The CLI handles authentication via the cookie file and returns the Bilibili video ID (BV number).
- Status tracking: The PublishTask model tracks status transitions: pending → uploading → published/failed, storing the BV and AV numbers on success.
Key design decisions:
- CLI subprocess: The biliup binary is invoked as a subprocess (not a Python library) for isolation
- Cookie management: Each account has a dedicated cookie file; cookies are validated for token presence
- Multi-account support: Users can register multiple Bilibili accounts with a default account
Usage
Use this principle when automating video publishing to Bilibili. Apply when generated content needs to be distributed to a video platform with authentication, metadata, and upload tracking. Use when CLI-based upload tools are the available integration method.
Theoretical Basis
# Abstract distribution flow
# 1. Account login (manual QR scan)
command = f"{biliup_path} login"
# After login: mv cookies.json {account_id}.json
# 2. Validate cookie
cookie_data = json.load(cookie_file)
has_token = bool(cookie_data.get('token_info', {}).get('access_token'))
# 3. Upload via CLI subprocess
cmd = [biliup_path, "-u", cookie_file, "upload", video_path,
"--title", title, "--desc", desc, "--tid", str(tid),
"--copyright", str(copyright)]
process = await asyncio.create_subprocess_exec(*cmd)
bvid = extract_bvid(process.stdout) # BVxxxxxxx
# 4. Update status
publish_task.mark_as_published(bvid=bvid, aid=aid)
Practical Guide
- Use the biliup CLI as a subprocess for video upload (not a Python library)
- Store cookie files per account in a dedicated directory
- Validate cookie files for token_info.access_token before upload
- Download video from MinIO to a local temp file before CLI upload
- Extract BV and AV numbers from CLI output via regex
- Track publish task status through a state machine (pending → uploading → published/failed)
- Support multiple accounts per user with a default account