bilibili API 合集(三):番组

技术 · 2022-04-23 · 598 人浏览

bilibili API 合集 - 目录

(一)扫码登录
(二)视频
(三)番组
(四)音乐


番组

注意
本文中的“番组”包括番剧,电影,纪录片,电视剧,综艺,国创等

获取番组信息、剧集列表

https://api.bilibili.com/pgc/view/web/season?ep_id={ep_id}

请求方式:GET
返回类型:json

请求参数说明
ep_idepid 号
返回参数说明
code状态码,0 为成功,非 0 为失败
areas地区
cover封面
evaluate简介
new_ep剧集完结信息
publish上线日期
rating评分
season_idseason_id 号
media_idmedia_id 号
episodes剧集列表
season_title标题
subtitle小标题,即播放数
season系列
sectionPV,特别企划等
stat播放数、点赞数、投币数、收藏数等数据
type番组类型

番组类型

type类型
1番剧
2电影
3纪录片
4国创
5电视剧
7综艺

返回 json 示例 (精简):

{
    "code": 0,
    "message": "success",
    "result": {
        "areas": [
            {
                "id": 2,
                "name": "日本"
            }
        ],
        "cover": "...",
        "episodes": [
            {
                "aid": 253061930,
                "bvid": "...",
                "cid": 482236646,
                "cover": "...",
                "duration": 1421000,
                "id": 450055,
                "link": "...",
                "long_title": "....",
                "pub_time": 1641915000,
                "pv": 0,
                "release_date": "",
                "rights": {
                    "allow_demand": 0,
                    "allow_dm": 1,
                    "allow_download": 0,
                    "area_limit": 0
                },
                "share_copy": "...",
                "share_url": "...",
                "short_link": "...",
                "status": 13,
                "subtitle": "已观看3105.4万次",
                "title": "1",
                "vid": ""
            }
        ],
        "evaluate": "...",
        "media_id": 28235858,
        "new_ep": {
            "desc": "已完结, 全12话",
            "id": 474222,
            "is_new": 0,
            "title": "12"
        },
        "publish": {
            "is_finish": 1,
            "is_started": 1,
            "pub_time": "2022-01-11 23:30:00",
            "pub_time_show": "01月11日23:30",
            "unknow_pub_date": 0,
            "weekday": 0
        },
        "rating": {
            "count": 8597,
            "score": 5.9
        },
        "season_id": 40154,
        "season_title": "...",
        "seasons": [
            "..."
        ],
        "section": [
            "..."
        ],
        "stat": {
            "coins": 81315,
            "danmakus": 156102,
            "favorite": 24485,
            "favorites": 1200168,
            "likes": 397319,
            "reply": 22737,
            "share": 10809,
            "views": 31054276
        },
        "subtitle": "已观看3105.4万次",
        "title": "...",
        "total": 12,
        "type": 1
    }
}

获取下载地址

https://api.bilibili.com/pgc/player/web/playurl?bvid={bvid}&cid={cid}&qn=0&fnver=0&fnval=4048&fourk=1

请求方式:GET
返回类型:json

请求参数说明
bvidBV 号
cidcid
返回参数说明
accept_description清晰度
accept_quality清晰度 id
video视频下载地址,id 为清晰度id,每种清晰度下面都有3个元素,分别是 AVC/H.264,HEVC/H.265,AV1 编码的下载地址,另外 baseUrl,base_url,backupUrl,backup_url 这些地址都是一样的,并无区别
audio音频下载地址,id 为清晰度 id 加上 30200

清晰度

id清晰度
16流畅 360P
32清晰 480P
64高清 720P
80高清 1080P
112高清 1080P+
116高清 1080P60
120超清 4K
125真彩 HDR
127超高清 8K

注意

  • 此接口默认最高能获取到 1080P 的清晰度,对于更高清晰度的视频,请求头中带上大会员 Cookie 中的 SESSDATA 字段即可下载
  • 下载的视频和音频是分开的,需使用 ffmpeg 合成
  • 下载视频和音频的请求头中还要带上 referer 才能下载

返回 json 示例 (精简):

{
    "code": 0,
    "message": "0",
    "ttl": 1,
    "data": {
        "accept_description": [
            "高清 1080P+",
            "高清 1080P",
            "高清 720P",
            "清晰 480P",
            "流畅 360P"
        ],
        "accept_quality": [
            112,
            80,
            64,
            32,
            16
        ],
        "dash": {
            "video": [
                {
                    "id": 80,
                    "baseUrl": "...",
                    "base_url": "...",
                    "backupUrl": [
                        "...",
                        "..."
                    ],
                    "backup_url": [
                        "...",
                        "..."
                    ],
                    "mimeType": "video/mp4",
                    "mime_type": "video/mp4",
                    "codecs": "avc1.640032",
                    "width": 1920,
                    "height": 1080,
                    "frameRate": "25",
                    "frame_rate": "25"
                },
                {
                    "id": 80,
                    "baseUrl": "...",
                    "base_url": "...",
                    "backupUrl": [
                        "...",
                        "..."
                    ],
                    "backup_url": [
                        "...",
                        "..."
                    ],
                    "mimeType": "video/mp4",
                    "mime_type": "video/mp4",
                    "codecs": "hev1.1.6.L150.90",
                    "width": 1920,
                    "height": 1080,
                    "frameRate": "25",
                    "frame_rate": "25"
                },
                {
                    "id": 80,
                    "baseUrl": "...",
                    "base_url": "...",
                    "backupUrl": [
                        "...",
                        "..."
                    ],
                    "backup_url": [
                        "",
                        ""
                    ],
                    "mimeType": "video/mp4",
                    "mime_type": "video/mp4",
                    "codecs": "av01.0.08M.08.0.110.01.01.01.0",
                    "width": 1920,
                    "height": 1080,
                    "frameRate": "25",
                    "frame_rate": "25"
                },
                        ...
                        ...
            ],
            "audio": [
                {
                    "id": 30280,
                    "baseUrl": "...",
                    "base_url": "...",
                    "backupUrl": [
                        "...",
                        "..."
                    ],
                    "backup_url": [
                        "...",
                        "..."
                    ],
                    "mimeType": "audio/mp4",
                    "mime_type": "audio/mp4",
                    "codecs": "mp4a.40.2"
                },
                ...
                        ...
            ]
        }
    }
}

声明

本文由 Scott Sloan 原创,转载请标明原作者。

bilibili API
Theme Jasmine by Kent Liao