From a59cc11a923b6ce7726a272702c11426ae40d1a5 Mon Sep 17 00:00:00 2001
From: SocialSisterYi <45892418+SocialSisterYi@users.noreply.github.com>
Date: Fri, 16 Oct 2020 21:06:34 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=90=E8=8E=B7=E5=8F=96?=
=?UTF-8?q?=E7=9B=B4=E6=92=AD=E6=B5=81url=E3=80=91api?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +-
live/{live_flow.md => live_stream.md} | 79 +++++++++++++++++-------
live/{info_flow.md => message_stream.md} | 0
3 files changed, 58 insertions(+), 25 deletions(-)
rename live/{live_flow.md => live_stream.md} (51%)
rename live/{info_flow.md => message_stream.md} (100%)
diff --git a/README.md b/README.md
index 4cd7dbe..c0d7ea4 100644
--- a/README.md
+++ b/README.md
@@ -148,8 +148,8 @@ PS:所有http协议地址均可使用https,文档中为了统一写作`http`
- [直播分区](live/live_area.md)×
- [直播间管理](live/manage.md)×
- 直播间操作
- - [直播视频流](live/live_flow.md)×
- - [直播信息流](live/info_flow.md)×
+ - [直播视频流](live/live_stream.md)×
+ - [直播信息流](live/message_stream.md)×
- 答题
- B币钱包
- 基本信息
diff --git a/live/live_flow.md b/live/live_stream.md
similarity index 51%
rename from live/live_flow.md
rename to live/live_stream.md
index 1005a84..907845f 100644
--- a/live/live_flow.md
+++ b/live/live_stream.md
@@ -1,10 +1,8 @@
# 直播间视频流
-
-
## 根据真实直播间号获取直播视频流
-> https://api.live.bilibili.com/room/v1/Room/playUrl
+> http://api.live.bilibili.com/room/v1/Room/playUrl
*请求方式:GET*
@@ -12,10 +10,10 @@
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
| ------ | ---- | ----------- | ------ | ---- |
-| cid | num | 目标真实直播间号 | 必要 | 为直播间的room_id号 |
-| quality | num | 画质等级 | 非必要 | 画质选择,4为最高画质,qn和quality参数二选一 |
-| platform | str | 直播流格式 | 非必要 | h5为m3u8格式,web为flv格式,默认为flv格式 |
-| qn | str | 画质等级 | 非必要 | 可选参数为1000、150、80,qn和quality参数二选一 |
+| cid | num | 目标真实直播间号 | 必要 | 直播间的`room_id`(非短号) |
+| platform | str | 直播流格式 | 非必要 | h5:hls方式
web:http-flv方式
默认为http-flv方式 |
+| quality | num | 画质 | 非必要 | `qn`与`quality`任选其一
2:流畅
3:高清
4:原画 |
+| qn | str | 画质 | 非必要 | `qn`与`quality`任选其一
80:流畅
150:高清
400:蓝光
10000:原画 |
**json回复:**
@@ -23,7 +21,7 @@
| 字段 | 类型 | 内容 | 备注 |
| ------- | ---- | -------- | --------------------------- |
-| code | num | 返回值 | 0:成功
-400:参数错误 |
+| code | num | 返回值 | 0:成功
-400:参数错误
19002003:房间信息不存在 |
| message | str | 错误信息 | 默认为0 |
| ttl | str | 1 | |
| data | obj | 信息本体 | |
@@ -33,31 +31,62 @@
| 字段 | 类型 | 内容 | 备注 |
| -------------- | ---- | ------------- | ------------------------ |
-| current_quality | num | 可选画质数量 | |
-| accept_quality | obj | 可选画质数参数 | |
-| current_qn | num | 可选画质数量 | |
-| quality_description | obj | 可选画质参数 | |
-| durl | obj | 直播流url | |
+| current_quality | num | 当前画质代码`qn` | |
+| accept_quality | array | 可选画质数参数 | |
+| current_qn | num | 当前画质代码`quality` | |
+| quality_description | array | 可选画质参数`quality` | |
+| durl | array | 直播流url组 | |
-`durl`对象:
+`accept_quality`数组:
+
+| 项 | 类型 | 内容 | 备注 |
+| ---- | ---- | ----------------- | ---- |
+| 0 | str | `qn`画质代码1 | |
+| n | str | `qn`画质代码(n+1) | |
+| …… | str | …… | …… |
+
+`quality_description`数组:
+
+| 项 | 类型 | 内容 | 备注 |
+| ---- | ---- | ------------- | ---- |
+| 0 | obj | 画质代码1 | |
+| n | obj | 画质代码(n+1) | |
+| …… | obj | …… | …… |
+
+`quality_description`数组中的对象:
+
+| 字段 | 类型 | 内容 | 备注 |
+| ---- | ---- | -------------------- | ---- |
+| qn | num | 画质代码 | |
+| desc | str | 该代码对应的画质名称 | |
+
+`durl`数组:
+
+| 项 | 类型 | 内容 | 备注 |
+| ---- | ---- | ----------- | ---- |
+| 0 | obj | 主线服务器 | |
+| n | obj | 备线n服务器 | |
+| …… | obj | …… | …… |
+
+`durl`数组中的对象:
| 字段 | 类型 | 内容 | 备注 |
| -------------- | ---- | ------------- | ------------------------ |
-| url | str | 直播流url | |
-| length | num | 未知 | |
-| order | num | 未知 | |
-| stream_type | num | 未知 | |
-| p2p_type | num | 未知 | |
-
-
+| url | str | 直播流url | flv或m3u8格式
**注:带有转义** |
+| length | num | 0 | 作用尚不明确 |
+| order | num | 服务器线路序号 | |
+| stream_type | num | 0 | 作用尚不明确 |
+| p2p_type | num | 0 | 作用尚不明确 |
**示例:**
查询直播间`CID=14073662`的直播间信息
```shell
-curl -G 'http://api.live.bilibili.com/room/v1/Room/room_init'\
---data-urlencode 'id=14073662'
+curl -G 'http://api.live.bilibili.com/room/v1/Room/playUrl' \
+--data-urlencode 'id=14073662' \
+--data-urlencode 'qn=10000' \
+--data-urlencode 'platform=web'
```
@@ -125,3 +154,7 @@ curl -G 'http://api.live.bilibili.com/room/v1/Room/room_init'\
```
+
+## 播放直播流媒体
+
+以上获得到`url`字段中的值为直播流url,例如`https://d1--cn-gotcha04.bilivideo.com/live-bvc/601131/live_14073662_bs_3699814_1500.flv?cdn=cn-gotcha04&expires=1602496530&len=0&oi=1939228219&pt=&qn=150&trid=e6540d81a5d04c2ea459c46ebe77472a&sigparams=cdn,expires,len,oi,pt,qn,trid&sign=20e4ac695fbdd1d11d5dac4f93caa783&ptype=0&src=9&sl=1&order=1`导入播放器即可播放直播
\ No newline at end of file
diff --git a/live/info_flow.md b/live/message_stream.md
similarity index 100%
rename from live/info_flow.md
rename to live/message_stream.md