XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/bilibili-API-collect

feat: 更新web端视频操作播放合集相关接口 (#1064)

- [d1a4f6d](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/d1a4f6dd2b4e5d57188d56671b1dfacc299ea3fd) close #1062 ~by myself~ - [ff450a6](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/ff450a65693dbdc3c9a78a05c67ddbc1a783a532) add Wbi API - [b3c3fce](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/b3c3fce1646e72985e46492224554ba8b505849a) close #707 - [fa6c9c8](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/fa6c9c8f575a617f6603935b5a77c9624dd5b9fb) new method of `buvid3` & `b_nut` from #790 - [45755b0](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/45755b01d8d9593d50658de83322dd79e7b45e21#diff-1a8d1ba142e61d01fd3b24620847ca2f2ff93f880973ea1e1d71de79d0123096R133) close #380 - [45755b0](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/45755b01d8d9593d50658de83322dd79e7b45e21#diff-1a8d1ba142e61d01fd3b24620847ca2f2ff93f880973ea1e1d71de79d0123096R542) add details in #244 - [1c5b778](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/1c5b7788f717f92a0e3f655e947db49e842f80e0) - [85e8fc5](https://github.com/SocialSisterYi/bilibili-API-collect/pull/1064/commits/85e8fc5304d94ccb7480545e38201219b71370ad) close #945

2465990
Session小胡 <102411014+SessionHu@users.noreply.github.com>
提交于

代码差异

8 个文件 +1651 -38
Modified README.md +1 -1
@@ -73,7 +73,7 @@ B站 API 采用 C/S 结构,大多数接口为 REST API 和 gRPC,少部分接
73 73 - [x] [图片格式化](docs/misc/picture.md)
74 74 - [x] [bvid 说明](docs/misc/bvid_desc.md)
75 75 - [ ] [设备唯一标识BUVID](docs/misc/device_identity.md)
76 - [ ] [获取 buvid3 / buvid4](docs/misc/buvid3_4.md)
76 - [ ] [获取 buvid3 / buvid4 / b_nut](docs/misc/buvid3_4.md)
77 77 - [ ] [gRPC API 接口定义](grpc_api)
78 78 - [ ] [登录](docs/login)
79 79 - [x] [登录操作 (人机认证)](docs/login/login_action)
Modified docs/live/follow_up_live.md +1 -1
@@ -2,7 +2,7 @@
2 2
3 3 ## 用户关注的所有UP的直播情况
4 4
5 > https://api.bilibili.com/x/space/wbi/acc/info
5 > https://api.live.bilibili.com/xlive/web-ucenter/user/following
6 6
7 7 *请求方式:GET*
8 8
Modified docs/misc/buvid3_4.md +38 -1
@@ -1,4 +1,4 @@
1 # 获取 buvid3 / buvid4
1 # 获取 buvid3 / buvid4 / b_nut
2 2
3 3 ## 游客获取 buvid3 / buvid4
4 4
@@ -46,3 +46,40 @@ curl -G 'https://api.bilibili.com/x/frontend/finger/spi'
46 46 ```
47 47
48 48 </details>
49
50 ## 从响应头获取 buvid3 / b_nut
51
52 使用 `GET` 或 `HEAD` 方法请求 `https://www.bilibili.com/`, 且请求头中 `User-Agent` 字段不包含 `curl` `python` `awa` 等敏感子字符串, 且相同 `User-Agent` 字段不得短时多次请求. 在响应头中的 `Set-Cookie` 字段中, 即可找到 `buvid3` 和 `b_nut`.
53
54 若不带任何 Cookie 请求, 则 `b_nut` 为响应生成时刻的 UNIX 秒级时间戳.
55 若请求 Cookie 仅带有 `buvid3`, 则 `b_nut` 为 `100`.
56 若请求 Cookie 仅带有 `b_nut`, 则与不带任何 Cookie 的响应相同.
57 若请求 Cookie 仅带有 `buvid3` 和 `b_nut`, 则响应无 `Set-Cookie` 字段.
58 若请求 Cookie 带有其他字段, 无影响.
59
60 **示例:**
61
62 ```shell
63 curl -I "https://www.bilibili.com/" -A "awa"
64 ```
65
66 <details>
67 <summary>查看响应示例:</summary>
68
69 ```http
70 HTTP/2 200
71 date: Fri, 26 Jul 2024 06:38:43 GMT
72 content-type: text/html; charset=utf-8
73 support: nantianmen
74 set-cookie: buvid3=805E4894-96A2-0684-6F00-C6EA1FFB911023315infoc; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com
75 set-cookie: b_nut=1721975923; path=/; expires=Sat, 26 Jul 2025 06:38:43 GMT; domain=.bilibili.com
76 vary: Origin,Accept-Encoding
77 idc: shjd
78 expires: Fri, 26 Jul 2024 06:38:42 GMT
79 cache-control: no-cache
80 x-cache-webcdn: MISS from blzone01
81 x-cache-time: 0
82 x-save-date: Fri, 26 Jul 2024 06:38:43 GMT
83 ```
84
85 </details>
Modified docs/user/info.md +1 -1
@@ -250,7 +250,7 @@
250 250 | title | str | 直播间标题 | |
251 251 | cover | str | 直播间封面 url | |
252 252 | watched_show | obj | | |
253 | roomid | num | 直播间 id(短号) | |
253 | roomid | num | 直播间 id | |
254 254 | roundStatus | num | 轮播状态 | 0:未轮播<br />1:轮播 |
255 255 | broadcast_type | num | 0 | |
256 256
Modified docs/video/action.md +81 -5
@@ -130,7 +130,7 @@ curl 'https://app.bilibili.com/x/v2/view/like' \
130 130
131 131 </details>
132 132
133 ### 判断视频是否被点赞(双端)
133 ### 判断视频近期是否被点赞(双端)
134 134
135 135 > https://api.bilibili.com/x/web-interface/archive/has/like
136 136
@@ -138,6 +138,9 @@ curl 'https://app.bilibili.com/x/v2/view/like' \
138 138
139 139 认证方式:APP或Cookie(SESSDATA)
140 140
141 注: 这一 API 实际上只能判断出视频**在近期内**是否被点赞, 并不能判断出视频是否被点赞.
142 「近期」的定义不明, 但至少半年前点赞过的视频, 用这一接口获取到的结果就已经是 `0` 了. 参见 [#380](https://github.com/SocialSisterYi/bilibili-API-collect/issues/380).
143
141 144 **url参数:**
142 145
143 146 | 参数名 | 类型 | 内容 | 必要性 | 备注 |
@@ -459,8 +462,6 @@ curl -G 'https://api.bilibili.com/x/web-interface/archive/coins' \
459 462 ### 收藏视频(双端)
460 463
461 464 > https://api.bilibili.com/medialist/gateway/coll/resource/deal
462 >
463 > https://api.bilibili.com/x/v3/fav/resource/deal
464 465
465 466 *请求方式:POST*
466 467
@@ -475,8 +476,8 @@ curl -G 'https://api.bilibili.com/x/web-interface/archive/coins' \
475 476 | access_key | str | APP 登录 Token | APP 方式必要 | |
476 477 | rid | num | 稿件 avid | 必要 | |
477 478 | type | num | 必须为2 | 必要 | |
478 | add_media_ids | nums | 需要加入的收藏夹 mlid | 非必要 | 同时添加多个,用`,`(%2C)分隔 |
479 | del_media_ids | nums | 需要取消的收藏夹 mlid | 非必要 | 同时取消多个,用`,`(%2C)分隔 |
479 | add_media_ids | nums | 需要加入的收藏夹 mlid | 非必要(可选) | 同时添加多个,用`,`(%2C)分隔 |
480 | del_media_ids | nums | 需要取消的收藏夹 mlid | 非必要(可选) | 同时取消多个,用`,`(%2C)分隔 |
480 481 | csrf | str | CSRF Token(位于 Cookie) | Cookie 方式必要 | |
481 482
482 483 **json回复:**
@@ -538,6 +539,81 @@ curl 'https://api.bilibili.com/medialist/gateway/coll/resource/deal' \
538 539
539 540 </details>
540 541
542 ### 收藏视频(Web端)
543
544 > https://api.bilibili.com/x/v3/fav/resource/deal
545
546 *请求方式: POST*
547
548 认证方式: Cookie(SESSDATA)
549
550 **正文参数(application/x-www-form-urlencoded):**
551
552 | 参数名 | 类型 | 内容 | 必要性 | 备注 |
553 | ------------- | ---- | ---------------------------------- | ------------ | ------------------------------ |
554 | rid | num | 稿件 avid | 必要 | |
555 | type | num | 必须为2 | 必要 | |
556 | add_media_ids | nums | 需要加入的收藏夹 mlid | 非必要(可选) | 同时添加多个,用`,`(%2C)分隔 |
557 | del_media_ids | nums | 需要取消的收藏夹 mlid | 非必要(可选) | 同时取消多个,用`,`(%2C)分隔 |
558 | csrf | str | CSRF Token (即 Cookie 中 bili_jct) | 必要 | |
559 | platform | str | 平台标识? | 非必要 | web端: web |
560 | eab_x | num | 1 | 非必要 | 作用尚不明确 |
561 | ramval | num | 正整数 | 非必要 | 可能与在该页面的停留时间相关? |
562 | ga | num | 1 | 非必要 | 作用尚不明确 |
563 | gaia_source | str | ??? | 非必要 | web端: web_normal |
564
565 **JSON回复:**
566
567 根对象:
568
569 | 字段 | 类型 | 内容 | 备注 |
570 | ------- | ---- | -------- | ------- |
571 | code | num | 返回值 | 0: 成功<br />-101: 账号未登录<br />-111: csrf 校验失败<br />2001000: 参数错误 |
572 | message | str | 错误信息 | 默认为0 |
573 | ttl | num | 1 | |
574 | data | obj | 信息本体 | 错误时为 null 或不存在 |
575
576 `data`对象:
577
578 | 字段 | 类型 | 内容 | 备注 |
579 | ----------- | ---- | --------------------- | ----------------------- |
580 | prompt | bool | 是否为未关注用户收藏? | false:否<br />true:是 |
581 | ga_data | null | | 作用尚不明确 |
582 | toast_msg | str | 空 | 作用尚不明确 |
583 | success_num | num | 0 | 作用尚不明确 |
584
585 **示例:**
586
587 将视频 `av1906473802` 添加到收藏夹 `1164192068` 中
588
589 ```shell
590 curl -sX POST "https://api.bilibili.com/x/v3/fav/resource/deal" \
591 --data-urlencode "rid=1906473802" \
592 --data-urlencode "type=2" \
593 --data-urlencode "csrf=xxx" \
594 --data-urlencode "add_media_ids=1164192068" \
595 -b "SESSDATA=xxx; bili_jct=xxx"
596 ```
597
598 <details>
599 <summary>查看响应示例:</summary>
600
601 ```json
602 {
603 "code": 0,
604 "message": "0",
605 "ttl": 1,
606 "data": {
607 "prompt": false,
608 "ga_data": null,
609 "toast_msg": "",
610 "success_num": 0
611 }
612 }
613 ```
614
615 </details>
616
541 617 ### 判断视频是否被收藏(双端)
542 618
543 619 > https://api.bilibili.com/x/v2/fav/video/favoured
Modified docs/video/info.md +1 -0
@@ -4,6 +4,7 @@
4 4
5 5 ## 获取视频详细信息(web端)
6 6
7 > https://api.bilibili.com/x/web-interface/wbi/view
7 8 > https://api.bilibili.com/x/web-interface/view
8 9
9 10 *请求方式:GET*
Modified docs/video/report.md +48 -18
@@ -78,28 +78,58 @@ curl 'https://api.bilibili.com/x/v2/history/report' \
78 78
79 79 认证方式:仅可Cookie(SESSDATA)
80 80
81 默认间隔15秒一次
81 默认间隔15秒一次, 亦可记录播放历史
82 82
83 亦可记录播放历史
83 尽管以下除正文 `aid` 以外的参数均为非必要, 但缺少可能会导致播放不被记录, 同一 IP/登陆用户 每五分钟最多记录一次播放
84
85 该接口较为复杂, 且参数计算方法均为推测, 实际过程不明, 可能含有错误, 若要正式使用可以把已播放的持续时间全都设为相同值
86
87 **URL参数:**
88
89 | 参数名 | 类型 | 内容 | 必要性 | 备注 |
90 | ------------------------- | ---- | ------------------------------ | ------ | ------- |
91 | w_start_ts | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | UNIX 秒级时间戳 |
92 | w_mid | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | |
93 | w_aid | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | |
94 | w_dt | num | 2 | 非必要 | |
95 | w_realtime | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | 单位 秒 |
96 | w_playedtime | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | 单位 秒 |
97 | w_real_played_time | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | 单位 秒 |
98 | w_video_duration | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | 单位 秒 |
99 | w_last_play_progress_time | num | 参见请求正文同名无`w_`前缀参数 | 非必要 | 单位 秒 |
100 | web_location | num | 网页位置 | 非必要 | 视频详情页播放器: 1315873 |
101 | w_rid | num | WBI 签名 | 非必要 | 参见[WBI 签名](docs/misc/sign/wbi.md) |
102 | wts | num | UNIX 秒级时间戳 | 非必要 | 参见[WBI 签名](docs/misc/sign/wbi.md) |
84 103
85 104 **正文参数( application/x-www-form-urlencoded ):**
86 105
87 | 参数名 | 类型 | 内容 | 必要性 | 备注 |
88 | ----------- | ---- | ------------------------ | ------------ | ------------------------------------------------------------ |
89 | aid | num | 稿件avid | 必要(可选) | avid与bvid任选一个 |
90 | bvid | str | 稿件bvid | 必要(可选) | avid与bvid任选一个 |
91 | cid | num | 视频cid | 非必要 | 用于识别分P |
92 | epid | num | 番剧epid | 非必要 | |
93 | sid | num | 番剧ssid | 非必要 | |
94 | mid | num | 当前用户mid | 非必要 | |
95 | played_time | num | 视频播放进度 | 非必要 | 单位为秒<br />默认为0 |
96 | realtime | num | 总计播放时间 | 非必要 | 单位为秒 |
97 | start_ts | num | 开始播放时刻 | 非必要 | 时间戳 |
98 | type | num | 视频类型 | 非必要 | 3:投稿视频<br />4:剧集<br />10:课程 |
99 | sub_type | num | 剧集副类型 | 非必要 | 当`type=4`时本参数有效<br />1:番剧<br />2:电影<br />3:纪录片<br />4:国创<br />5:电视剧<br />7:综艺 |
100 | dt | num | 2 | 非必要 | |
101 | play_type | num | 播放动作 | 非必要 | 0:播放中<br />1:开始播放<br />2:暂停<br />3:继续播放 |
102 | csrf | str | CSRF Token(位于cookie) | 非必要 | |
106 | 参数名 | 类型 | 内容 | 必要性 | 备注 |
107 | ----------------------- | ---- | ---------------------------------- | ------------ | ----------------------------------------------------------- |
108 | aid | num | 稿件avid | 必要(可选) | avid与bvid任选一个(网页端请求默认仅使用aid) |
109 | bvid | str | 稿件bvid | 必要(可选) | avid与bvid任选一个 |
110 | cid | num | 视频cid | 非必要 | 用于识别分P |
111 | epid | num | 番剧epid | 非必要 | |
112 | sid | num | 番剧ssid | 非必要 | |
113 | mid | num | 当前用户mid | 非必要 | |
114 | played_time | num | 视频播放进度 | 非必要 | 单位 秒<br />播放完成为 -1 |
115 | realtime | num | 本轮页面会话真实播放时间 | 非必要 | 单位 秒 |
116 | real_played_time | num | 本轮页面会话真实视频播放持续时间 | 非必要 | 单位 秒 |
117 | refer_url | str | 与请求头 Referer 字段相同 | 非必要 | |
118 | quality | num | 视频清晰度 | 非必要 | 参见[qn视频清晰度标识](videostream_url.md#qn视频清晰度标识) |
119 | video_duration | num | 视频时长 | 非必要 | 单位 秒 |
120 | last_play_progress_time | num | play_time 与 本轮页面会话开始时 played_time 之和 | 非必要 | 单位 秒 |
121 | max_play_progress_time | num | 本轮页面会话所有最大 last_play_progress_time 与 本轮页面会话开始时 played_time 之和 | 非必要 | 单位 秒 |
122 | start_ts | num | 开始播放时刻 | 非必要 | 时间戳 |
123 | type | num | 视频类型 | 非必要 | 3:投稿视频<br />4:剧集<br />10:课程 |
124 | sub_type | num | 剧集副类型 | 非必要 | 0: 普通投稿视频<br />1:番剧<br />2:电影<br />3:纪录片<br />4:国创<br />5:电视剧<br />7:综艺 |
125 | dt | num | 2 | 非必要 | |
126 | outer | num | 0 | 非必要 | |
127 | spmid | str | 333.788.0.0 | 非必要 | 作用尚不明确 |
128 | from_spmid | str | 播放来源? | 非必要 | 也可为空, 如: 444.41.list.card_archive.click |
129 | session | str | 会话信息? | 非必要 | 每次刷新均不同, 生成原理尚不明确 |
130 | extra | obj | 额外信息, 如播放器版本 | 非必要 | 如: `{"player_version":"4.8.36"}` |
131 | play_type | num | 播放动作 | 非必要 | 0:播放中<br />1:开始播放<br />2:暂停<br />3:继续播放<br />4: 结束播放 |
132 | csrf | str | CSRF Token(即 Cookie 中 bili_jct) | 非必要 | |
103 133
104 134 **json回复:**
105 135