Skip to content

About

biliLiveExtractor is a tool that extracts playable stream URLs from Bilibili live rooms. biliLiveExtractor 是一个用于提取B站直播间真实推流地址的工具。

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Bilibili Live Stream Extractor

GitHub stars GitHub forks License

Live Instances:

Extract playable stream URLs from Bilibili live rooms and videos with:

  • Web app: Vite-built static frontend + Vercel serverless proxy
  • CLI: Python script for terminal usage (live rooms only)

QR login is optional, but enables higher qualities like Original / 4K / Dolby for live rooms and 1080P / 4K / HDR for videos.

⭐ If this project helps you, please star it on GitHub.


Features

Live rooms

  • Accepts room input as:
    • full live URL (https://live.bilibili.com/12345)
    • room ID (12345)
    • short link (b23.tv/xxxx)
  • Optional QR-code login for premium qualities
  • Returns best stream URL quickly
  • Supports listing all available quality/protocol/codec combinations

Videos

  • Accepts video input as:
    • full video URL (https://www.bilibili.com/video/BV1xxxxxxxxx?p=2)
    • BV ID (BV1xxxxxxxxx) or av ID (av170001; bare numbers are treated as live room IDs)
    • short link (b23.tv/xxxx, resolved server-side to a live room or a video)
  • Multi-part videos: pick the part (分 P) from a dropdown; streams are fetched per part
  • DASH tracks for every quality and codec (AVC / HEVC / AV1) plus separate audio tracks (AAC / Dolby / Hi-Res), and a single-file MP4 when Bilibili offers one
  • "Best" picks the highest quality with the most compatible codec and pairs it with the best regular audio track
  • Shows which higher qualities are locked behind login or a premium account
  • One-click copy mpv command that sets the Referer and merges the video and audio tracks
  • WBI-signed requests against Bilibili's current playurl endpoint

Video URLs require a Referer. Bilibili's video CDN only serves requests that carry Referer: https://www.bilibili.com/, so pasting a video URL straight into a browser returns 403. Use a player that supports custom headers (mpv, PotPlayer, ffmpeg) or the copied mpv command. Live stream URLs do not have this restriction.

General

  • Browser-side cookie storage only (not persisted server-side)
  • Interface in English, 简体中文 and 繁體中文

Project Structure

public/            Static frontend (Vite entry: main.mjs; source scripts unchanged)
  locales/         UI translations (en, zh-cn, zh-hk)
api/
  _lib/bili.js     Shared Bilibili helpers, input classification, quality maps
  _lib/wbi.js      WBI request signing (w_rid / wts)
  qrcode/
    generate.js    Generate login QR code
    poll.js        Poll login status and capture cookies
  resolve.js       GET /api/resolve?input=<anything>       -> live room or video
  room.js          GET /api/room?input=<url|id|b23.tv>
  streams.js       GET /api/streams?input=<url|id|b23.tv>
  video.js         GET /api/video?input=<url|BV|av|b23.tv>  -> title, owner, parts
  video-streams.js GET /api/video-streams?input=<BV|av>&cid=<part cid>
vercel.json        Build, cache headers and serverless function config
vite.config.mjs    Vite build config (content-hashed assets into dist/)

Quick Start

Web App (Vercel)

npm i -g vercel
vercel        # preview
vercel --prod # production

Or import this repository at vercel.com/new.

Local Development

npm install
vercel dev     # full stack: Vite frontend + /api functions
npm run dev    # frontend only (no /api)
npm run build  # production build into dist/

Then open http://localhost:3000.

CLI

pip install -r requirements.txt
python Bilibili_Live_Stream_Extractor.py <live_url_or_room_id>
python Bilibili_Live_Stream_Extractor.py 12345 --allstream

Security & Cookie Handling

  • Cookies are captured from Bilibili only after successful QR confirmation.
  • Cookies are stored in browser localStorage.
  • Cookies are sent to backend APIs only through the x-bili-cookies header.
  • No cookie persistence is performed on the server.

Star History

Star History Chart

Notes

  • Stream URLs are time-limited and may expire.
  • Video stream URLs (DASH tracks and MP4) only play with Referer: https://www.bilibili.com/; see the Features section.
  • Without login, videos are capped at 480P; login unlocks 1080P, and 4K / HDR / Dolby need a premium (大会员) account.
  • For personal use only. Please respect Bilibili's terms of service.

About

biliLiveExtractor is a tool that extracts playable stream URLs from Bilibili live rooms. biliLiveExtractor 是一个用于提取B站直播间真实推流地址的工具。

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages