B站视频解析 API

基于 bilibili-parse 的 B站视频解析接口。支持 BV/AV 号、多种清晰度、多种输出格式,免费稳定。

服务正常 BV/AV 支持 多清晰度 多种格式

01功能特性

📹

BV / AV 解析

支持 BV 号和 AV 号两种视频编号格式,兼容所有 B站视频。

🎬

番剧支持

支持番剧 EP 编号解析,type=bangumi 即可解析番剧内容。

多清晰度

支持 360P 到 1080P 多种清晰度,自动降级到可用清晰度。

🔧

多种格式

支持 FLV、DASH、MP4 三种视频格式,满足不同场景需求。

02API 接口

GET /?bv={bv}&p=1&q=80&otype=json

解析 B站视频,返回 JSON 格式的视频信息。

curl
curl "https://yuri.fan/bili/?bv=BV1zYKf6jENs&p=1&q=80&otype=json"
GET /?bv={bv}&p=1&q=80&otype=url

直接返回视频直链 URL,浏览器可直接播放或下载。

curl
curl -L "https://yuri.fan/bili/?bv=BV1zYKf6jENs&p=1&q=80&otype=url" -o video.mp4
GET /?bv={bv}&p=1&q=80&otype=dplayer

返回 DPlayer 播放器页面,可直接嵌入 iframe 播放。

html
<iframe src="https://yuri.fan/bili/?bv=BV1zYKf6jENs&p=1&q=80&otype=dplayer" 
        width="100%" height="500" frameborder="0">
</iframe>
GET /?ep={ep}&type=bangumi&otype=json

解析番剧,使用 EP 编号和 type=bangumi 参数。

curl
curl "https://yuri.fan/bili/?ep=123456&type=bangumi&otype=json"

03参数说明

参数 类型 必填 默认值 说明
bv string 二选一 - 视频 BV 号,如 BV1zYKf6jENs
av string 二选一 - 视频 AV 号,如 av14661594
ep string 番剧用 - 番剧 EP 编号,需配合 type=bangumi
p int 选填 1 视频分P序号,从 1 开始
q int 选填 32 视频清晰度代码
type string 选填 video video / bangumi
format string 选填 flv flv / dash / mp4
otype string 选填 json json / url / dplayer
cookie string 选填 - SESSDATA Cookie,用于解锁 1080P。格式:SESSDATA=xxx

清晰度代码

16 — 360P 流畅 32 — 480P 清晰 64 — 720P 高清 80 — 1080P 高清 112 — 1080P+
💡
BV 与 AV
BV 号和 AV 号二选一即可。BV 号是 B站较新的编号格式(如 BV1zYKf6jENs),AV 号是旧格式(如 av14661594)。
⚠️
1080P 需要登录 Cookie
默认最高返回 480P(q=32)。如需 720P/1080P,需要在请求时带上 cookie 参数。

获取 SESSDATA:浏览器登录 B站 → F12 → Application → Cookies → bilibili.com → 复制 SESSDATA 的值。
用法:在 URL 后面加 &cookie=SESSDATA=你的值
GET /?bv={bv}&q=80&cookie=SESSDATA=xxx

通过 URL 参数直接传入 Cookie,即可解锁 1080P。

curl
curl "https://yuri.fan/bili/?bv=BV1zYKf6jENs&p=1&q=80&otype=json&cookie=SESSDATA=abc123"
curl
curl -L "https://yuri.fan/bili/?bv=BV1zYKf6jENs&p=1&q=80&otype=url&cookie=SESSDATA=abc123" -o video.mp4

04代码示例

JavaScript

JavaScript
async function getBiliVideo(bv, p = 1, q = 80) {
  const url = `https://yuri.fan/bili/?bv=${bv}&p=${p}&q=${q}&otype=json`;

  const response = await fetch(url);
  const data = await response.json();

  console.log('标题:', data.title);
  console.log('视频链接:', data.url);
  console.log('清晰度:', data.quality);

  return data;
}

getBiliVideo('BV1zYKf6jENs', 1, 80);

Python

Python
import requests

def get_bili_video(bv, p=1, q=80):
    url = f'https://yuri.fan/bili/'
    params = {
        'bv': bv,
        'p': p,
        'q': q,
        'otype': 'json'
    }

    response = requests.get(url, params=params, timeout=30)
    data = response.json()

    print(f"标题: {data.get('title')}")
    print(f"视频链接: {data.get('url')}")
    print(f"清晰度: {data.get('quality')}")

    return data

# 下载视频
def download_video(bv, p=1, q=80, output='video.mp4'):
    url = f'https://yuri.fan/bili/?bv={bv}&p={p}&q={q}&otype=url'
    response = requests.get(url, timeout=60)

    with open(output, 'wb') as f:
        f.write(response.content)
    print(f'已保存到 {output}')

get_bili_video('BV1zYKf6jENs')
download_video('BV1zYKf6jENs', output='test.mp4')

PHP

PHP
<?php
function getBiliVideo($bv, $p = 1, $q = 80) {
    $url = 'https://yuri.fan/bili/?' . http_build_query([
        'bv' => $bv,
        'p' => $p,
        'q' => $q,
        'otype' => 'json'
    ]);

    $response = file_get_contents($url);
    $data = json_decode($response, true);

    echo "标题: " . $data['title'] . "
";
    echo "链接: " . $data['url'] . "
";

    return $data;
}

getBiliVideo('BV1zYKf6jENs');

HTML 嵌入播放器

HTML
<!-- DPlayer 播放器 -->
<iframe 
    src="https://yuri.fan/bili/?bv=BV1zYKf6jENs&p=1&q=80&otype=dplayer" 
    width="100%" 
    height="500" 
    frameborder="0" 
    allowfullscreen>
</iframe>

<!-- 或直接跳转播放 -->
<a href="https://yuri.fan/bili/?bv=BV1zYKf6jENs&p=1&q=80&otype=url" target="_blank">
    点击播放
</a>
返回格式说明
otype=json 返回完整视频信息(标题、封面、各清晰度链接等)。
otype=url 直接返回最佳视频直链,适合下载或播放。
otype=dplayer 返回完整播放器页面,适合 iframe 嵌入。