Skip to main content

bili-dl

Cross-platform Bilibili downloader — a thin, fast wrapper around yt-dlp + ffmpeg.

CI Python 3.11+ PyPI License: MIT

Download Bilibili videos and audio at the best available quality (up to 1080p for non-premium accounts). Cross-platform, zero runtime dependencies, foobar2000-friendly audio output.

Features

  • Cookie-safe — drop any .txt cookie export next to the tool, and only the Bilibili-domain entries are extracted. Other-site cookies are never parsed, stored, or sent anywhere.
  • Cookie-verified — probes Bilibili's nav API to confirm your session is actually logged in before downloading.
  • foobar2000-friendly audio — every produced M4A goes through a zero-loss ffmpeg -c copy remux (moov-first + ISOM container). No re-encode, no quality loss, instant playback in picky players.
  • Zero runtime deps — standard library only. If you have Python, pipx install bili-dl is all you need.
  • Configurable — set defaults in a TOML config file (mode, proxy, output dirs, etc.); CLI flags override per-invocation.
  • Batch download — download a list of URLs from a text file.

Install

bili-dl needs yt-dlp and ffmpeg on your PATH:

pip install -U yt-dlp       # or: winget / brew / pipx
# ffmpeg:
winget install ffmpeg        # Windows
brew install ffmpeg          # macOS
sudo apt install ffmpeg      # Debian/Ubuntu

Then:

pipx install bili-dl         # recommended
bili-dl -V                   # verify

Quick start

Cookies (one-time)

Bilibili requires a login cookie. Use any browser extension that exports cookies in Netscape format (Cookie-Editor, Get cookies.txt, etc.):

  1. Log in to bilibili.com

  2. Export cookies — the file should look like:

    # Netscape HTTP Cookie File
    .bilibili.com	TRUE	/	FALSE	0	SESSDATA	<session>
    .bilibili.com	TRUE	/	FALSE	0	bili_jct	<csrf>
    
  3. Save the exported .txt file in the cookie directory (any filename works):

OS Cookie directory
Windows %APPDATA%\bili-dl
macOS ~/Library/Application Support/bili-dl
Linux ~/.config/bili-dl

Run bili-dl once — it auto-detects any .txt file containing Bilibili entries, extracts only those, and reuses them thereafter. Override with --cookie-dir.

Download

bili-dl                                       # interactive REPL
bili-dl https://www.bilibili.com/video/BV...   # one-shot (video + audio)
bili-dl -a https://www.bilibili.com/video/BV...  # audio only
bili-dl -v https://www.bilibili.com/video/BV...  # video only
bili-dl --batch-file urls.txt                  # batch: download all URLs in file
OS Videos Audio
Windows ~/Videos/bilibili_videos ~/Music/bilibili_audio
macOS ~/Movies/bilibili_videos ~/Music/bilibili_audio
Linux ~/Downloads/bilibili_videos ~/Downloads/bilibili_audio

Override with --output-dir / --audio-dir.

Config file

Save defaults in config.toml (in the cookie directory shown above) so you don't repeat CLI flags every time:

mode = "a"                      # "all" | "v" | "a"
proxy = "http://127.0.0.1:7890"
insecure = false
video_dir = "/path/to/videos"
audio_dir = "/path/to/audio"
cookie_dir = "/path/to/cookies"

All fields are optional — set only what you need. CLI flags always override config file values. Override the config path with --config FILE.

Batch download

Create a text file with one URL per line (# for comments):

# my playlist
https://www.bilibili.com/video/BV1xx...
https://www.bilibili.com/video/BV2xx...
bili-dl --batch-file urls.txt

CLI reference

Flag Description
--all video + audio, merged MP4 + extracted M4A (default)
-v, --video video only (MP4)
-a, --audio audio only (M4A, faststart ISOM)
-k, --insecure skip TLS certificate verification
--proxy URL proxy for yt-dlp (env: HTTPS_PROXY/HTTP_PROXY)
--no-color disable colored output (also: NO_COLOR env var)
--config FILE override config file path
--batch-file FILE download URLs listed in a text file
-V, --version show version
-h, --help show help

Privacy

  • Only Bilibili-domain cookie lines are kept; all others are discarded in memory — never written to disk or sent anywhere.
  • Network requests go only to api.bilibili.com (login probe) and the URLs you provide (via yt-dlp). No telemetry, no analytics.
  • cookies_bilibili.txt is created with a timestamped backup before any overwrite.

License

MIT. bili-dl is a wrapper; the actual downloading is done by yt-dlp (Unlicense) and ffmpeg (LGPL/GPL), which you must install separately.

Release files for bili-dl 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bili-dl 0.2.3
File Size Uploaded
bili_dl-0.2.3.tar.gz 44.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bili-dl 0.2.3
File Interpreter ABI Platform
bili_dl-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 68.6 kB

Release files / bili_dl-0.2.3.tar.gz

Download URL bili_dl-0.2.3.tar.gz
Size 44.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5b81369ee2cd4f66044087a6a718c9a9850c6c0f0691d5036c9f0a21983e139b
BLAKE2b-256 checksum
How to use checksums
eb432107b407e1e72b59c733c3972f298da138bf77ed1b1050e8e7f69f1ccb65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Release files / bili_dl-0.2.3-py3-none-any.whl

Download URL bili_dl-0.2.3-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c572e38389f7aca46853c7e01f1d2a6dc1f654278e9ea15ff4784019afa91964
BLAKE2b-256 checksum
How to use checksums
24d29d2dd99a4fe9c473cd7df18f574e57c88b075f186860aa0632354b864f7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 28, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page