96 lines
2.9 KiB
Markdown
96 lines
2.9 KiB
Markdown
# 📺 Bilibili Video Downloader
|
|
|
|
> A Python tool to **download videos from Bilibili (B站)** with WBI signature authentication, multi-quality selection, and optional ffmpeg audio+video merging.
|
|
|
|
**Bilibili Video Downloader** downloads videos from Bilibili by BV URL. It implements the WBI signature algorithm for API authentication, picks the best available MP4 quality, and supports downloading with **aria2** (fast) or pure-Python fallback, then optionally merges audio & video with **ffmpeg**.
|
|
|
|
---
|
|
|
|
## 📦 Files
|
|
|
|
| File | Description |
|
|
|------|-------------|
|
|
| `bilibili_downloader.py` | Standard version — fill in your `sessdata` cookie manually |
|
|
| `bilibili_downloader_auto.py` | Auto version — edit the `sessdata` variable inside the script |
|
|
|
|
> Both files have identical features. The difference is only how the cookie is provided.
|
|
|
|
---
|
|
|
|
## ✨ Features
|
|
|
|
| Feature | Description |
|
|
|---------|-------------|
|
|
| 🔑 **WBI Signature** | Implements Bilibili WBI signing algorithm for authenticated API calls |
|
|
| 🎞️ **Best MP4 Quality** | Automatically picks the highest available MP4 stream |
|
|
| 🧪 **URL Test** | Verifies content URL accessibility before download |
|
|
| ⚡ **aria2 Support** | Uses aria2 for fast parallel downloads (if installed) |
|
|
| 🐍 **Pure-Python Fallback** | If aria2 is unavailable, downloads directly via Python |
|
|
| 🎬 **ffmpeg Merge** | Merges separate video + audio streams into one file |
|
|
| 📄 **Info Fetch** | Retrieves video metadata (title, etc.) via BV URL |
|
|
|
|
---
|
|
|
|
## 🚀 Quick Start
|
|
|
|
### Prerequisites
|
|
- Python 3.7+
|
|
- `requests` library
|
|
- **Cookie** (`sessdata`) — required for Bilibili access
|
|
- Optional: `aria2` (fast), `ffmpeg` (audio/video merge)
|
|
|
|
### Install
|
|
|
|
```bash
|
|
pip install requests
|
|
```
|
|
|
|
### Setup Cookie
|
|
|
|
1. Log in to Bilibili in your browser
|
|
2. Open DevTools → Application → Cookies → find `sessdata`
|
|
3. Paste it into the script:
|
|
|
|
**`bilibili_downloader.py`** (fill at runtime or edit variable):
|
|
```python
|
|
sessdata = "" # <-- paste your sessdata
|
|
```
|
|
|
|
**`bilibili_downloader_auto.py`** (edit variable directly):
|
|
```python
|
|
sessdata = '填写你的Cookie' # <-- replace with your sessdata
|
|
```
|
|
|
|
### Run
|
|
|
|
```bash
|
|
python bilibili_downloader.py
|
|
# or
|
|
python bilibili_downloader_auto.py
|
|
```
|
|
|
|
Enter a Bilibili video BV URL when prompted (e.g. `BV1xx411c7mD`).
|
|
|
|
---
|
|
|
|
## 📁 Project Structure
|
|
|
|
```
|
|
Bilibili-Video-Downloader/
|
|
├── bilibili_downloader.py # Standard version
|
|
├── bilibili_downloader_auto.py # Auto version (cookie in script)
|
|
└── README.md # This document
|
|
```
|
|
|
|
---
|
|
|
|
## 📄 License
|
|
|
|
This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.
|
|
|
|
---
|
|
|
|
## ⚠️ Disclaimer
|
|
|
|
> This tool is for **personal learning and research only**. Please respect Bilibili's Terms of Service and content creators' copyright. Do not redistribute downloaded content. Use at your own risk.
|