forked from nilaoda/BBDown
-
Notifications
You must be signed in to change notification settings - Fork 18
Developer Guide
aliveranme edited this page Aug 18, 2026
·
2 revisions
本文档为希望参与 BBDown 开发、修改源码或自行从源码构建独立二进制/Docker 镜像的开发者提供完整指引。
- .NET SDK:.NET 10.0 SDK 或更高版本
- 开发工具:Visual Studio 2022+ / JetBrains Rider / VS Code (配合 C# Dev Kit)
- 操作系统:Windows 10/11、macOS (Intel/Apple Silicon) 或 Linux (x64/arm64)
- 外部依赖:FFmpeg(测试混流流程时需要)
git clone https://github.com/aliveranme/BBDown.git
cd BBDownBBDown/
├── BBDown/ # 主控制台应用程序 (CLI / Spectre.Console / API Server)
├── BBDown.Core/ # 核心业务类库 (解析、下载、混流、DRM、弹幕)
├── BBDown.Tests/ # xUnit 单元测试与集成测试工程
├── docs/ # 项目文档与 Wiki 知识库
├── scripts/ # 自动化构建与 Wiki 同步脚本
├── Dockerfile # Native AOT 多阶段 Docker 构建文件
└── BBDown.sln # 解决方案入口
# 还原 NuGet 依赖
dotnet restore
# Debug 构建
dotnet build
# 运行单元测试
dotnet testdotnet run --project BBDown -- --help
# 或直接传入测试视频
dotnet run --project BBDown -- -I "https://www.bilibili.com/video/BV1qt4y1X7TW"BBDown 深度适配了 .NET 的 Native AOT (提前编译) 技术:
- 极小体积与零依赖:生成真正的单文件原生 ELF/PE/Mach-O 二进制,目标机器无需安装任何 .NET Runtime。
- 毫秒级极速冷启动:无 JIT 编译开销,适合频繁作为 CLI 命令调用。
# 1. Windows (x64)
dotnet publish BBDown -c Release -r win-x64 -o ./dist/win-x64
# 2. Linux (x64)
dotnet publish BBDown -c Release -r linux-x64 -o ./dist/linux-x64
# 3. Linux (ARM64 - 如树莓派 / 苹果 M 系列 Linux 容器)
dotnet publish BBDown -c Release -r linux-arm64 -o ./dist/linux-arm64
# 4. macOS (Apple Silicon M1/M2/M3/M4)
dotnet publish BBDown -c Release -r osx-arm64 -o ./dist/osx-arm64
# 5. macOS (Intel x64)
dotnet publish BBDown -c Release -r osx-x64 -o ./dist/osx-x64AOT 开发注意事项: 由于 Native AOT 会在编译时进行全程序剪裁(Trim),在新增功能或数据模型时:
- 避免使用不可推断的动态反射(Dynamic Reflection)。
- JSON 序列化请优先使用
System.Text.Json源生成器(Source Generator)以确保强类型 AOT 兼容。
项目根目录的 Dockerfile 采用多阶段构建,在构建阶段利用 AOT 编译为静态二进制,运行阶段基于极简的 Alpine/Debian 基础镜像,镜像体积通常仅几十 MB:
# 构建本地镜像
docker build -t bbdown:latest .
# 验证镜像运行
docker run --rm bbdown:latest --help欢迎提交 Pull Request!提交前请确保:
- 本地执行
dotnet test所有测试用例均通过。 - 代码符合
.editorconfig规范。 - 任何新增的 CLI 选项或功能请同步更新 docs/wiki/ 中的相关 Wiki 文档。
BBDown Wiki · 由 aliveranme/BBDown 维护 · 基于 MIT 协议开源
- 🏠 首页 (Home)
- 🚀 快速上手 (Getting Started)
- ⚙️ 全命令行参数详解 (CLI Reference)
- 🔑 账号登录与鉴权 (Authentication)
- 📝 配置文件与命名规则 (Configuration)
- 🛠️ 子命令使用指南 (Subcommands)
- 💬 弹幕与评论区抓取 (Danmaku & Comments)
- 📦 批量下载与自动化 (Batch & Automation)
- 🔓 Widevine DRM 原生解密 (DRM Decryption)
- 🌐 API 服务器与 Docker 部署 (API & Docker)
- 🏗️ 内部架构与设计原理 (Architecture)
- 💻 开发者指南与编译构建 (Developer Guide)
- ❓ 常见问题与故障排查 (FAQ)