mirror of
https://github.com/SocialSisterYi/bilibili-API-collect.git
synced 2024-12-25 20:10:06 +08:00
feat: bili_ticket 算法 Java 实现 及 信息补充 及 错误修正 (#1061)
* feat: 空间头图及拼写错误修正 * feat(fav/info.md): code 11010 * fix(misc/sign/wbi.md): java extra params * feat(misc/sign/bili_ticket.md): description and java demo * feat(video_ranking/dynamic.md): 分区视频相关接口 * fix(video_ranking/dynamic.md): 未关闭的标签 * feat(README.md): 补充链接 * feat(clientinfo/ip.md): 查询任意 IP 地址的归属地 * feat: get buvid3 buvid4 from api * feat: new error code & format * feat(misc/picture.md): 图片格式化更多规则
This commit is contained in:
parent
750dd6a924
commit
18c1efbc10
@ -67,11 +67,13 @@ B站 API 采用 C/S 结构,大多数接口为 REST API 和 gRPC,少部分接
|
||||
- [x] [APP API 签名](docs/misc/sign/APP.md)(`appkey`与`sign`)
|
||||
- [x] [已知的 APPKey](docs/misc/sign/APPKey.md)
|
||||
- [x] [Wbi 签名](docs/misc/sign/wbi.md)(`wts`与`w_rid`)
|
||||
- [ ] [bili_ticket](docs/misc/sign/bili_ticket.md)
|
||||
|
||||
- [x] [公共错误码](docs/misc/errcode.md)
|
||||
- [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)
|
||||
- [ ] [gRPC API 接口定义](grpc_api)
|
||||
- [ ] [登录](docs/login)
|
||||
- [x] [登录操作 (人机认证)](docs/login/login_action)
|
||||
@ -207,6 +209,7 @@ B站 API 采用 C/S 结构,大多数接口为 REST API 和 gRPC,少部分接
|
||||
- [ ] 动态列表
|
||||
- [x] [特定话题动态列表](docs/dynamic/tag_dynamics.md)
|
||||
- [ ] [动态内容](docs/dynamic/get_dynamic_detail.md)
|
||||
- [ ] [导航栏动态](docs/dynamic/nav.md)
|
||||
- [ ] [相簿](docs/album)
|
||||
- [x] [基本信息](docs/album/info.md)
|
||||
- [x] [相簿列表](docs/album/list.md)
|
||||
@ -357,6 +360,7 @@ OR Aifadian:[https://afdian.net/@ShakaiAneE](https://afdian.net/@ShakaiAneE)
|
||||
- [SocialSisterYi/bcut-asr](https://github.com/SocialSisterYi/bcut-asr): 使用必剪API的语音字幕识别
|
||||
- [CzJam/Bili_Realtime_Data](https://github.com/CzJam/Bili_Realtime_Data): Bilibili粉丝与视频实时数据统计
|
||||
- [kingwingfly/fav](https://github.com/kingwingfly/fav): 自动同步bili收藏夹、合集视频到本地的CLI工具(Rust实现,并提供一个文档测试完善的Rust风格的用于构建有状态爬虫的核心库)
|
||||
- [linyuye/Bilibili_crawler](https://github.com/linyuye/Bilibili_crawler): 基于bilibili懒加载api爬取b站动态,视频等评论区
|
||||
|
||||
### 其他
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 通过ip确定地理位置
|
||||
|
||||
## 通过ip确定位置
|
||||
## 根据请求IP确定属地
|
||||
|
||||
> https://api.bilibili.com/x/web-interface/zone
|
||||
|
||||
@ -60,3 +60,94 @@ curl 'https://api.bilibili.com/x/web-interface/zone'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 查询任意 IP 地址的归属地
|
||||
|
||||
> https://api.live.bilibili.com/ip_service/v1/ip_service/get_ip_addr
|
||||
> https://api.live.bilibili.com/client/v1/Ip/getInfoNew
|
||||
|
||||
注: 两接口等效
|
||||
|
||||
*请求方式:GET*
|
||||
|
||||
**URL参数:**
|
||||
|
||||
|
||||
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
||||
| ------ | ---- | -------- | ------ | ---- |
|
||||
| ip | str | IP地址 | 不必要 | IPv4或IPv6地址不限, 留空与[根据请求IP确定地理位置](#根据请求ip确定地理位置)基本相同 |
|
||||
|
||||
**JSON回复:**
|
||||
|
||||
根对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------- | ---- | -------- | ------- |
|
||||
| code | num | 返回值 | 0: 成功 |
|
||||
| message | str | 错误信息 | 默认为空 |
|
||||
| msg | str | 错误信息 | 同message |
|
||||
| data | obj | 信息本体 | 出错时为空数组 |
|
||||
|
||||
`data`对象:
|
||||
|
||||
与[根据请求IP确定地理位置](#根据请求ip确定地理位置)回复的`data`对象基本相同, 但无 `country_code` 字段
|
||||
|
||||
**示例:**
|
||||
|
||||
查询请求IP地址的归属地:
|
||||
|
||||
```shell
|
||||
curl -G 'https://api.live.bilibili.com/client/v1/Ip/getInfoNew'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>查看响应示例:</summary>
|
||||
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"message": "",
|
||||
"data": {
|
||||
"addr": "104.28.156.113",
|
||||
"country": "新加坡",
|
||||
"province": "新加坡",
|
||||
"city": "",
|
||||
"isp": "cloudflare.com",
|
||||
"latitude": "1.352083",
|
||||
"longitude": "103.819836"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
查询IP地址`8.8.8.8`的归属地:
|
||||
|
||||
```shell
|
||||
curl -G 'https://api.live.bilibili.com/ip_service/v1/ip_service/get_ip_addr' \
|
||||
--data-urlencode 'ip=8.8.8.8'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>查看响应示例:</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "",
|
||||
"message": "",
|
||||
"data": {
|
||||
"addr": "8.8.8.8",
|
||||
"country": "GOOGLE.COM",
|
||||
"province": "GOOGLE.COM",
|
||||
"city": "",
|
||||
"isp": "level3.com",
|
||||
"latitude": "",
|
||||
"longitude": ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------- | ----------------------------- | -------- | --------------------------------------------------- |
|
||||
| code | num | 返回值 | 0:成功<br />-400:请求错误<br />-403:访问权限不足 |
|
||||
| code | num | 返回值 | 0:成功<br />-400:请求错误<br />-403:访问权限不足<br />11010: 内容不存在 |
|
||||
| message | str | 错误信息 | 默认为0 |
|
||||
| data | 有效时:obj<br />无效或:null | 信息本体 | |
|
||||
|
||||
|
@ -161,7 +161,7 @@ curl 'https://api.live.bilibili.com/room/v1/Room/update' \
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------- | ---- | -------- | ------------------------------------------------------------ |
|
||||
| code | num | 返回值 | 0:成功<br />65530:token错误(登录错误)<br />1:错误<br />60009:分区不存在<br />60013:非常抱歉,您所在的地区受实名认证限制无法开播<br />**(其他错误码有待补充)** |
|
||||
| code | num | 返回值 | 0:成功<br />65530:token错误(登录错误)<br />1:错误<br />60009:分区不存在<br />60024: 目标分区需要人脸认证<br />60013:非常抱歉,您所在的地区受实名认证限制无法开播<br />**(其他错误码有待补充)** |
|
||||
| msg | str | 错误信息 | 默认为空 |
|
||||
| message | str | 错误信息 | 默认为空 |
|
||||
| data | obj | 信息本体 | |
|
||||
|
48
docs/misc/buvid3_4.md
Normal file
48
docs/misc/buvid3_4.md
Normal file
@ -0,0 +1,48 @@
|
||||
# 获取 buvid3 / buvid4
|
||||
|
||||
## 游客获取 buvid3 / buvid4
|
||||
|
||||
> https://api.bilibili.com/x/frontend/finger/spi
|
||||
|
||||
*请求方式: GET*
|
||||
|
||||
**JSON回复:**
|
||||
|
||||
根对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------- | ---- | -------- | -------- |
|
||||
| code | num | 返回值 | 0:成功 |
|
||||
| message | str | 信息 | ok: 成功 |
|
||||
| data | obj | 数据本体 | |
|
||||
|
||||
`data`对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ---- | ---- | ------ | ---- |
|
||||
| b_3 | str | buvid3 | 需手动存放至 cookie 中 |
|
||||
| b_4 | str | buvid4 | 同上 |
|
||||
|
||||
**示例:**
|
||||
|
||||
注: 建议自行生成, 不要复制本处示例的 buvid3 / buvid4.
|
||||
|
||||
```shell
|
||||
curl -G 'https://api.bilibili.com/x/frontend/finger/spi'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>查看响应示例:</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"data": {
|
||||
"b_3": "D9656DA8-9BEF-F464-5B72-C4849AFD336379044infoc",
|
||||
"b_4": "F6E0FD4B-520C-1902-4F7B-E461D8D1F5AB79044-024072309-666onEZSnlHVPjoRp4kDYg=="
|
||||
},
|
||||
"message": "ok"
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
@ -248,10 +248,9 @@ print(av2bv(avid: 111298867365120))
|
||||
print(bv2av(bvid: "BV1L9Uoa9EUx"))
|
||||
```
|
||||
|
||||
|
||||
### Java
|
||||
|
||||
```
|
||||
```java
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
@ -266,8 +265,7 @@ public class AVBVConverter {
|
||||
|
||||
private static final String DATA = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
|
||||
|
||||
public static String av2bv(int aidParam) {
|
||||
|
||||
public static String av2bv(long aidParam) {
|
||||
BigInteger aid = BigInteger.valueOf(aidParam);
|
||||
char[] bytes = {'B', 'V', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0'};
|
||||
int bvIndex = bytes.length - 1;
|
||||
@ -275,18 +273,14 @@ public class AVBVConverter {
|
||||
while (tmp.compareTo(BigInteger.ZERO) > 0) {
|
||||
bytes[bvIndex] = DATA.charAt(tmp.mod(BigInteger.valueOf(BASE)).intValue());
|
||||
tmp = tmp.divide(BigInteger.valueOf(BASE));
|
||||
bvIndex -= 1;
|
||||
bvIndex--;
|
||||
}
|
||||
swap(bytes, 3, 9);
|
||||
swap(bytes, 4, 7);
|
||||
StringBuilder sb = new StringBuilder(bytes.length);
|
||||
for (Character ch : bytes) {
|
||||
sb.append(ch);
|
||||
}
|
||||
return sb.toString();
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public static int bv2av(String bvid) {
|
||||
public static long bv2av(String bvid) {
|
||||
char[] bvidArr = bvid.toCharArray();
|
||||
swap(bvidArr, 3, 9);
|
||||
swap(bvidArr, 4, 7);
|
||||
@ -296,7 +290,7 @@ public class AVBVConverter {
|
||||
tmp = tmp.multiply(BigInteger.valueOf(BASE)).add(BigInteger.valueOf(DATA.indexOf(c)));
|
||||
}
|
||||
BigInteger xor = tmp.and(MASK_CODE).xor(XOR_CODE);
|
||||
return xor.intValue();
|
||||
return xor.longValue();
|
||||
}
|
||||
|
||||
|
||||
@ -314,21 +308,17 @@ public class AVBVConverter {
|
||||
final int aid2 = 305988942;
|
||||
final String bv2 = "BV1aP411K7it";
|
||||
|
||||
|
||||
//av ==> bv
|
||||
assert av2bv(aid1).equals(bv1);
|
||||
assert av2bv(aid2).equals(bv2);
|
||||
|
||||
|
||||
//bv ==>av
|
||||
assert bv2av(bv1) == aid1;
|
||||
assert bv2av(bv2) == aid2;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Golang
|
||||
|
||||
```go
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
## 设备唯一标识 BUVID
|
||||
|
||||
注意区分于 Web 端的 buvid3, buvid4.
|
||||
注意区分于 Web 端的 [buvid3, buvid4](buvid3_4.md).
|
||||
|
||||
BUVID 在 APP 首次安装于某设备, 且首次启动时生成.
|
||||
|
||||
|
@ -1,18 +1,33 @@
|
||||
# 图片格式化
|
||||
|
||||
对于\*.hdslb.com/bfs下的图片文件都可以使用以下格式化参数
|
||||
对于 `*.hdslb.com/bfs` 下的图片文件都可以使用以下可选格式化参数.
|
||||
|
||||
> \*.hdslb.com/bfs/\*/\*.\[jpg/png/gif\]@{width}w\_{high}h\_{quality}q.{format}
|
||||
使用 `@` 开始参数 (无论格式如何, 无论是否有参数, 通过计算 HASH 发现, 使用 `@` 均会导致返回图片不同), 多个参数以 `_` 分隔, 图片格式无需分隔且必须放在最后
|
||||
|
||||
| 可选参数 | 含义 | 备注 |
|
||||
| -------- | ---------------- | ---------------- |
|
||||
| width | 图片最大限制宽度 | |
|
||||
| high | 图片最大限制高度 | |
|
||||
| quality | 图片质量百分比 | 仅限webp |
|
||||
| format | 图片格式 | 仅限png/jpg/webp/[avg_color](#avg_color格式说明) |
|
||||
参见: [#191](https://github.com/SocialSisterYi/bilibili-API-collect/issues/191)
|
||||
|
||||
注: jpg 即 jpeg, 二者等效. 网页端常用 AVIF, WebP.
|
||||
|
||||
| 参数 | 格式 | 含义 | 备注 |
|
||||
| ---- | ------- | ---------------- | ---------------- |
|
||||
| w | ${int}w | 图片最大限制宽度 | 范围 [1, 9223372036854775807] |
|
||||
| h | ${int}h | 图片最大限制高度 | 范围 [1, 9223372036854775807] |
|
||||
| s | ${int}s | 作用尚不明确 | 不影响输出结果, 范围 [1, 9223372036854775807] |
|
||||
| e | ${int}e | 改变大小 | 0: 保留比例取其小, 1: 保留比例取其大, 2: 不保留原比例 |
|
||||
| p | ${int}p | 缩放倍数 | 默认100, 范围 [1, 1000] |
|
||||
| o | ${int}o | 作用尚不明确 | 不影响输出结果 范围 [0, 1] |
|
||||
| q | ${int}q | 图片质量百分比 | 仅限webp/jpeg/avif |
|
||||
| c | ${int}c | 裁切图片(如果宽高允许) | 0: 不裁切但会修改图片, 1: 上传时的预设规则(若无则右下), 2: 左上, 3: 右上 |
|
||||
| f | ${int}f | 作用尚不明确 | [0, 1]: 不改变图片, 2: 会改变图片 |
|
||||
| progressive | progressive | 图片编码方式 | 仅限 jpeg(无: baseline, 有: progressive)/png(无:non-interlaced, 有: interlaced) |
|
||||
| ! | !${str} | 加载来源 | web-home-carousel-cover, header, web-dynamic, web-avatar-space-header, ... |
|
||||
| . | .${str} | 图片格式 | 仅限 png/jpeg/webp/avif/[avg_color](#avg_color格式说明) |
|
||||
|
||||
**示例:**
|
||||
|
||||
<details>
|
||||
<summary>查看示例:</summary>
|
||||
|
||||
原始图片
|
||||
|
||||
https://i1.hdslb.com/bfs/archive/e5fff1472bad1c0c6bcb3004205f9be23b58ffc0.jpg
|
||||
@ -43,6 +58,7 @@ https://i1.hdslb.com/bfs/archive/e5fff1472bad1c0c6bcb3004205f9be23b58ffc0.jpg@1q
|
||||
|
||||
![](https://i1.hdslb.com/bfs/archive/e5fff1472bad1c0c6bcb3004205f9be23b58ffc0.jpg@1q.webp)
|
||||
|
||||
</details>
|
||||
|
||||
## avg_color格式说明
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
`bili_ticket` 目前没发现多少风控价值,但是暂且在这里提供一份示例。
|
||||
# BiliTicket
|
||||
|
||||
## 简述
|
||||
|
||||
`bili_ticket` 位于请求头 Cookie 中, 非必需, 但存在可降低风控概率
|
||||
|
||||
由 [@aynuarance](https://github.com/aynuarance) 于 [#903](https://github.com/SocialSisterYi/bilibili-API-collect/issues/903) 提供的思路,根据时间戳使用 `hmac_sha256` 算法计算 `hexsign`。
|
||||
|
||||
|
||||
是 [JWT 令牌](https://jwt.io/),有效时长为 259260 秒,即 3 天。
|
||||
例如 `eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDI3NDI3NDYsImlhdCI6MTcwMjQ4MzQ4NiwicGx0IjotMX0.xQgtTAc41NA1gzvd9yKUPgucUy_DKcQj6OG1vj8V7ZA`
|
||||
|
||||
@ -14,7 +17,18 @@
|
||||
}
|
||||
```
|
||||
|
||||
# Python 示例
|
||||
## 算法
|
||||
|
||||
1. 获取 UNIX 秒级时间戳存入变量如 `timestamp`
|
||||
2. 计算变量 `hexsign` 值,使用 `hmac_sha256` 算法,密钥为 `XgwSnGZ1p`,消息为字符串 `"ts"` 与变量 `timestamp` 值拼接
|
||||
3. 构造请求参数,`key_id` 为 `ec02`,`hexsign` 为变量 `hexsign` 值,`context[ts]` 为变量 `timestamp` 值,`csrf` 为 cookie 中的 `bili_jct` 值也可为空
|
||||
4. 发送 `POST` 请求,获取 `data` 字段中的 `ticket` 字段的值即为所求
|
||||
|
||||
## Demo
|
||||
|
||||
### Python
|
||||
|
||||
需要 `requests` 依赖
|
||||
|
||||
```python
|
||||
import hmac
|
||||
@ -59,4 +73,106 @@ if __name__ == '__main__':
|
||||
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0"
|
||||
}
|
||||
resp = requests.post(url, params=params,headers=headers).json()
|
||||
```
|
||||
print(resp)
|
||||
```
|
||||
|
||||
### Java
|
||||
|
||||
无需第三方依赖
|
||||
|
||||
```java
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class BiliTicketDemo {
|
||||
|
||||
/**
|
||||
* Convert a byte array to a hex string.
|
||||
*
|
||||
* @param bytes The byte array to convert.
|
||||
* @return The hex string representation of the given byte array.
|
||||
*/
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
String hex = Integer.toHexString(0xff & b);
|
||||
if (hex.length() == 1) {
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(hex);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a HMAC-SHA256 hash of the given message string using the given key
|
||||
* string.
|
||||
*
|
||||
* @param key The key string to use for the HMAC-SHA256 hash.
|
||||
* @param message The message string to hash.
|
||||
* @throws Exception If an error occurs during the HMAC-SHA256 hash generation.
|
||||
* @return The HMAC-SHA256 hash of the given message string using the given key
|
||||
* string.
|
||||
*/
|
||||
public static String hmacSha256(String key, String message) throws Exception {
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "HmacSHA256");
|
||||
mac.init(secretKeySpec);
|
||||
byte[] hash = mac.doFinal(message.getBytes(StandardCharsets.UTF_8));
|
||||
return bytesToHex(hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Bilibili web ticket for the given CSRF token.
|
||||
*
|
||||
* @param csrf The CSRF token to use for the web ticket, can be {@code null} or
|
||||
* empty.
|
||||
* @return The Bilibili web ticket raw response for the given CSRF token.
|
||||
* @throws Exception If an error occurs during the web ticket generation.
|
||||
* @see https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/misc/sign/bili_ticket.md
|
||||
*/
|
||||
public static String getBiliTicket(String csrf) throws Exception {
|
||||
// params
|
||||
long ts = System.currentTimeMillis() / 1000;
|
||||
String hexSign = hmacSha256("XgwSnGZ1p", "ts" + ts);
|
||||
StringBuilder url = new StringBuilder(
|
||||
"https://api.bilibili.com/bapis/bilibili.api.ticket.v1.Ticket/GenWebTicket");
|
||||
url.append('?');
|
||||
url.append("key_id=ec02").append('&');
|
||||
url.append("hexsign=").append(hexSign).append('&');
|
||||
url.append("context[ts]=").append(ts).append('&');
|
||||
url.append("csrf=").append(csrf == null ? "" : csrf);
|
||||
// request
|
||||
HttpURLConnection conn = (HttpURLConnection) new URI(url.toString()).toURL().openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0");
|
||||
InputStream in = conn.getInputStream();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int b;
|
||||
while ((b = in.read()) != -1) {
|
||||
out.write(b);
|
||||
}
|
||||
return new String(out.toByteArray(), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method to test the BiliTicketDemo class.
|
||||
*
|
||||
* @param args The command line arguments (not used).
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println(getBiliTicket("")); // use empty CSRF here
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
@ -700,8 +700,6 @@ public class WbiTest {
|
||||
map.put("bar", "五一四");
|
||||
map.put("baz", 1919810);
|
||||
map.put("wts", System.currentTimeMillis() / 1000);
|
||||
map.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
|
||||
map.put("Referer", "https://www.bilibili.com/");
|
||||
StringJoiner param = new StringJoiner("&");
|
||||
//排序 + 拼接字符串
|
||||
map.entrySet().stream()
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
## 获取当前时间戳
|
||||
|
||||
> https://api.bilibili.com/x/report/click/now
|
||||
> https://api.bilibili.com/x/report/click/now
|
||||
> https://api.bilibili.com/x/click-interface/click/now
|
||||
|
||||
*请求方式:GET*
|
||||
|
@ -1008,6 +1008,325 @@ curl -G 'http://space.bilibili.com/ajax/settings/getSettings' \
|
||||
|
||||
</details>
|
||||
|
||||
#### 查询可用头图列表 (Web端)
|
||||
|
||||
> https://space.bilibili.com/ajax/topphoto/getlist
|
||||
|
||||
*请求方式: GET*
|
||||
|
||||
注: 带有转义
|
||||
|
||||
**URL参数:**
|
||||
|
||||
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
||||
| ------ | ---- | ----------- | ------ | -------------------------- |
|
||||
| mid | num | 目标用户mid | 必要 | 非负数, 即使该用户并不存在 |
|
||||
|
||||
**JSON回复:**
|
||||
|
||||
根对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------ | ------------------------- | -------------------------------------- | ---- |
|
||||
| status | bool | 成功: true<br />失败: false | |
|
||||
| data | 成功: array<br/>失败: str | 成功: 信息本体<br />失败: "用户id错误" | |
|
||||
|
||||
`data`数组中的对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------------- | ---- | ----------- | ------------------------------------ |
|
||||
| id | num | 空间头图 ID | |
|
||||
| product_name | str | 显示名称 | |
|
||||
| price | num | 价格 | |
|
||||
| coin_type | num | 支付类型? | |
|
||||
| vip_free | num | 大会员免费 | |
|
||||
| s_img | str | 小图 URI | 需要自行与 `i0.hdslb.com` 拼接成 URL |
|
||||
| l_img | str | 大图 URI | 同 s_img |
|
||||
| thumbnail_img | str | 空 | 并不存在的缩略图? |
|
||||
| sort_num | num | 排序编号 | |
|
||||
| is_disable | num | 已禁用 | 0: 未禁用 |
|
||||
| expire | num | 过期时间? | UNIX 时间戳, 或 0 为永不过期 |
|
||||
| had | num | 是否拥有? | 当 expire 不为 0 时 为 1, 否则为 0 |
|
||||
|
||||
**示例:**
|
||||
|
||||
查询`mid=1145141919810000000`的可用空间头图
|
||||
|
||||
```shell
|
||||
curl -G "https://space.bilibili.com/ajax/topphoto/getlist" \
|
||||
--data-urlencode "mid=1145141919810000000"
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>查看响应示例:</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"status": true,
|
||||
"data": [
|
||||
{
|
||||
"id": 1,
|
||||
"product_name": "bilibili春",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/768cc4fd97618cf589d23c2711a1d1a729f42235.png",
|
||||
"l_img": "bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 19,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"product_name": "两人单车",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/d60a4be11f1bca6168a60a53c64bca18eddd6443.jpg",
|
||||
"l_img": "bfs/space/44873d3568bdcb3d850d234e02a19602972450f1.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 16,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"product_name": "成为偶像",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/5fe2632486a5a91a234f0e7cb368ab6397477da4.jpg",
|
||||
"l_img": "bfs/space/87277d30cd19edcec9db466a9a3e556aeb0bc0ed.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 15,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"product_name": "星际勘探",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/6849abc6e67000ad807b35a970aba31dd1e400dd.jpg",
|
||||
"l_img": "bfs/space/c919a9818172a8297f8b0597722f96504a1e1d88.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 14,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"product_name": "星O大战",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/ff3b0882e55c1099738e59616e5956ad357d9948.jpg",
|
||||
"l_img": "bfs/space/e22f5b8e06ea3ee4de9e4da702ce8ef9a2958f5a.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 13,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"product_name": "王牌特工",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/f5d38e2af44fd12fa65423aff55933fcf9071419.jpg",
|
||||
"l_img": "bfs/space/8cd85a382756ab938df23a856017abccd187188e.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 12,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"product_name": "仰望星空",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/c9dae917e24b4fc17c4d544caf6b6c0b17f8692b.jpg",
|
||||
"l_img": "bfs/space/9ccc0447aebf0656809b339b41aa5b3705f27c47.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 11,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"product_name": "雨过天晴",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/1115b2fdabd128337f892feada4ce32e51f3a5ad.jpg",
|
||||
"l_img": "bfs/space/6a1198e25f8764bd30d53411dac9fdf840bc3265.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 10,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"product_name": "绿荫秘境",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/dc02d22a718c1c436f1a355b3cd726b04098ef7d.jpg",
|
||||
"l_img": "bfs/space/265ecddc52d74e624dc38cf0cff13317085aedf7.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 9,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"product_name": "漫游仙境",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/184abe52a5ea9390b506c064cfba4f8f20ae9cca.jpg",
|
||||
"l_img": "bfs/space/24d0815514951bb108fbb360b04a969441079315.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 7,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"product_name": "放课后time",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/aea2dd7b8894ce31d578d4fad6a7188c7b49cb2f.jpg",
|
||||
"l_img": "bfs/space/6e799ff2de2de55d27796707a283068d66cdf3f4.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 6,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"product_name": "昴宿星团",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/1f4eaf70d1bb981f6057b3e440249d7a1f65774f.jpg",
|
||||
"l_img": "bfs/space/3ab888c1d149e864ab44802dea8c1443e940fa0d.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 5,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"product_name": "蔷薇洛丽塔",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/718eac8c71e29b8a80431c46110805c3a40e30a6.jpg",
|
||||
"l_img": "bfs/space/70ce28bcbcb4b7d0b4f644b6f082d63a702653c1.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 4,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"product_name": "黑暗之门",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/ef1b08e62fdc35b06e39795bc6de8e510935bf97.jpg",
|
||||
"l_img": "bfs/space/cd52d4ac1d336c940cc4958120170f7928d9e606.png",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 3,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"product_name": "你的名字",
|
||||
"price": 0,
|
||||
"coin_type": 0,
|
||||
"vip_free": 0,
|
||||
"s_img": "bfs/space/373e127e8784d3e4c1b5e6db0c27702ba077643f.jpg",
|
||||
"l_img": "bfs/space/f49642b3683a08e3190f29d5a095386451f8952c.jpg",
|
||||
"thumbnail_img": "",
|
||||
"sort_num": 2,
|
||||
"is_disable": 0,
|
||||
"expire": 0,
|
||||
"had": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### 设置空间头图 (Web端)
|
||||
|
||||
> https://space.bilibili.com/ajax/settings/setToutu
|
||||
|
||||
*请求方式: POST*
|
||||
|
||||
认证方式: Cookie (SESSDATA)
|
||||
|
||||
鉴权方式: referer为 `.bilibili.com` 域名下
|
||||
|
||||
**正文参数(application/x-www-form-urlencoded):**
|
||||
|
||||
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
||||
| ------ | ---- | ---------------------------------- | ------ | ---- |
|
||||
| id | num | 头图 ID | 必要 | |
|
||||
| csrf | str | CSRF Token (即 Cookie bili_jct 值) | 不必要 | |
|
||||
|
||||
**JSON回复:**
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------ | ---- | -------- | --------------------------- |
|
||||
| status | bool | 状态 | true: 成功<br />false: 失败 |
|
||||
| data | str | 错误信息 | 正确时无此项 (带有转义) |
|
||||
|
||||
**示例:**
|
||||
|
||||
设置空间头图为为`王牌特工(id=12)`
|
||||
|
||||
```shell
|
||||
curl -X POST "https://space.bilibili.com/ajax/settings/setToutu" \
|
||||
--referer "https://space.bilibili.com/" \
|
||||
--data-urlencode "id=12" \
|
||||
--data-urlencode "csrf=xxx" \
|
||||
-b "SESSDATA=xxx; bili_jct=xxx"
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>查看响应示例:</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"status": true
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
#### 调整空间板块布局
|
||||
|
||||
> http://space.bilibili.com/ajax/settings/setIndexOrder
|
||||
@ -1034,7 +1353,7 @@ curl -G 'http://space.bilibili.com/ajax/settings/getSettings' \
|
||||
| 3 | (左侧)订阅番剧 |
|
||||
| 4 | (左侧)订阅标签 |
|
||||
| 5 | (左侧)最近投币的视频 |
|
||||
| 6 | (左侧)我的圈子**(此板块被隐藏)** |
|
||||
| 6 | (左侧)我的圈子 **(此板块被隐藏)** |
|
||||
| 7 | (左侧)我的频道 |
|
||||
| 8 | (左侧)我的专栏 |
|
||||
| 9 | (左侧)我的相簿 |
|
||||
@ -1050,24 +1369,26 @@ curl -G 'http://space.bilibili.com/ajax/settings/getSettings' \
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------ | ---- | -------- | ----------------------------------- |
|
||||
| ststus | bool | 操作结果 | true:操作成功<br />false:操作失败 |
|
||||
| status | bool | 操作结果 | true:操作成功<br />false:操作失败 |
|
||||
| data | str | 错误信息 | 正确时无此项 |
|
||||
|
||||
**示例:**
|
||||
|
||||
调整空间布局为:
|
||||
|
||||
>我的稿件 直播间
|
||||
>我的专栏 个人资料
|
||||
>订阅番剧 公告
|
||||
>我的收藏夹 官方活动
|
||||
>我的相簿 最近玩的游戏
|
||||
>最近投币的视频
|
||||
>订阅标签
|
||||
>我的频道
|
||||
```text
|
||||
我的稿件 直播间
|
||||
我的专栏 个人资料
|
||||
订阅番剧 公告
|
||||
我的收藏夹 官方活动
|
||||
我的相簿 最近玩的游戏
|
||||
最近投币的视频
|
||||
订阅标签
|
||||
我的频道
|
||||
```
|
||||
|
||||
```shell
|
||||
curl 'http://space.bilibili.com/ajax/settings/setIndexOrder' \
|
||||
curl 'https://space.bilibili.com/ajax/settings/setIndexOrder' \
|
||||
--data-urlencode 'index_order=1,8,3,2,9,5,4,7,22,23,21,24,25,6' \
|
||||
--data-urlencode 'csrf=xxx' \
|
||||
-b 'SESSDATA=xxx;DedeUserID=1;DedeUserID__ckMd5=1;' \
|
||||
@ -1113,7 +1434,7 @@ curl 'http://space.bilibili.com/ajax/settings/setIndexOrder' \
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------ | ---- | -------- | ----------------------------------- |
|
||||
| ststus | bool | 操作结果 | true:操作成功<br />false:操作失败 |
|
||||
| status | bool | 操作结果 | true:操作成功<br />false:操作失败 |
|
||||
| data | str | 错误信息 | 正确时无此项 |
|
||||
|
||||
**示例:**
|
||||
@ -1121,7 +1442,7 @@ curl 'http://space.bilibili.com/ajax/settings/setIndexOrder' \
|
||||
设置`关注的TAG`为隐藏
|
||||
|
||||
```shell
|
||||
curl 'http://space.bilibili.com/ajax/settings/setPrivacy' \
|
||||
curl 'https://space.bilibili.com/ajax/settings/setPrivacy' \
|
||||
--data-urlencode 'tags=0' \
|
||||
--data-urlencode 'csrf=xxx' \
|
||||
-b 'SESSDATA=xxx;DedeUserID=1;DedeUserID__ckMd5=1;' \
|
||||
@ -4298,7 +4619,7 @@ curl -G 'https://api.bilibili.com/x/space/bangumi/follow/list' \
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------ | ---------------------------- | -------------------------------------- | --------------------------- |
|
||||
| ststus | bool | 返回值 | false:错误<br />true:正确 |
|
||||
| status | bool | 返回值 | false:错误<br />true:正确 |
|
||||
| data | 错误时:str<br />正确时:obj | 错误时:错误信息<br />正确时:数据本体 | 正确时不返回错误信息 |
|
||||
|
||||
`data`对象:
|
||||
|
@ -460,7 +460,7 @@ 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
|
||||
> https://api.bilibili.com/x/v3/fav/resource/deal
|
||||
|
||||
*请求方式:POST*
|
||||
|
||||
@ -485,7 +485,7 @@ curl -G 'https://api.bilibili.com/x/web-interface/archive/coins' \
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------- | ---- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| code | num | 返回值 | 0:成功<br />-101:账号未登录<br />-111:csrf校验失败<br />-400:请求错误<br />-403:访问权限不足<br />10003:不存在该稿件<br />11201:已经收藏过了<br />11202:已经取消收藏了<br />11203:达到收藏上限<br />72010017:参数错误 |
|
||||
| code | num | 返回值 | 0:成功<br />-101:账号未登录<br />-111:csrf校验失败<br />-400:请求错误<br />-403:访问权限不足<br />10003:不存在该稿件<br />11010: 您访问的内容不存在<br />11201:已经收藏过了<br />11202:已经取消收藏了<br />11203:达到收藏上限<br />72010017:参数错误 |
|
||||
| message | str | 错误信息 | 正确为success |
|
||||
| data | obj | 信息本体 | |
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
# 分区最新视频
|
||||
|
||||
- [获取分区最新视频列表](#获取分区最新视频列表)
|
||||
|
||||
---
|
||||
|
||||
## 获取分区最新视频列表
|
||||
|
||||
> https://api.bilibili.com/x/web-interface/dynamic/region
|
||||
@ -15,7 +11,7 @@
|
||||
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
||||
| ------ | ---- | ----------- | ------ | ------- |
|
||||
| pn | num | 页码 | 非必要 | 默认为1 |
|
||||
| ps | num | 每页项数 | 非必要 | 默认为5 |
|
||||
| ps | num | 每页项数 | 非必要 | 默认为14, 留空为5 |
|
||||
| rid | num | 目标分区tid | 必要 | |
|
||||
|
||||
**json回复:**
|
||||
@ -197,3 +193,445 @@ curl -G 'https://api.bilibili.com/x/web-interface/dynamic/region' \
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### 获取分区标签近期互动列表
|
||||
|
||||
> https://api.bilibili.com/x/web-interface/dynamic/tag
|
||||
|
||||
*请求方式: GET*
|
||||
|
||||
**url参数:**
|
||||
|
||||
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
||||
| ------ | ---- | ---------- | ------ | ----------------- |
|
||||
| ps | num | 视频数 | 非必要 | 默认为14, 留空为5 |
|
||||
| pn | num | 列数 | 非必要 | 留空为1 |
|
||||
| rid | num | 目标分区id | 必要 | 参见[视频分区一览](../video/video_zone.md) |
|
||||
| tag_id | num | 目标标签id | 必要 | |
|
||||
|
||||
**json回复:**
|
||||
|
||||
与[获取分区最新视频列表](#获取分区最新视频列表)相同, 略
|
||||
|
||||
**示例:**
|
||||
|
||||
获取`tid=136(游戏->音游)`分区中`tag_id=10026108(Phigros)`标签近期互动列表的2条视频信息
|
||||
|
||||
```shell
|
||||
curl -G 'https://api.bilibili.com/x/web-interface/dynamic/tag' \
|
||||
--data-urlencode 'rid=136' \
|
||||
--data-urlencode 'tag_id=10026108' \
|
||||
--data-urlencode 'ps=2' \
|
||||
--data-urlencode 'pn=1'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>查看响应示例:</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"message": "0",
|
||||
"ttl": 1,
|
||||
"data": {
|
||||
"page": {
|
||||
"num": 1,
|
||||
"size": 2,
|
||||
"count": 152
|
||||
},
|
||||
"archives": [
|
||||
{
|
||||
"aid": 1452657587,
|
||||
"videos": 1,
|
||||
"tid": 136,
|
||||
"tname": "音游",
|
||||
"copyright": 1,
|
||||
"pic": "http://i1.hdslb.com/bfs/archive/4cb13f97e0d4b43645728432468e44b40ad343de.jpg",
|
||||
"title": "【MuseDash x Phigros/逆天愚人节谱面】Retribution ~Cycle of Redemption~ Lv.? AP",
|
||||
"pubdate": 1712310000,
|
||||
"ctime": 1712302810,
|
||||
"desc": "谱师:Mayflycmd(@命令提示符 )",
|
||||
"state": 0,
|
||||
"duration": 189,
|
||||
"rights": {
|
||||
"bp": 0,
|
||||
"elec": 0,
|
||||
"download": 0,
|
||||
"movie": 0,
|
||||
"pay": 0,
|
||||
"hd5": 0,
|
||||
"no_reprint": 1,
|
||||
"autoplay": 1,
|
||||
"ugc_pay": 0,
|
||||
"is_cooperation": 0,
|
||||
"ugc_pay_preview": 0,
|
||||
"no_background": 0,
|
||||
"arc_pay": 0,
|
||||
"pay_free_watch": 0
|
||||
},
|
||||
"owner": {
|
||||
"mid": 3493136175204754,
|
||||
"name": "TempoTiger",
|
||||
"face": "https://i1.hdslb.com/bfs/face/0cf2722f9aaa0db94f9166a8084e347bca3580f4.jpg"
|
||||
},
|
||||
"stat": {
|
||||
"aid": 1452657587,
|
||||
"view": 27021,
|
||||
"danmaku": 141,
|
||||
"reply": 113,
|
||||
"favorite": 306,
|
||||
"coin": 144,
|
||||
"share": 95,
|
||||
"now_rank": 0,
|
||||
"his_rank": 0,
|
||||
"like": 1050,
|
||||
"dislike": 0,
|
||||
"vt": 0,
|
||||
"vv": 27021
|
||||
},
|
||||
"dynamic": "",
|
||||
"cid": 1494650111,
|
||||
"dimension": {
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"rotate": 0
|
||||
},
|
||||
"short_link_v2": "https://b23.tv/BV1Eq421w7T4",
|
||||
"first_frame": "http://i0.hdslb.com/bfs/storyff/n240405sa2zsrp9x2i3erx1ln8icirs6_firsti.jpg",
|
||||
"pub_location": "广东",
|
||||
"cover43": "",
|
||||
"bvid": "BV1Eq421w7T4",
|
||||
"season_type": 0,
|
||||
"is_ogv": false,
|
||||
"ogv_info": null,
|
||||
"rcmd_reason": "",
|
||||
"enable_vt": 0,
|
||||
"ai_rcmd": null
|
||||
},
|
||||
{
|
||||
"aid": 1155789590,
|
||||
"videos": 1,
|
||||
"tid": 136,
|
||||
"tname": "音游",
|
||||
"copyright": 1,
|
||||
"pic": "http://i1.hdslb.com/bfs/archive/c75674c8d104421d1794e69926d42ffa90e7d73d.jpg",
|
||||
"title": "[Phigros 自制谱] 把一切都倾注进去吧!/ 雑踏、僕らの街 - TOGENASHI TOGEARI",
|
||||
"pubdate": 1719687153,
|
||||
"ctime": 1719687153,
|
||||
"desc": "不是,你们怎么忍住把这键盘歌写这么简单的?\n不是,你们怎么忍住把这键盘歌写这么简单的?\n不是,你们怎么忍住把这键盘歌写这么简单的?\n\n应该是 Phigros 第一个写满三分钟的,虽然后面抄了很多重复配置,但无伤大雅(\n个人定数 16.6,其实就两段 5k 键盘难,看时间长多给了 0.1\n所以啊\n\n愤怒也好喜悦也好悲伤也好,把一切都倾注进去!\n怒りも喜びも哀しさも、全部ぶちこめ。\n\n-- 6.30 更新,修了一个特效的问题,改了一个很蹭的配置和一个很丑的排键",
|
||||
"state": 0,
|
||||
"duration": 201,
|
||||
"mission_id": 1726375,
|
||||
"rights": {
|
||||
"bp": 0,
|
||||
"elec": 0,
|
||||
"download": 0,
|
||||
"movie": 0,
|
||||
"pay": 0,
|
||||
"hd5": 0,
|
||||
"no_reprint": 1,
|
||||
"autoplay": 1,
|
||||
"ugc_pay": 0,
|
||||
"is_cooperation": 0,
|
||||
"ugc_pay_preview": 0,
|
||||
"no_background": 0,
|
||||
"arc_pay": 0,
|
||||
"pay_free_watch": 0
|
||||
},
|
||||
"owner": {
|
||||
"mid": 341532844,
|
||||
"name": "西宮缄",
|
||||
"face": "https://i1.hdslb.com/bfs/face/1387108d9337c04c27ce2d8d75679e40540d4c14.jpg"
|
||||
},
|
||||
"stat": {
|
||||
"aid": 1155789590,
|
||||
"view": 39479,
|
||||
"danmaku": 303,
|
||||
"reply": 169,
|
||||
"favorite": 1650,
|
||||
"coin": 473,
|
||||
"share": 653,
|
||||
"now_rank": 0,
|
||||
"his_rank": 0,
|
||||
"like": 5843,
|
||||
"dislike": 0,
|
||||
"vt": 0,
|
||||
"vv": 39479
|
||||
},
|
||||
"dynamic": "打这个比溜冰还爽",
|
||||
"cid": 1600971084,
|
||||
"dimension": {
|
||||
"width": 2000,
|
||||
"height": 1500,
|
||||
"rotate": 0
|
||||
},
|
||||
"season_id": 3395535,
|
||||
"short_link_v2": "https://b23.tv/BV1iZ421g7E8",
|
||||
"first_frame": "http://i1.hdslb.com/bfs/storyff/n240630sa3chl8idnpz8d31t6yaczagn_firsti.jpg",
|
||||
"pub_location": "天津",
|
||||
"cover43": "",
|
||||
"bvid": "BV1iZ421g7E8",
|
||||
"season_type": 0,
|
||||
"is_ogv": false,
|
||||
"ogv_info": null,
|
||||
"rcmd_reason": "",
|
||||
"enable_vt": 0,
|
||||
"ai_rcmd": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### 获取分区近期投稿列表
|
||||
|
||||
> https://api.bilibili.com/x/web-interface/newlist
|
||||
|
||||
*请求方式: GET*
|
||||
|
||||
注: 该接口在 Web 端实际情况中被请求, 但似乎未在页面中显示, 作用尚不清楚
|
||||
|
||||
**URL参数:**
|
||||
|
||||
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
||||
| ------ | ---- | ---------- | ------ | ----------------- |
|
||||
| ps | num | 视频数 | 非必要 | 默认为14, 留空为5 |
|
||||
| pn | num | 页码 | 非必要 | 默认为1 |
|
||||
| rid | num | 目标分区id | 非必要 | 参见[视频分区一览](../video/video_zone.md) |
|
||||
| type | num | 类型? | 非必要 | 默认为0 |
|
||||
|
||||
**JSON回复:**
|
||||
|
||||
与[获取分区最新视频列表](#获取分区最新视频列表)相同, 略
|
||||
|
||||
**示例:**
|
||||
|
||||
与[获取分区最新视频列表](#获取分区最新视频列表)相似, 略
|
||||
|
||||
### 获取分区近期投稿列表 (带排序)
|
||||
|
||||
> https://api.bilibili.com/x/web-interface/newlist_rank
|
||||
|
||||
*请求方式: GET*
|
||||
|
||||
**URL参数:**
|
||||
|
||||
| 参数名 | 类型 | 内容 | 必要性 | 备注 |
|
||||
| ----------- | ---- | --------- | ------ | ------- |
|
||||
| main_ver | str | 主页版本 | 非必要 | 默认为 `v3` |
|
||||
| search_type | str | 搜索类型 | 必要 | 默认为 `video` |
|
||||
| view_type | str | 查看类型? | 必要 | 默认为 `hot_rank` |
|
||||
| copy_right | num | 版权? | 非必要 | 默认为 `-1` |
|
||||
| new_web_tag | num | 标签? | 非必要 | 默认为 `1` |
|
||||
| order | str | 排序方式 | 非必要 | click: 按播放排序(默认)<br />scores: 按评论数排序<br />stow: 按收藏排序<br />coin: 按硬币数排序<br />dm: 按弹幕数排序|
|
||||
| cate_id | num | 分区id | 必要 | 留空会导致响应中`data`中`result`为`null`, 参见[视频分区一览](../video/video_zone.md) |
|
||||
| page | num | 页码 | 非必要 | 默认以 `1` 开始 |
|
||||
| pagesize | num | 视频数 | 必要 | 默认为 `30`, 留空会导致 -500 |
|
||||
| time_from | num | 起始时间 | 必要 | yyyyMMdd, 默认为 `time_to` - 7 |
|
||||
| time_to | num | 结束时间 | 必要 | yyyyMMdd, 默认为当前时间(大于起始时间) |
|
||||
|
||||
**JSON回复:**
|
||||
|
||||
根对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ------- | ---- | -------- | ----- |
|
||||
| code | num | 返回值 | 0:成功<br />-500: 未传pagesize<br />-10: 未传其余必要参数 |
|
||||
| message | str | 错误信息 | 无为0 |
|
||||
| ttl | num | 1 | |
|
||||
| data | obj | 信息本体 | 错误为null |
|
||||
|
||||
`data`对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| ---------------- | ----- | ------------------ | ----- |
|
||||
| exp_list | null | | 作用尚不明确 |
|
||||
| show_module_list | array | 显示模块列表? | |
|
||||
| result | array | 结果本体 | 失败时为null |
|
||||
| show_column | num | 0 | 作用尚不明确 |
|
||||
| rqt_type | str | search | 作用尚不明确 |
|
||||
| numPages | num | 页码 | 失败时为0 |
|
||||
| numResults | num | 视频数 | 失败时为0 |
|
||||
| crr_query | str | 空 | 作用尚不明确 |
|
||||
| pagesize | num | 视频数 | |
|
||||
| suggest_keyword | num | 空 | 作用尚不明确 |
|
||||
| egg_info | null | | 作用尚不明确 |
|
||||
| cache | num | 0 | 作用尚不明确 |
|
||||
| exp_bits | num | 1 | 作用尚不明确 |
|
||||
| exp_str | str | 空 | 作用尚不明确 |
|
||||
| seid | str | 一串字符串中的数字 | 作用尚不明确 |
|
||||
| msg | str | 结果信息 | 成功时为`success`, 反之为`as error.` |
|
||||
| egg_hit | num | 0 | 作用尚不明确 |
|
||||
| page | num | 页码 | |
|
||||
|
||||
`data`中的`show_module_list`数组:
|
||||
|
||||
| 项 | 类型 | 内容 | 备注 |
|
||||
| ---- | ---- | ------------- | ---- |
|
||||
| 0 | str | tips | |
|
||||
| 1 | str | brand_ad | |
|
||||
| 2 | str | esports | |
|
||||
| 3 | str | activity | |
|
||||
| 4 | str | web_game | |
|
||||
| 5 | str | card | |
|
||||
| 6 | str | media_bangumi | |
|
||||
| 7 | str | media_ft | |
|
||||
| 8 | str | bili_user | |
|
||||
| 9 | str | user | |
|
||||
| 10 | str | star | |
|
||||
| 11 | str | video | |
|
||||
|
||||
`data`中的`result`数组中的对象:
|
||||
|
||||
| 字段 | 类型 | 内容 | 备注 |
|
||||
| -------------- | ---- | -------------- | ----- |
|
||||
| pubdate | str | 发布时间 | 格式为 `yyyy-MM-dd HH:mm:ss` |
|
||||
| pic | str | 封面图 | |
|
||||
| tag | str | 标签 | 用 `,` 分隔 |
|
||||
| duration | num | 时长 | 单位为秒 |
|
||||
| id | num | aid | |
|
||||
| rank_score | num | 排序分数? | |
|
||||
| badgepay | bool | 是否有角标? | |
|
||||
| senddate | num | 发送时间? | UNIX 秒级时间戳 |
|
||||
| author | str | UP主名 | |
|
||||
| review | num | 评论数 | |
|
||||
| mid | num | UP主mid | |
|
||||
| is_union_video | num | 是否为联合投稿 | |
|
||||
| rank_index | num | 排序索引号 | |
|
||||
| type | str | 类型 | video: 视频 |
|
||||
| arcrank | str | 0 | 作用尚不明确 |
|
||||
| play | str | 播放数 | |
|
||||
| rank_offset | num | 排序偏移? | 与 `rank_index` 相同 |
|
||||
| description | str | 简介 | |
|
||||
| video_review | num | 弹幕数? | |
|
||||
| is_pay | num | 是否付费? | 0: 免费<br />1: 付费 |
|
||||
| favorites | num | 收藏数 | |
|
||||
| arcurl | str | 视频播放页URL | |
|
||||
| bvid | str | bvid | |
|
||||
| title | str | 标题 | |
|
||||
| vt | num | 0 | 作用尚不明确 |
|
||||
| enable_vt | num | 0 | 作用尚不明确 |
|
||||
| vt_display | str | 空 | 作用尚不明确 |
|
||||
|
||||
**示例:**
|
||||
|
||||
获取`tid=231(科技->计算机技术)`分区近期投稿列表, 按播放数排序, 页码为1, 视频数为2, 时间一周
|
||||
|
||||
```shell
|
||||
curl -G 'https://api.bilibili.com/x/web-interface/newlist_rank' \
|
||||
--data-urlencode 'search_type=video' \
|
||||
--data-urlencode 'view_type=hot_rank' \
|
||||
--data-urlencode 'order=click' \
|
||||
--data-urlencode 'cate_id=231' \
|
||||
--data-urlencode 'page=1' \
|
||||
--data-urlencode 'pagesize=2' \
|
||||
--data-urlencode 'time_from=20240716' \
|
||||
--data-urlencode 'time_to=20240723'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>查看响应示例:</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 0,
|
||||
"message": "0",
|
||||
"ttl": 1,
|
||||
"data": {
|
||||
"exp_list": null,
|
||||
"show_module_list": [
|
||||
"tips",
|
||||
"brand_ad",
|
||||
"esports",
|
||||
"activity",
|
||||
"web_game",
|
||||
"card",
|
||||
"media_bangumi",
|
||||
"media_ft",
|
||||
"bili_user",
|
||||
"user",
|
||||
"star",
|
||||
"video"
|
||||
],
|
||||
"result": [
|
||||
{
|
||||
"pubdate": "2024-07-19 15:27:23",
|
||||
"pic": "//i0.hdslb.com/bfs/archive/a6c2a8669e623333eee4bd8316b4e7b01716b7f2.jpg",
|
||||
"tag": "微软,Microsoft",
|
||||
"duration": 14,
|
||||
"id": 1406270001,
|
||||
"rank_score": 237205,
|
||||
"badgepay": false,
|
||||
"senddate": 1721410429,
|
||||
"author": "柚子木字幕组",
|
||||
"review": 928,
|
||||
"mid": 221648,
|
||||
"is_union_video": 0,
|
||||
"rank_index": 1,
|
||||
"type": "video",
|
||||
"arcrank": "0",
|
||||
"play": "237205",
|
||||
"rank_offset": 1,
|
||||
"description": "X",
|
||||
"video_review": 42,
|
||||
"is_pay": 0,
|
||||
"favorites": 618,
|
||||
"arcurl": "http://www.bilibili.com/video/av1406270001",
|
||||
"bvid": "BV1gr421M7rE",
|
||||
"title": "突发:微软服务中断正在影响全球用户",
|
||||
"vt": 0,
|
||||
"enable_vt": 0,
|
||||
"vt_display": ""
|
||||
},
|
||||
{
|
||||
"pubdate": "2024-07-17 22:12:47",
|
||||
"pic": "//i0.hdslb.com/bfs/archive/1b02bc3806369f8c051a84e1ffef11b22695e659.jpg",
|
||||
"tag": "演讲,大学,编程,英伟达,人工智能,TED,AI,黄仁勋",
|
||||
"duration": 1908,
|
||||
"id": 1556206286,
|
||||
"rank_score": 52653,
|
||||
"badgepay": false,
|
||||
"senddate": 1721225567,
|
||||
"author": "YouTube精选字幕组",
|
||||
"review": 147,
|
||||
"mid": 487511093,
|
||||
"is_union_video": 0,
|
||||
"rank_index": 2,
|
||||
"type": "video",
|
||||
"arcrank": "0",
|
||||
"play": "52648",
|
||||
"rank_offset": 2,
|
||||
"description": "New SciTech\n上月加州理工学院毕业典礼上,刚刚带领英伟达达成世界第一市值的CEO黄仁勋,到场分享对当下AI革命趋势的见解、带领英伟达转型成AI公司的历程、以及自己在职场这么多年的人生感悟。\n\n全程没有上位者那种空洞无意义的说教,都是真实的发展故事和对未来世界的看法。如果你的工作生活中有涉及到AI技术的可能,那么这期演讲将会非常有意义。",
|
||||
"video_review": 16,
|
||||
"is_pay": 0,
|
||||
"favorites": 2152,
|
||||
"arcurl": "http://www.bilibili.com/video/av1556206286",
|
||||
"bvid": "BV1C1421b7dD",
|
||||
"title": "“这个时代要跑,不要走”黄仁勋加州理工毕业演讲完整版",
|
||||
"vt": 0,
|
||||
"enable_vt": 0,
|
||||
"vt_display": ""
|
||||
}
|
||||
],
|
||||
"show_column": 0,
|
||||
"rqt_type": "search",
|
||||
"numPages": 404,
|
||||
"numResults": 808,
|
||||
"crr_query": "",
|
||||
"pagesize": 2,
|
||||
"suggest_keyword": "",
|
||||
"egg_info": null,
|
||||
"cache": 0,
|
||||
"exp_bits": 1,
|
||||
"exp_str": "",
|
||||
"seid": "6717218533109517809",
|
||||
"msg": "success",
|
||||
"egg_hit": 0,
|
||||
"page": 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
Loading…
Reference in New Issue
Block a user