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

Principle:869413421 Ai moive studio Publish Task Tracking

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

Overview

Technique for tracking the lifecycle of content publishing tasks through a state machine with status transitions, Celery task association, and dashboard-level monitoring.

Description

Publish Task Tracking manages the state machine for content distribution tasks. A PublishTask record links a video task, a Bilibili account, and publishing metadata, and transitions through a defined set of statuses:

  • pending: Task created, awaiting processing
  • uploading: Task picked up by Celery worker, download and upload in progress
  • published: Upload completed successfully, BV/AV numbers recorded
  • failed: Upload failed, error message recorded

The DashboardService aggregates publish task statistics across users, providing visibility into publishing success rates, recent activity, and task distribution by status.

Key design:

  • The Celery task ID is stored on the PublishTask for cross-referencing with the Celery task system
  • Status transitions are guarded by the model's state methods (mark_as_uploading, mark_as_published, mark_as_failed)
  • Multi-account support: each task is associated with a specific Bilibili account

Usage

Use this principle when building content distribution pipelines that need task lifecycle management. Apply when publish operations are asynchronous (Celery tasks) and require status tracking for monitoring and retry. Use when dashboard-level statistics are needed for visibility.

Theoretical Basis

# Abstract state machine
class PublishTask:
    status: str  # pending | uploading | published | failed
    bvid: Optional[str]
    aid: Optional[str]
    celery_task_id: Optional[str]
    error_message: Optional[str]

    def mark_as_uploading(self):
        self.status = "uploading"
        self.celery_task_id = celery_task_id

    def mark_as_published(self, bvid, aid):
        self.status = "published"
        self.bvid = bvid
        self.aid = aid

    def mark_as_failed(self, error):
        self.status = "failed"
        self.error_message = error

Practical Guide

  • Use explicit state transition methods on the model to guard valid transitions
  • Store Celery task ID for cross-referencing with the async task system
  • Record both BV and AV numbers on successful publication
  • Capture error messages on failure for debugging
  • Aggregate statistics in a dashboard service for visibility
  • Support multiple Bilibili accounts per user

Related Pages

Implemented By

Page Connections

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