Skip to content

Commit

Permalink
feat: 更新web端视频操作播放合集相关接口 (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
SessionHu authored Jul 27, 2024
1 parent 64f8643 commit 2465990
Show file tree
Hide file tree
Showing 8 changed files with 1,651 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ B站 API 采用 C/S 结构,大多数接口为 REST API 和 gRPC,少部分接
- [x] [图片格式化](docs/misc/picture.md)
- [x] [bvid 说明](docs/misc/bvid_desc.md)
- [ ] [设备唯一标识BUVID](docs/misc/device_identity.md)
- [ ] [获取 buvid3 / buvid4](docs/misc/buvid3_4.md)
- [ ] [获取 buvid3 / buvid4 / b_nut](docs/misc/buvid3_4.md)
- [ ] [gRPC API 接口定义](grpc_api)
- [ ] [登录](docs/login)
- [x] [登录操作 (人机认证)](docs/login/login_action)
Expand Down
2 changes: 1 addition & 1 deletion docs/live/follow_up_live.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 用户关注的所有UP的直播情况

> https://api.bilibili.com/x/space/wbi/acc/info
> https://api.live.bilibili.com/xlive/web-ucenter/user/following
*请求方式:GET*

Expand Down
39 changes: 38 additions & 1 deletion docs/misc/buvid3_4.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 获取 buvid3 / buvid4
# 获取 buvid3 / buvid4 / b_nut

## 游客获取 buvid3 / buvid4

Expand Down Expand Up @@ -46,3 +46,40 @@ curl -G 'https://api.bilibili.com/x/frontend/finger/spi'
```

</details>

## 从响应头获取 buvid3 / b_nut

使用 `GET``HEAD` 方法请求 `https://www.bilibili.com/`, 且请求头中 `User-Agent` 字段不包含 `curl` `python` `awa` 等敏感子字符串, 且相同 `User-Agent` 字段不得短时多次请求. 在响应头中的 `Set-Cookie` 字段中, 即可找到 `buvid3``b_nut`.

若不带任何 Cookie 请求, 则 `b_nut` 为响应生成时刻的 UNIX 秒级时间戳.
若请求 Cookie 仅带有 `buvid3`, 则 `b_nut``100`.
若请求 Cookie 仅带有 `b_nut`, 则与不带任何 Cookie 的响应相同.
若请求 Cookie 仅带有 `buvid3``b_nut`, 则响应无 `Set-Cookie` 字段.
若请求 Cookie 带有其他字段, 无影响.

**示例:**

```shell
curl -I "https://www.bilibili.com/" -A "awa"
```

<details>
<summary>查看响应示例:</summary>

```http
HTTP/2 200
date: Fri, 26 Jul 2024 06:38:43 GMT
content-type: text/html; charset=utf-8
support: nantianmen
set-cookie: buvid3=805E4894-96A2-0684-6F00-C6EA1FFB911023315infoc; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com
set-cookie: b_nut=1721975923; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com
vary: Origin,Accept-Encoding
idc: shjd
expires: Fri, 26 Jul 2024 06:38:42 GMT
cache-control: no-cache
x-cache-webcdn: MISS from blzone01
x-cache-time: 0
x-save-date: Fri, 26 Jul 2024 06:38:43 GMT
```

</details>
2 changes: 1 addition & 1 deletion docs/user/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
| title | str | 直播间标题 | |
| cover | str | 直播间封面 url | |
| watched_show | obj | | |
| roomid | num | 直播间 id(短号) | |
| roomid | num | 直播间 id | |
| roundStatus | num | 轮播状态 | 0:未轮播<br />1:轮播 |
| broadcast_type | num | 0 | |

Expand Down
86 changes: 81 additions & 5 deletions docs/video/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,17 @@ curl 'https://app.bilibili.com/x/v2/view/like' \

</details>

### 判断视频是否被点赞(双端)
### 判断视频近期是否被点赞(双端)

> https://api.bilibili.com/x/web-interface/archive/has/like
*请求方式:GET*

认证方式:APP或Cookie(SESSDATA)

注: 这一 API 实际上只能判断出视频**在近期内**是否被点赞, 并不能判断出视频是否被点赞.
「近期」的定义不明, 但至少半年前点赞过的视频, 用这一接口获取到的结果就已经是 `0` 了. 参见 [#380](https://github.com/SocialSisterYi/bilibili-API-collect/issues/380).

**url参数:**

| 参数名 | 类型 | 内容 | 必要性 | 备注 |
Expand Down Expand Up @@ -459,8 +462,6 @@ curl -G 'https://api.bilibili.com/x/web-interface/archive/coins' \
### 收藏视频(双端)

> https://api.bilibili.com/medialist/gateway/coll/resource/deal
>
> https://api.bilibili.com/x/v3/fav/resource/deal
*请求方式:POST*

Expand All @@ -475,8 +476,8 @@ curl -G 'https://api.bilibili.com/x/web-interface/archive/coins' \
| access_key | str | APP 登录 Token | APP 方式必要 | |
| rid | num | 稿件 avid | 必要 | |
| type | num | 必须为2 | 必要 | |
| add_media_ids | nums | 需要加入的收藏夹 mlid | 非必要 | 同时添加多个,用`,`(%2C)分隔 |
| del_media_ids | nums | 需要取消的收藏夹 mlid | 非必要 | 同时取消多个,用`,`(%2C)分隔 |
| add_media_ids | nums | 需要加入的收藏夹 mlid | 非必要(可选) | 同时添加多个,用`,`(%2C)分隔 |
| del_media_ids | nums | 需要取消的收藏夹 mlid | 非必要(可选) | 同时取消多个,用`,`(%2C)分隔 |
| csrf | str | CSRF Token(位于 Cookie) | Cookie 方式必要 | |

**json回复:**
Expand Down Expand Up @@ -538,6 +539,81 @@ curl 'https://api.bilibili.com/medialist/gateway/coll/resource/deal' \

</details>

### 收藏视频(Web端)

> https://api.bilibili.com/x/v3/fav/resource/deal
*请求方式: POST*

认证方式: Cookie(SESSDATA)

**正文参数(application/x-www-form-urlencoded):**

| 参数名 | 类型 | 内容 | 必要性 | 备注 |
| ------------- | ---- | ---------------------------------- | ------------ | ------------------------------ |
| rid | num | 稿件 avid | 必要 | |
| type | num | 必须为2 | 必要 | |
| add_media_ids | nums | 需要加入的收藏夹 mlid | 非必要(可选) | 同时添加多个,用`,`(%2C)分隔 |
| del_media_ids | nums | 需要取消的收藏夹 mlid | 非必要(可选) | 同时取消多个,用`,`(%2C)分隔 |
| csrf | str | CSRF Token (即 Cookie 中 bili_jct) | 必要 | |
| platform | str | 平台标识? | 非必要 | web端: web |
| eab_x | num | 1 | 非必要 | 作用尚不明确 |
| ramval | num | 正整数 | 非必要 | 可能与在该页面的停留时间相关? |
| ga | num | 1 | 非必要 | 作用尚不明确 |
| gaia_source | str | ??? | 非必要 | web端: web_normal |

**JSON回复:**

根对象:

| 字段 | 类型 | 内容 | 备注 |
| ------- | ---- | -------- | ------- |
| code | num | 返回值 | 0: 成功<br />-101: 账号未登录<br />-111: csrf 校验失败<br />2001000: 参数错误 |
| message | str | 错误信息 | 默认为0 |
| ttl | num | 1 | |
| data | obj | 信息本体 | 错误时为 null 或不存在 |

`data`对象:

| 字段 | 类型 | 内容 | 备注 |
| ----------- | ---- | --------------------- | ----------------------- |
| prompt | bool | 是否为未关注用户收藏? | false:否<br />true:是 |
| ga_data | null | | 作用尚不明确 |
| toast_msg | str || 作用尚不明确 |
| success_num | num | 0 | 作用尚不明确 |

**示例:**

将视频 `av1906473802` 添加到收藏夹 `1164192068`

```shell
curl -sX POST "https://api.bilibili.com/x/v3/fav/resource/deal" \
--data-urlencode "rid=1906473802" \
--data-urlencode "type=2" \
--data-urlencode "csrf=xxx" \
--data-urlencode "add_media_ids=1164192068" \
-b "SESSDATA=xxx; bili_jct=xxx"
```

<details>
<summary>查看响应示例:</summary>

```json
{
"code": 0,
"message": "0",
"ttl": 1,
"data": {
"prompt": false,
"ga_data": null,
"toast_msg": "",
"success_num": 0
}
}
```

</details>

### 判断视频是否被收藏(双端)

> https://api.bilibili.com/x/v2/fav/video/favoured
Expand Down
Loading

0 comments on commit 2465990

Please sign in to comment.