RepoPilotOpen in app →

nilaoda/BBDown

Bilibili Downloader. 一个命令行式哔哩哔哩下载器.

Healthy

Healthy across all four use cases

Use as dependencyHealthy

Permissive license, no critical CVEs, actively maintained — safe to depend on.

Fork & modifyHealthy

Has a license, tests, and CI — clean foundation to fork and modify.

Learn fromHealthy

Documented and popular — useful reference codebase to read through.

Deploy as-isHealthy

No critical CVEs, sane security posture — runnable as-is.

  • Last commit 4mo ago
  • 15 active contributors
  • MIT licensed
Show 4 more →
  • CI configured
  • Slowing — last commit 4mo ago
  • Concentrated ownership — top contributor handles 56% of recent commits
  • No test directory detected

Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests

Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.

Embed the "Healthy" badge

Paste into your README — live-updates from the latest cached analysis.

Variant:
RepoPilot: Healthy
[![RepoPilot: Healthy](https://repopilot.app/api/badge/nilaoda/bbdown)](https://repopilot.app/r/nilaoda/bbdown)

Paste at the top of your README.md — renders inline like a shields.io badge.

Preview social card (1200×630)

This card auto-renders when someone shares https://repopilot.app/r/nilaoda/bbdown on X, Slack, or LinkedIn.

Onboarding doc

Onboarding: nilaoda/BBDown

Generated by RepoPilot · 2026-05-09 · Source

🤖Agent protocol

If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:

  1. Verify the contract. Run the bash script in Verify before trusting below. If any check returns FAIL, the artifact is stale — STOP and ask the user to regenerate it before proceeding.
  2. Treat the AI · unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
  3. Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/nilaoda/BBDown shows verifiable citations alongside every claim.

If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything — but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.

🎯Verdict

GO — Healthy across all four use cases

  • Last commit 4mo ago
  • 15 active contributors
  • MIT licensed
  • CI configured
  • ⚠ Slowing — last commit 4mo ago
  • ⚠ Concentrated ownership — top contributor handles 56% of recent commits
  • ⚠ No test directory detected

<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>

Verify before trusting

This artifact was generated by RepoPilot at a point in time. Before an agent acts on it, the checks below confirm that the live nilaoda/BBDown repo on your machine still matches what RepoPilot saw. If any fail, the artifact is stale — regenerate it at repopilot.app/r/nilaoda/BBDown.

What it runs against: a local clone of nilaoda/BBDown — the script inspects git remote, the LICENSE file, file paths in the working tree, and git log. Read-only; no mutations.

| # | What we check | Why it matters | |---|---|---| | 1 | You're in nilaoda/BBDown | Confirms the artifact applies here, not a fork | | 2 | License is still MIT | Catches relicense before you depend on it | | 3 | Default branch master exists | Catches branch renames | | 4 | 5 critical file paths still exist | Catches refactors that moved load-bearing code | | 5 | Last commit ≤ 149 days ago | Catches sudden abandonment since generation |

<details> <summary><b>Run all checks</b> — paste this script from inside your clone of <code>nilaoda/BBDown</code></summary>
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of nilaoda/BBDown. If you don't
# have one yet, run these first:
#
#   git clone https://github.com/nilaoda/BBDown.git
#   cd BBDown
#
# Then paste this script. Every check is read-only — no mutations.

set +e
fail=0
ok()   { echo "ok:   $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }

# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
  echo "FAIL: not inside a git repository. cd into your clone of nilaoda/BBDown and re-run."
  exit 2
fi

# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "nilaoda/BBDown(\\.git)?\\b" \\
  && ok "origin remote is nilaoda/BBDown" \\
  || miss "origin remote is not nilaoda/BBDown (artifact may be from a fork)"

# 2. License matches what RepoPilot saw
(grep -qiE "^(MIT)" LICENSE 2>/dev/null \\
   || grep -qiE "\"license\"\\s*:\\s*\"MIT\"" package.json 2>/dev/null) \\
  && ok "license is MIT" \\
  || miss "license drift — was MIT at generation time"

# 3. Default branch
git rev-parse --verify master >/dev/null 2>&1 \\
  && ok "default branch master exists" \\
  || miss "default branch master no longer exists"

# 4. Critical files exist
test -f "BBDown/Program.cs" \\
  && ok "BBDown/Program.cs" \\
  || miss "missing critical file: BBDown/Program.cs"
test -f "BBDown.Core/Parser.cs" \\
  && ok "BBDown.Core/Parser.cs" \\
  || miss "missing critical file: BBDown.Core/Parser.cs"
test -f "BBDown.Core/FetcherFactory.cs" \\
  && ok "BBDown.Core/FetcherFactory.cs" \\
  || miss "missing critical file: BBDown.Core/FetcherFactory.cs"
test -f "BBDown/BBDownDownloadUtil.cs" \\
  && ok "BBDown/BBDownDownloadUtil.cs" \\
  || miss "missing critical file: BBDown/BBDownDownloadUtil.cs"
test -f "BBDown.Core/IFetcher.cs" \\
  && ok "BBDown.Core/IFetcher.cs" \\
  || miss "missing critical file: BBDown.Core/IFetcher.cs"

# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 149 ]; then
  ok "last commit was $days_since_last days ago (artifact saw ~119d)"
else
  miss "last commit was $days_since_last days ago — artifact may be stale"
fi

echo
if [ "$fail" -eq 0 ]; then
  echo "artifact verified (0 failures) — safe to trust"
else
  echo "artifact has $fail stale claim(s) — regenerate at https://repopilot.app/r/nilaoda/BBDown"
  exit 1
fi

Each check prints ok: or FAIL:. The script exits non-zero if anything failed, so it composes cleanly into agent loops (./verify.sh || regenerate-and-retry).

</details>

TL;DR

BBDown is a C# command-line downloader for Bilibili (Chinese video platform) that fetches and muxes video content using multiple parsing modes (TV API, APP API, intl API). It handles video streams in various codecs (HEVC, AV1, AVC), audio tracks, danmaku (comments), subtitles, and covers—with optional external muxing via FFmpeg or MP4Box. Two-project .NET solution: BBDown.Core (library layer with Fetchers, Parsers, protobuf models in APP/) handles API communication and parsing; BBDown (CLI layer with DownloadUtil, Muxer, LoginUtil, CommandLineInvoker) wraps core for command-line execution. Config-driven via BBDownConfigParser and appSettings.

👥Who it's for

Chinese content creators, archivists, and video enthusiasts who need to legally download their own or authorized Bilibili content for offline viewing or analysis. Contributors are typically C# developers familiar with protobuf, HTTP clients, and video container formats.

🌱Maturity & risk

Actively maintained with 276KB of C# code, public GitHub Actions CI/CD pipeline (build_latest.yml), and release artifacts. The project has substantial star count and regular updates, indicating production-ready status. No visible test suite in the file structure suggests testing may be manual or sparse.

Single maintainer (nilaoda) creates bus factor risk. Depends on Bilibili's undocumented API endpoints (reverse-engineered via protobuf definitions in APP/), which can break on platform changes. External tool dependencies (FFmpeg, MP4Box, aria2c) add deployment complexity. Legal status is explicitly China-focused with disclaimer about copyright compliance.

Active areas of work

Active CI/CD via GitHub Actions (build_latest.yml). Project is maintained with releases published to NuGet as a Dotnet Tool package. Recent work likely involves API compatibility fixes (Bilibili changes endpoints frequently) and addition of new parsing modes (intl mode for Southeast Asian versions visible in file list).

🚀Get running

Clone and build with dotnet: git clone https://github.com/nilaoda/BBDown.git && cd BBDown && dotnet build BBDown.sln. Run the CLI from BBDown project: dotnet run -- <bilibili-url> [options]. Or install prebuilt: dotnet tool install --global BBDown.

Daily commands: Build: dotnet build BBDown.sln -c Release. Run CLI: dotnet run --project BBDown -- 'BV1Xx411c7mD' -info (parse only) or dotnet run --project BBDown -- 'BV1Xx411c7mD' -q '1080P 高码率' (download). Use --debug for verbose logging.

🗺️Map of the codebase

  • BBDown/Program.cs — Main entry point and CLI orchestration; all download workflows originate here.
  • BBDown.Core/Parser.cs — Core parsing logic that extracts video metadata and quality information from Bilibili responses.
  • BBDown.Core/FetcherFactory.cs — Factory that routes different content types (bangumi, cheese, normal videos, playlists) to appropriate fetchers.
  • BBDown/BBDownDownloadUtil.cs — Orchestrates the entire download pipeline including quality selection, segment fetching, and muxing.
  • BBDown.Core/IFetcher.cs — Interface defining the contract all fetchers must implement for extensibility.
  • BBDown/BBDownMuxer.cs — Handles FFmpeg/MP4Box integration to merge audio, video, and subtitles into final output.
  • BBDown.Core/Config.cs — Centralized configuration object passed through the entire download pipeline.

🛠️How to make changes

Add support for a new Bilibili content type

  1. Create a new fetcher class in BBDown.Core/Fetcher/ inheriting from IFetcher (BBDown.Core/Fetcher/YourNewInfoFetcher.cs)
  2. Implement Fetch() and Resolve() methods following NormalInfoFetcher.cs pattern (BBDown.Core/Fetcher/NormalInfoFetcher.cs)
  3. Register your fetcher in FetcherFactory.GetFetcher() with a URL pattern match (BBDown.Core/FetcherFactory.cs)
  4. If needed, extend Parser.cs to handle new response structures (BBDown.Core/Parser.cs)

Add a new command-line option

  1. Add property to MyOption class with [Option] attributes (BBDown/MyOption.cs)
  2. Parse and validate the option in BBDownConfigParser.ParseOption() (BBDown/BBDownConfigParser.cs)
  3. Pass through Config object and use in BBDownDownloadUtil.cs or target module (BBDown.Core/Config.cs)

Integrate a new external muxer tool

  1. Extend BBDownMuxer.cs with new muxer detection and execution logic (BBDown/BBDownMuxer.cs)
  2. Add conditional logic in BBDownDownloadUtil.cs to select the muxer (BBDown/BBDownDownloadUtil.cs)
  3. Document tool requirements in MyOption.cs help text (BBDown/MyOption.cs)

Add a new output subtitle format

  1. Extend SubUtil.cs with new format conversion method (BBDown.Core/Util/SubUtil.cs)
  2. Add format option to MyOption.cs (BBDown/MyOption.cs)
  3. Call SubUtil converter in BBDownDownloadUtil.cs before muxing (BBDown/BBDownDownloadUtil.cs)

🔧Why these technologies

  • C# / .NET — Cross-platform CLI application; enables Windows/Linux/macOS single codebase; strong type safety for complex API parsing
  • Protobuf (proto3) — Bilibili's internal API uses protobuf for request/response serialization; must be parsed to extract stream information
  • FFmpeg / MP4Box — Industry-standard external muxers required by Bilibili's segmented streams (separate video/audio); external to avoid licensing complexity
  • aria2c (optional) — Multi-threaded download accelerator for faster segment fetching; optional fallback to built-in HTTP client

⚖️Trade-offs already made

  • External muxer dependency (FFmpeg/MP4Box) instead of pure .NET muxing

    • Why: Bilibili segments require sophisticated codec handling and MP4 container logic; reinventing would be fragile and unmaintainable
    • Consequence: Users must install FFmpeg or MP4Box separately; adds complexity but ensures reliability
  • Factory pattern for fetchers instead of single monolithic parser

    • Why: Bilibili has many content types (normal videos, bangumi, cheese, playlists, intl) with different API endpoints and response formats
    • Consequence: More code files but better maintainability and extensibility; each fetcher focused on one content type
  • Config object passed through entire pipeline instead of dependency injection

    • Why: Simpler for a CLI tool; avoids heavy DI container overhead; matches C# CommandLineParser conventions
    • Consequence: Config object has wide surface area; potential for subtle initialization bugs if fields are added
  • Protobuf code generation from .proto files

    • Why: Bilibili's app API requires
    • Consequence: undefined

🪤Traps & gotchas

Bilibili API endpoints change frequently and are undocumented—protobuf definitions may become stale without active reverse-engineering. FFmpeg/MP4Box binaries must be separately installed and on PATH; --use-mp4box requires MP4Box instead of FFmpeg. APP API mode requires spoofing device headers (device.proto) or requests fail. Danmaku download requires parsing XML-based DM reply format (DanmakuUtil.cs). Some streams have geo-restrictions enforced by intl-vs-normal API selection. Login tokens may expire; BBDownLoginUtil.cs handles refresh but QR code auth (ConsoleQRCode.cs) is interactive-only.

🏗️Architecture

💡Concepts to learn

  • Protocol Buffers (protobuf) — BBDown reverse-engineers Bilibili's wire protocol using .proto definitions (APP/Header/.proto, APP/Payload/.proto, APP/Response/*.proto); understanding how protobuf serialization works is essential to modify API request/response handling
  • HTTP/HTTPS streaming and byte-range requests — Video and audio streams are downloaded via HTTP GET with Range headers for parallel chunk download (aria2c integration); understanding stream resumption and chunking is critical for reliability
  • Video codec selection and transcoding (HEVC, AV1, AVC) — BBDown supports multiple video codecs with user-configurable priority (-e flag); muxing different codecs correctly requires understanding container compatibility (MP4/MOV/MKV) and codec-specific constraints
  • MP4/Matroska container formats and muxing — Final output requires combining separate video, audio, and subtitle streams into a single container using FFmpeg or MP4Box; understanding elementary streams and metadata atoms is needed to debug muxing failures
  • Bilibili Danmaku (comment stream) format — DanmakuUtil.cs parses XML-based danmaku replies with timing, position, and styling metadata; understanding this format is required to extend subtitle/comment export features
  • Factory and Strategy design patterns — FetcherFactory selects between NormalInfoFetcher, BangumiInfoFetcher, CheeseInfoFetcher, and IntlBangumiInfoFetcher based on content type; understanding these patterns is essential to add support for new Bilibili content categories
  • QR code authentication for Bilibili login — ConsoleQRCode.cs implements QR-based OAuth flow for obtaining session tokens; understanding Bilibili's auth flow is required to maintain login functionality when endpoints change
  • iawia002/annie — Similar video downloader architecture (multiple site plugins, stream selection, muxing) but written in Go; useful for cross-language design patterns
  • yt-dlp/yt-dlp — Industry-standard video downloader with plugin-based site support and subtitle/metadata extraction; BBDown follows similar design but specialized for Bilibili
  • SocialSisterYi/bilibili-API-collect — Crowdsourced Bilibili API documentation and reverse-engineering; directly referenced by BBDown maintainers for API discovery
  • yutto/yutto — Alternative Bilibili downloader in Python; helps validate API behavior and provides reference implementation for comparison
  • protocolbuffers/protobuf — Defines protobuf toolchain used to compile .proto files in APP/ directory; understanding protoc is required to regenerate C# models

🪄PR ideas

To work on one of these in Claude Code or Cursor, paste: Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.

Add unit tests for BBDown.Core/Fetcher implementations

The Fetcher classes (NormalInfoFetcher, BangumiInfoFetcher, CheeseInfoFetcher, etc.) handle critical data parsing from Bilibili API responses. Currently, there are no visible test files in the repo structure. Adding unit tests would catch regressions when Bilibili changes their API and ensure each fetcher correctly parses its specific content type (normal videos, bangumi, cheese courses, series, etc.). This is especially important given the project's reliance on reverse-engineered API endpoints.

  • [ ] Create BBDown.Tests project alongside BBDown.Core in the solution
  • [ ] Add test classes for each Fetcher: NormalInfoFetcherTests, BangumiInfoFetcherTests, CheeseInfoFetcherTests, FavListFetcherTests, SeriesListFetcherTests, SpaceVideoFetcherTests
  • [ ] Mock HTTPUtil responses using a test fixture library (xUnit + Moq)
  • [ ] Test parsing of real/sanitized Bilibili API response samples for each content type
  • [ ] Integrate tests into .github/workflows/build_latest.yml to run on each push

Refactor BBDown/Program.cs and Program.Methods.cs into modular command handlers

Program.cs and Program.Methods.cs likely contain large procedural methods handling CLI argument parsing, download orchestration, and output formatting. This monolithic structure makes testing difficult and maintenance harder. Splitting into handler classes (e.g., DownloadCommandHandler, LoginCommandHandler, InfoCommandHandler) following the CommandLineInvoker pattern already present would improve code organization, testability, and allow easier feature additions.

  • [ ] Analyze Program.Methods.cs to identify distinct command workflows (download, login, info, update, etc.)
  • [ ] Create BBDown/Handlers/ directory with separate handler classes for each major command
  • [ ] Extract method logic from Program.Methods.cs into corresponding handler classes with testable dependencies injected
  • [ ] Update CommandLineInvoker.cs to delegate to appropriate handler instead of Program methods
  • [ ] Add unit tests in BBDown.Tests for each handler class with mocked dependencies

Add integration tests for BBDownDownloadUtil with aria2c fallback scenarios

BBDownDownloadUtil.cs and BBDownAria2c.cs handle critical download logic with fallback mechanisms between different downloaders. There are no visible tests validating that aria2c integration works correctly or that fallback to the default downloader occurs properly when aria2c is unavailable. Integration tests would ensure downloads don't silently fail and give confidence when external tool availability changes.

  • [ ] Create BBDown.Tests/Integration/DownloadUtilTests.cs class
  • [ ] Add test cases: successful download via aria2c, aria2c not found fallback, large file chunking scenarios
  • [ ] Mock file system operations and HTTP responses; optionally use TestContainers for aria2c availability testing
  • [ ] Test BBDownDownloadUtil methods with various file sizes, connection scenarios, and proxy configurations
  • [ ] Add GitHub Actions workflow step to run integration tests (can be optional/separate from unit tests given external dependency)

🌿Good first issues

  • Add unit tests for BilibiliBvConverter.cs (AV↔BV ID conversion logic). Current file lacks coverage; conversion bugs could silently pass wrong IDs to API.
  • Document the .proto file regeneration workflow: there's no README or script explaining how to update APP/ protocol buffers when Bilibili changes their APIs, creating friction for maintainers.
  • Extend SubUtil.cs to handle more subtitle formats beyond the current implementation (e.g., VTT export option). Inspect existing code to understand the ASS/SRT parsing and add an exporter for a new format.

Top contributors

Click to expand

📝Recent commits

Click to expand
  • 259a555 — feat: 适配新版空间合集/系列链接并优化合集解析 (#1077) (Q-E-D)
  • d869225 — 优化Linux构建产物的低版本兼容性 (#1067) (nilaoda)
  • 4b47d1b — 修复超过24小时的时长格式化时不正确的问题 (#1052) (nilaoda)
  • 204d728 — 修复断点续传功能 (#1050) (nilaoda)
  • 1cba9b0 — 音频默认排序以码率为准 (nilaoda)
  • 675d082 — EncodingPriority支持音频编码 (#1034) (nilaoda)
  • db26c54 — feat: 支持自定义 TV 请求 host (#1021) (Rovniced)
  • 7c48a07 — BBDown: Docker Support, Webhook Enhancements & Code Cleanup (#997) (AchanYao)
  • 1e17446 — 优化函数名 (nilaoda)
  • a72c5ab — update deps (nilaoda)

🔒Security observations

  • High · Exposed Service Port in Docker — Dockerfile, lines 14-17. The Dockerfile exposes port 23333 and runs the application with 'serve' command listening on 0.0.0.0:23333. This makes the API server accessible to all network interfaces without authentication mechanisms visible in the provided code. Combined with a downloader that may handle user content, this could expose the service to unauthorized access. Fix: 1) Implement authentication and authorization for the API server. 2) Use a reverse proxy (nginx/traefik) with SSL/TLS termination. 3) Restrict network access to the container via firewall rules or network policies. 4) Consider running the service on localhost only if not intended for remote access.
  • High · Unvalidated External Content Handling — BBDown.Core/Fetcher/*.cs, BBDown.Core/APP/Response/*.proto. The application is a Bilibili content downloader that fetches and processes video/media content from external sources. The file structure shows fetchers (NormalInfoFetcher, BangumiInfoFetcher, etc.) and protocol buffer definitions for handling responses. Without visible input validation, this could be vulnerable to malicious payloads in API responses, MITM attacks, or deserialization attacks. Fix: 1) Implement strict validation of all API responses before processing. 2) Use HTTPS for all external communications and validate certificates. 3) Implement timeout mechanisms for network requests. 4) Sanitize and validate protobuf deserialization. 5) Consider implementing HMAC or signature verification for critical operations.
  • High · Missing Dependency Security Information — Dockerfile, BBDown.Core/BBDown.Core.csproj, BBDown/BBDown.csproj. No package lock file (packages.lock.json, project.lock.json) or explicit dependency versions are visible in the provided file structure. The Dockerfile uses .NET 9.0 SDK and aspnet:9.0 runtime without pinned versions, making the build non-deterministic and potentially vulnerable to supply chain attacks if a compromised dependency version is released. Fix: 1) Generate and commit package lock files for all dependencies. 2) Pin specific versions in the Dockerfile (e.g., mcr.microsoft.com/dotnet/sdk:9.0.x-alpine). 3) Implement dependency scanning in CI/CD pipeline. 4) Use tools like NuGet audit or OWASP Dependency-Check. 5) Regularly update and audit dependencies.
  • High · Improper File Handling in Download Utility — BBDown/BBDownDownloadUtil.cs. The presence of BBDownDownloadUtil.cs and file writing operations for downloaded media suggests potential path traversal vulnerabilities if user-supplied filenames or paths are not properly validated before file operations. Fix: 1) Implement strict path validation using Path.GetFullPath() and verify the final path is within the intended directory. 2) Use a whitelist approach for allowed characters in filenames. 3) Never use user-supplied input directly in file paths. 4) Implement canonicalization checks to prevent directory traversal. 5) Run with minimal filesystem permissions.
  • Medium · Potential Command Injection in Aria2c Integration — BBDown/BBDownAria2c.cs. BBDownAria2c.cs suggests integration with aria2c external tool. If command line arguments are built from user input without proper escaping, this could lead to command injection vulnerabilities. Fix: 1) Use ProcessStartInfo with argument lists instead of string concatenation. 2) Never pass user input directly to shell/command line. 3) Use parameterized execution methods available in .NET. 4) Validate and sanitize all user inputs before passing to external tools.
  • Medium · FFmpeg Integration Without Validation — Dockerfile line 13, BBDown/BBDownMuxer.cs. The Dockerfile installs ffmpeg and the codebase includes BBDownMuxer.cs, suggesting video muxing operations. FFmpeg can be vulnerable to various exploits if processing untrusted media files without validation. Fix: 1) Run ffmpeg in a sandboxed environment. 2) Validate media files before processing. 3) Set resource limits (memory, CPU, timeout) for ffmpeg processes. 4) Use the latest stable version of ffmpeg. 5) Run ffmpeg with minimal permissions.
  • Medium · Potential Ins — undefined. undefined Fix: undefined

LLM-derived; treat as a starting point, not a security audit.


Generated by RepoPilot. Verdict based on maintenance signals — see the live page for receipts. Re-run on a new commit to refresh.

Healthy signals · nilaoda/BBDown — RepoPilot