Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:869413421 Ai moive studio BilibiliService upload video

From Leeroopedia
Knowledge Sources
Domains Distribution
Last Updated 2026-10-23 12:00 GMT

Overview

Service that uploads a video to Bilibili via the biliup CLI subprocess, with cookie-based authentication and BV/AV number extraction.

Description

'BilibiliService.upload_video constructs a biliup CLI command with the cookie file (-u flag), upload subcommand, video path, and publishing metadata (title, description, category, tags, copyright, cover). The command is executed as an asyncio.create_subprocess_exec subprocess.

On success, the BV and AV numbers are extracted from stdout via regex. On failure, the error message from stderr is returned.

Usage

Import when uploading videos to Bilibili. Called by BilibiliPublishService.upload_chapter_task.

Code Reference

Source Location

  • Repository: ai-moive-studio
  • File: backend/src/services/bilibili.py:L157-264

Signature

class BilibiliService(BaseService):
    async def upload_video(
        self,
        video_path: str,
        title: str,
        desc: str,
        tid: int,
        cover: Optional[str] = None,
        tag: Optional[str] = None,
        copyright: int = 1,
        source: Optional[str] = None,
        dynamic: Optional[str] = None,
        dtime: Optional[int] = None,
        cookie_file: Optional[str] = None,
        line: str = "bda2",
        limit: int = 3
    ) -> Dict[str, Any]:
        """
        Returns:
            Dict with success, bvid, aid (or error)
        """

Import

from src.services.bilibili import BilibiliService

I/O Contract

Inputs

Name Type Required Description
video_path str Yes Local video file path
title str Yes Video title
desc str Yes Video description
tid int Yes Bilibili category ID
cookie_file str Yes Cookie file path for auth
cover str No Cover image path
tag str No Tags (comma-separated)
copyright int No 1=original, 2=repost (default 1)

Outputs

Name Type Description
return value dict {success, bvid, aid, output} or {success: False, error}

Usage Examples

Uploading a Video

from src.services.bilibili import BilibiliService

service = BilibiliService(db_session)
result = await service.upload_video(
    video_path="/tmp/video.mp4",
    title="My AI Video",
    desc="Generated by AI",
    tid=171,  # tech category
    tag="AI,video",
    copyright=1,
    cookie_file="./data/bilibili_cookies/account-uuid.json",
)
if result["success"]:
    print(f"Published: BV{result['bvid']}")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment