From 1e5c3df557695570ef7226c468764c9129beea25 Mon Sep 17 00:00:00 2001 From: zhadongmin Date: Sat, 13 Apr 2024 21:27:07 +0800 Subject: [PATCH 01/11] fix: typo (#1000) --- docs/login/member_center.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/login/member_center.md b/docs/login/member_center.md index 9612d60..4c2765a 100644 --- a/docs/login/member_center.md +++ b/docs/login/member_center.md @@ -470,7 +470,7 @@ curl 'https://api.bilibili.com/x/member/realname/apply/status' \ ## 查询硬币变化情况 -> httpsss://api.bilibili.com/x/member/web/coin/log +> https://api.bilibili.com/x/member/web/coin/log *请求方式:GET* From 8b7ca24b97857172a492c8f07e7197c81bd69344 Mon Sep 17 00:00:00 2001 From: Hansiyu Date: Tue, 16 Apr 2024 13:24:04 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8D=E7=89=87=E4=BF=A1=E6=81=AF=E7=9A=84=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E7=A4=BA=E4=BE=8B=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/user/info.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/user/info.md b/docs/user/info.md index 45beb88..ff69b85 100644 --- a/docs/user/info.md +++ b/docs/user/info.md @@ -717,13 +717,13 @@ curl -G 'https://api.bilibili.com/x/web-interface/card' \ "space": { "s_img": "http://i1.hdslb.com/bfs/space/768cc4fd97618cf589d23c2711a1d1a729f42235.png", "l_img": "http://i1.hdslb.com/bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png" - } - }, - "following": true, - "archive_count": 37, - "article_count": 0, - "follower": 969999, - "like_num": 3547978 + }, + "following": true, + "archive_count": 37, + "article_count": 0, + "follower": 969999, + "like_num": 3547978 + } } ``` From 0e8f12d9b71a381dcdb5710657b185c5cfa6f054 Mon Sep 17 00:00:00 2001 From: Shiokiri Date: Tue, 16 Apr 2024 22:47:47 +0800 Subject: [PATCH 03/11] fix: typo (#1003) --- docs/fav/info.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fav/info.md b/docs/fav/info.md index a3a5206..84bce67 100644 --- a/docs/fav/info.md +++ b/docs/fav/info.md @@ -49,7 +49,7 @@ | media_count | num | 收藏夹内容数量 | | -`info`中的`upper`对象: +`data`中的`upper`对象: | 字段 | 类型 | 内容 | 备注 | | ---------- | ---- | ---------------- | ----------------------------------------------- | @@ -60,7 +60,7 @@ | vip_type | num | 会员类别 | 0:无
1:月大会员
2:年度及以上大会员 | | vip_statue | num | 会员开通状态 | 0:无
1:有 | -`info`中的`cnt_info`对象: +`data`中的`cnt_info`对象: | 字段 | 类型 | 内容 | 备注 | | -------- | ---- | ------ | ---- | From 5fcc6e3a772c9049ed87d813955a064348069c7b Mon Sep 17 00:00:00 2001 From: SocialSisterYi <1440239038@qq.com> Date: Sat, 20 Apr 2024 20:47:22 +0800 Subject: [PATCH 04/11] add issue template --- .github/ISSUE_TEMPLATE /1-update-request.yml | 54 ++++++++++++++++++++ .vuepress/config.js | 2 +- README.md | 2 +- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE /1-update-request.yml diff --git a/.github/ISSUE_TEMPLATE /1-update-request.yml b/.github/ISSUE_TEMPLATE /1-update-request.yml new file mode 100644 index 0000000..d0cb0ac --- /dev/null +++ b/.github/ISSUE_TEMPLATE /1-update-request.yml @@ -0,0 +1,54 @@ +name: "新增/更新请求" +description: "请求添加/补充/更新文档中的 API 定义" +title: "[新增/更新请求] " +body: + - type: checkboxes + id: reminders + attributes: + description: "提交前请确认" + options: + label: "我已检索仓库中文档,不包含所提及内容,或所提及内容在本仓库中存在错误,且 Issues、Pull Requests 中无相关提交" + required: true + - type: dropdown + id: source + attributes: + label: "API 来源" + description: "该 API 在何平台中使用" + options: + - label: "Web 端(含 h5)" + - label: "PC 客户端(Electron)" + - label: "Android 客户端(含粉版、平板版、蓝版、概念版、国际版等)" + - label: "TV 客户端(含云试听小电视、车机、物联网版等)" + - label: "IOS 客户端(含粉版、平板版、概念版等)" + - label: "必剪客户端" + - label: "漫画客户端" + - label: "其他(请在详情中备注)" + validations: + required: true + - type: dropdown + id: type + attributes: + label: "API 类型" + description: "API 所使用的协议标准及调用方式" + options: + - label: "REST" + - label: "gRPC" + - label: "长连接数据帧(含 ws、TCP)" + - label: "其他类型(请在详情中备注)" + validations: + required: true + - type: input + id: adderss + attributes: + label: "API 地址" + description: "REST 的 url,或 gRPC 的包名+服务名,更新时可为原文档链接" + placeholder: "eg: https://api.bilibili.com/2333333" + validations: + required: false + - type: textarea + id: details + attributes: + label: "详情描述" + description: "新增时请描述该 API 的使用场景、请求及响应字段等,可附上原始抓包记录;更新时请指出原文档中与最新 API 行为不符之处,并附上已知的最新改动" + validations: + required: true diff --git a/.vuepress/config.js b/.vuepress/config.js index 48c1dd2..99b7f2e 100644 --- a/.vuepress/config.js +++ b/.vuepress/config.js @@ -25,7 +25,7 @@ export default defineUserConfig({ children: [ { text: "QQ交流群(综合技术交流)", - link: "http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=2rRJXK3zgU5yi3e_4rNLeJYUjMLzw_Jj&authKey=L%2FN3EfZXo3QFjEuHq4ifTgh%2F384UmrYpjl7dbYPhYHtznhfJWxkymxQKObQunmEQ&noverify=0&group_code=560304737", + link: "http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=ympvb3LAPT-Ulu3ezhGqbkJ8zXMKImOX&authKey=z1KdkOdKO3wytN43m9K6On9nBtnDL4pAoD6VQHCipFBb9TasNDKuDHCmOE6TF3uc&noverify=0&group_code=191187164", }, { text: "Telegram交流群(Github Bot推送)", diff --git a/README.md b/README.md index a169926..1f39259 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,7 @@ protobuf 序列格式:[传送门](https://www.jianshu.com/p/a24c88c0526a ) ⚠注意:开源社群欢迎交流探讨,**拒绝**咨询、**不支持**合作,**黑产号**一经发现立即拉黑并举报相关 SRC -- QQ 交流群:[邀请链接](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=2rRJXK3zgU5yi3e_4rNLeJYUjMLzw_Jj&authKey=L%2FN3EfZXo3QFjEuHq4ifTgh%2F384UmrYpjl7dbYPhYHtznhfJWxkymxQKObQunmEQ&noverify=0&group_code=560304737) +- QQ 交流群:[邀请链接](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=ympvb3LAPT-Ulu3ezhGqbkJ8zXMKImOX&authKey=z1KdkOdKO3wytN43m9K6On9nBtnDL4pAoD6VQHCipFBb9TasNDKuDHCmOE6TF3uc&noverify=0&group_code=191187164) - Telegram 交流群:[@bilibili_API_collect_community](https://t.me/bilibili_API_collect_community) ## 🧋发电 From 262e62145a740c50b3f3130c010b0342be3ff52b Mon Sep 17 00:00:00 2001 From: SilverWolf <i@thefish.icu> Date: Sat, 20 Apr 2024 22:41:47 +0800 Subject: [PATCH 05/11] =?UTF-8?q?issue=20=E8=A1=A8=E5=8D=95=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E9=94=99=E8=AF=AF=201-update-request.yml=20(#1005)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE /1-update-request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE /1-update-request.yml b/.github/ISSUE_TEMPLATE /1-update-request.yml index d0cb0ac..47613b8 100644 --- a/.github/ISSUE_TEMPLATE /1-update-request.yml +++ b/.github/ISSUE_TEMPLATE /1-update-request.yml @@ -5,10 +5,10 @@ body: - type: checkboxes id: reminders attributes: - description: "提交前请确认" + label: "提交前请确认" options: - label: "我已检索仓库中文档,不包含所提及内容,或所提及内容在本仓库中存在错误,且 Issues、Pull Requests 中无相关提交" - required: true + - label: "我已检索仓库中文档,不包含所提及内容,或所提及内容在本仓库中存在错误,且 Issues、Pull Requests 中无相关提交" + required: true - type: dropdown id: source attributes: From db2bd9ccf556685716bfeca1122f5431c0a76246 Mon Sep 17 00:00:00 2001 From: SilverWolf <i@thefish.icu> Date: Sat, 20 Apr 2024 23:30:10 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20issue=20form=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=20(#1006)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update 1-update-request.yml * Create config.yml * Rename 1-update-request.yml to 1-update-request.yml * Rename config.yml to config.yml --- .../1-update-request.yml | 24 +++++++++---------- .github/ISSUE_TEMPLATE/config.yml | 5 ++++ 2 files changed, 17 insertions(+), 12 deletions(-) rename .github/{ISSUE_TEMPLATE => ISSUE_TEMPLATE}/1-update-request.yml (69%) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE /1-update-request.yml b/.github/ISSUE_TEMPLATE/1-update-request.yml similarity index 69% rename from .github/ISSUE_TEMPLATE /1-update-request.yml rename to .github/ISSUE_TEMPLATE/1-update-request.yml index 47613b8..9693f2f 100644 --- a/.github/ISSUE_TEMPLATE /1-update-request.yml +++ b/.github/ISSUE_TEMPLATE/1-update-request.yml @@ -15,14 +15,14 @@ body: label: "API 来源" description: "该 API 在何平台中使用" options: - - label: "Web 端(含 h5)" - - label: "PC 客户端(Electron)" - - label: "Android 客户端(含粉版、平板版、蓝版、概念版、国际版等)" - - label: "TV 客户端(含云试听小电视、车机、物联网版等)" - - label: "IOS 客户端(含粉版、平板版、概念版等)" - - label: "必剪客户端" - - label: "漫画客户端" - - label: "其他(请在详情中备注)" + - "Web 端(含 h5)" + - "PC 客户端(Electron)" + - "Android 客户端(含粉版、平板版、蓝版、概念版、国际版等)" + - "TV 客户端(含云试听小电视、车机、物联网版等)" + - "IOS 客户端(含粉版、平板版、概念版等)" + - "必剪客户端" + - "漫画客户端" + - "其他(请在详情中备注)" validations: required: true - type: dropdown @@ -31,10 +31,10 @@ body: label: "API 类型" description: "API 所使用的协议标准及调用方式" options: - - label: "REST" - - label: "gRPC" - - label: "长连接数据帧(含 ws、TCP)" - - label: "其他类型(请在详情中备注)" + - "REST" + - "gRPC" + - "长连接数据帧(含 ws、TCP)" + - "其他类型(请在详情中备注)" validations: required: true - type: input diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..e65606e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: 参与讨论 + url: https://github.com/SocialSisterYi/bilibili-API-collect/discussions + about: 代码用例、情报分享等内容请使用 Discussions From ed9ac01b6769430aa3f12ad02c2ed337a96924eb Mon Sep 17 00:00:00 2001 From: fwqaaq <fwqaaq@gmail.com> Date: Sun, 21 Apr 2024 18:08:57 +0800 Subject: [PATCH 07/11] Add user-agent http header when curl download video (#1004) --- docs/video/videostream_url.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/video/videostream_url.md b/docs/video/videostream_url.md index 0719ed0..78e0d4d 100644 --- a/docs/video/videostream_url.md +++ b/docs/video/videostream_url.md @@ -1263,6 +1263,7 @@ curl -G 'https://api.bilibili.com/x/player/playurl' \ ```shell wget 'http://upos-sz-mirrorhw.bilivideo.com/upgcxcode/08/62/171776208/171776208-1-112.flv?e=ig8euxZM2rNcNbhMnwhVhwdlhzK3hzdVhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1589565412&gen=playurl&os=hwbv&oi=606631998&trid=e0fa5f9a7610440a871279a28fae85aau&platform=pc&upsig=5f469cb4c190ed54b89bd40cc37eddff&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,platform&mid=293793435&logo=80000000' \ + -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" --referer 'https://www.bilibili.com' \ -O 'Download_video.flv' ``` @@ -1272,10 +1273,12 @@ wget 'http://upos-sz-mirrorhw.bilivideo.com/upgcxcode/08/62/171776208/171776208- ```bash # 下载视频流 wget 'https://cn-jxjj-ct-01-01.bilivideo.com/upgcxcode/65/46/244954665/244954665_f9-1-30125.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1674137769&gen=playurlv2&os=bcache&oi=606633952&trid=0000524e9cc80dea41dca72b59782270b5d3u&mid=293793435&platform=pc&upsig=c4206c80b1d0dc18c0545a7758d56eee&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&cdnid=4261&bvc=vod&nettype=0&orderid=0,3&buvid=EC1BD8EA-88F6-4951-BF27-2CFE3450C78F167646infoc&build=0&agrr=0&bw=1726751&logo=80000000' \ + -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" --referer 'https://www.bilibili.com' \ -O 'video.m4s' # 下载伴音流 wget 'https://xy125x75x230x185xy.mcdn.bilivideo.cn:4483/upgcxcode/65/46/244954665/244954665_f9-1-30280.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1674137769&gen=playurlv2&os=mcdn&oi=606633952&trid=0000524e9cc80dea41dca72b59782270b5d3u&mid=293793435&platform=pc&upsig=e5feff4626de4c6fd2ed9c6061c324a0&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&mcdnid=1002708&bvc=vod&nettype=0&orderid=0,3&buvid=EC1BD8EA-88F6-4951-BF27-2CFE3450C78F167646infoc&build=0&agrr=0&bw=41220&logo=A0000001' \ + -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" --referer 'https://www.bilibili.com' \ -O 'audio.m4s' # 进行混流 From a4132acd0a43f1ac0a033c34e8538cecc9bd4ea7 Mon Sep 17 00:00:00 2001 From: HIM~ <67405384+HIM049@users.noreply.github.com> Date: Sun, 5 May 2024 14:05:00 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E9=94=99=E8=AF=AF=20(#1012)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/video/collection.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/video/collection.md b/docs/video/collection.md index 1dbea2f..410d753 100644 --- a/docs/video/collection.md +++ b/docs/video/collection.md @@ -10,7 +10,7 @@ | 参数名 | 类型 | 内容 | 必要性 | 备注 | |--------|-----|------|--------|-----| -| mid | num | UP 主 ID | 必要 | | +| mid | num | 用户 mid | 必要 | 似乎不一定需要创建者的 mid,随意的用户 mid 就能成功请求。 | | season_id | num | 视频合集 ID | 必要 | | | sort_reverse | bool | 未知 | 可选 | | | page_num | num | 页码索引 | 可选 | | @@ -31,7 +31,7 @@ | 字段 | 类型 | 内容 | 备注 | | ----------------------- | ------- | ------------------------------ | ----------------------------------------------------------- | -| aids | array | 稿件avid | 对应下方数组中内容 aid | +| aids | array | 稿件 avid 列表 | 对应下方数组中内容 aid | | archives | array | 合集中的视频 | | | meta | obj | 合集元数据 | | | page | obj | 分页信息 | | @@ -48,8 +48,8 @@ | 字段 | 类型 | 内容 | 备注 | |----------|-----|------|-----| -| aid | num | 稿件avid || -| bvid | str | 稿件bvid || +| aid | num | 稿件 avid || +| bvid | str | 稿件 bvid || | ctime | num | 创建时间 | Unix 时间戳 | | duration | num | 视频时长 | 单位为秒 | | enable_vt | bool | false || @@ -75,10 +75,10 @@ | 字段 | 类型 | 内容 | 备注 | |-----------------|-----|--------------|--------| | category | num | 0 | | -| covr | str | 合集封面 URL | | +| cover | str | 合集封面 URL | | | description | str | 合集描述 | | | mid | num | UP 主 ID | | -| name | num | 合集标题 | | +| name | str | 合集标题 | | | ptime | num | 发布时间 | Unix 时间戳 | | season_id | num | 合集 ID | | | total | num | 合集内视频数量 | | From 1d557be039a887ef25bc25da0c396eb5e03eb42e Mon Sep 17 00:00:00 2001 From: Han Zhang <45134013+holazzer@users.noreply.github.com> Date: Sun, 5 May 2024 14:06:23 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E6=99=BA=E8=83=BD=E9=98=B2=E6=8C=A1?= =?UTF-8?q?=E5=BC=B9=E5=B9=95=20(#659)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 智能防挡弹幕 * Create player.md * Update webmask.md * style: webmask.md --------- Co-authored-by: z0z0r4 <z0z0r4@outlook.com> --- docs/danmaku/webmask.md | 80 +++++++++++++++++++++ docs/video/player.md | 153 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 docs/danmaku/webmask.md create mode 100644 docs/video/player.md diff --git a/docs/danmaku/webmask.md b/docs/danmaku/webmask.md new file mode 100644 index 0000000..ab0fff8 --- /dev/null +++ b/docs/danmaku/webmask.md @@ -0,0 +1,80 @@ +# 智能防挡弹幕 + +B 站部分视频提供“智能防挡弹幕”功能,其原理是提供了一个 webmask 二进制文件,其中保存了视频中各个位置的 svg 格式蒙版。 + +首先需要获取 webmask 资源的地址。 + +## 获取 webmask 资源地址 + +通过 [web 播放器资源接口](../video/player.md) 获取 webmask 二进制文件的地址。 + + +## webmask 资源 + +获取的 url 没有权鉴,不需要后面的参数也可以获取。 + +示例: + +```shell +curl -G https://upos-sz-staticcos-cmask.bilivideo.com/cmaskboss/825851971_30_0.webmask >> 825851971_30_0.webmask +``` + +下载后是二进制文件。 + + +## webmask 二进制读取 + +参考:[andrewvy/webmask-renderer](https://github.com/andrewvy/webmask-renderer) + +name | offset | length | type | desc +--- | ------ | ------ | ---- | ---- +mask | 0 | 4 | char | 'MASK' 文件头 +version| 4 | 4 | int | 是1 +vU | 8 | 4 | ? | 不知道是干什么的 +Ly | 12 | 4 | int | 后续数据的段数 +time_1 | 16 | 8 | long | 第一段对应视频开始时间 +offset_1 | 24 | 8 | long | 第一段蒙版信息开始处对应二进制偏移 +...|...|...|...|... +time_{Ly} |16+(Ly-1)*16| 8 | long | 第 `Ly` 段对应视频开始时间 +offset_{Ly} |24+(Ly-1)*16| 8 | long | 第 `Ly` 段蒙版信息开始处对应二进制偏移 +segments_1| 由前面offset_1提供 | 由 `offset_2-offset_1` 计算得到 | binary | 蒙版信息块,使用 gzip 压缩 +...|...|...|...|... + + +蒙版信息块是经过 gzip 压缩文本得到的二进制。解压缩后得到一个字节串。 + +前 16 字节是两个 long,记为 `left` 和 `right`,暂时不清楚其作用。`left` 似乎和平均每张蒙版的时间有关。`right` 总是 `i*10000`,`i` 是从 0 开始数的数据段次序。 + +后面是各个 svg 文本直接拼起来,可以直接通过 svg 格式头 `data:image/svg+xml;base64,` 分开。 + + +Python 示例: +```python +from struct import unpack +import gzip + +f = open('你的 webmask', 'rb') +buf = f.read() +_Ly = buf[12:16] +Ly = unpack('>i', _Ly)[0] # 大端序 int + +times = [] +offsets = [] +for idx in range(Ly): + op = 16 + idx * 16 # 个人习惯,我算偏移时喜欢用 `op` 和 `ed` 作为开始和结束的名字。 + time = unpack('>q', buf[op: op+8])[0] + offset = unpack('>q', buf[op+8: op+16])[0] + times.append(time) + offsets.append(offset) + +frames = [] +for idx in range(Ly): + op = offsets[idx] + if idx == Ly - 1: ed = len(buf) + else: ed = offsets[idx+1] + ba = buf[op: ed] + bad = gzip.decompress(ba) + badl = bad.split(b'data:image/svg+xml;base64,') + # badl[0]是16字节,`left` 和 `right` + frames.append(badl[1: ]) +``` diff --git a/docs/video/player.md b/docs/video/player.md new file mode 100644 index 0000000..1d39959 --- /dev/null +++ b/docs/video/player.md @@ -0,0 +1,153 @@ +# web 播放器信息 + +web 播放器的信息接口,提供正常播放需要的元数据,包括:智能防挡弹幕、字幕、章节看点等。 + +> https://api.bilibili.com/x/player/wbi/v2 + +*请求方式:GET* + +**url 参数:** + +| 参数名 | 类型 | 内容 | 必要性 | 备注 | +| ------ | ---- | --------- | ----------- | ----------------- | +| aid | num | 稿件 avid | 必要 (可选) | aid 与 bvid 任选 | +| bvid | str | 稿件 bvid | 必要 (可选) | aid 与 bvid 任选 | +| cid | num | 稿件 cid | 必要 | | +| w_rid | str | 未知 | 不必要 | | +| wts | num | 当前 unix 时间戳 | 不必要 | | + + +**json 回复:** + +根对象: + +| 字段 | 类型 | 内容 | 备注 | +| ------- | ---- | -------- | --------------------------- | +| code | num | 返回值 | 0:成功<br />-400:请求错误 | +| message | str | 错误信息 | 默认为 0 | +| ttl | num | 1 | | +| data | obj | 数据本体 | | + +`data` 对象: + +| 字段 | 类型 | 内容 | 备注 | +| --------- | ----- | -------- | ---- | +|aid | num | 视频 aid | | +|bvid | str | 视频 bvid | | +|cid | num | 视频 cid | | +|dm_mask | obj | | webmask 信息(如果没有这一项,说明这个视频没有防挡功能) | +|subtitle | obj | | 字幕信息(需要登录,不登录此项内容为 `[]` )| +|view_points| array | | 章节看点信息 | +| 其他 | ... | | 主要是观看记录、使用者等级权限等个人信息 | + + +`dm_mask`对象(如果有): + +| 字段 | 类型 | 内容 | 备注 | +| --------- | ----- | -------- | ---- | +|cid | num | 视频 cid | | +|plat | num | 未知 | | +|fps | num | webmask 取样 fps | | +|time | num | 未知 | | +|mask_url | str | webmask 资源 url | | + +解析 webmask 请看 [智能防挡弹幕](../danmaku/webmask.md) + +`subtitle`对象: +| 字段 | 类型 | 内容 | 备注 | +| --------- | ----- | -------- | ---- | +|allow_submit|bool | true | | +| lan | str | "" | | +|lan_doc | str | "" | | | +|subtitles| array | | 不登录为 `[]` | + +`subtitles` 数组内的元素: + +| 字段 | 类型 | 内容 | 备注 | +| --------- | ----- | -------- | ---- | +| ai_status | num | | | +| ai_type | num | | | +| id | num | | | +|id_str | str| | 和 id 不一样 | +| is_lock | bool | | +| lan | str | 语言类型英文字母缩写 || +| lan_doc | str| 语言类型中文名称 | | +|subtitle_url|str| 资源 url 地址 | | +|type| num | 0 | | + + +`view_point` 数组内的元素: +| 字段 | 类型 | 内容 | 备注 | +| --------- | ----- | -------- | ---- | +| content | num | 章节名 | | +| from | num | | | +| to | num | | | +| type | num | | | +| imgUrl | str | 图片资源地址 | | +| logoUrl | str | "" | | + +示例: + +```shell +curl -G https://api.bilibili.com/x/player/wbi/v2?aid=515345690&cid=825851971 +``` + +```json +{ + "code": 0, + "message": "0", + "ttl": 1, + "data": { + "aid": 515345690, + "bvid": "BV1Fg411D7Jy", + ... // 省略 + "dm_mask": { + "cid": 825851971, + "plat": 0, + "fps": 30, + "time": 0, + "mask_url": "//upos-sz-staticcos-cmask.bilivideo.com/cmaskboss/825851971_30_0.webmask?trid=219266863a1442baa05086b4285ba923B&orderid=0,1&logo=00000000" + }, + "view_points": [ + { + "type": 2, + "from": 0, + "to": 27, + "content": "狗啃的", + "imgUrl": "http://i0.hdslb.com/bfs/vchapter/825851971_0.jpg", + "logoUrl": "" + }, + { + "type": 2, + "from": 27, + "to": 63, + "content": "椒牌泡菜", + "imgUrl": "http://i0.hdslb.com/bfs/vchapter/825851971_27.jpg", + "logoUrl": "" + }, ... // 省略 + ], + "subtitle": { + "allow_submit": true, + "lan": "", + "lan_doc": "", + "subtitles": [], // 未登录,下面是登录的版本 + "subtitles":[ + { + "id": 1042985852759993300, + "lan": "ai-zh", + "lan_doc": "中文(自动生成)", + "is_lock": false, + "subtitle_url": "//aisubtitle.hdslb.com/bfs/ai_subtitle/prod/5153456908258519712094280c7c2884b77929bab82f64530f?auth_key=1714795727-a8eb254b60bc4a73bc8662da51005340-0-1c305894e48e959979b163636461fb8f", + "type": 1, + "id_str": "1042985852759993344", + "ai_type": 0, + "ai_status": 2 + } + ] + } + } +} +``` + + + From e6dc29ec338003ce0e9d8fb2ef1c6b205ebc0556 Mon Sep 17 00:00:00 2001 From: Danny Du <50359598+DannyDu26@users.noreply.github.com> Date: Sat, 18 May 2024 14:10:31 +0800 Subject: [PATCH 10/11] =?UTF-8?q?feat:=20cookie=E5=88=B7=E6=96=B0=E7=94=9F?= =?UTF-8?q?=E6=88=90CorrespondPath=E7=AE=97=E6=B3=95=E6=B7=BB=E5=8A=A0java?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=9E=E7=8E=B0=20(#1017)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Duyulin <duyulin@kingsoft.com> --- docs/login/cookie_refresh.md | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/docs/login/cookie_refresh.md b/docs/login/cookie_refresh.md index f090f24..137e210 100644 --- a/docs/login/cookie_refresh.md +++ b/docs/login/cookie_refresh.md @@ -278,6 +278,68 @@ JNrRuoEUXpabUzGB8QIDAQAB 97759947aa357ed5d88cf9bf1172737570b7bba2d6788d39006f082b2b25ddf53b581f1f0c61ed8573317485ef525d2789faa25a277b4602a4b9cbf837681093a03e96cb9773a11df4bb1e20f1587180b3e958194de922d7dd94d0a2f0b9b0ef74e426e8041f99b99e7c02407ef4ab38040e61be81e4fdfbdb73461e3a2ad810 ``` +### Java +```Java +import javax.crypto.Cipher; +import javax.crypto.spec.OAEPParameterSpec; +import javax.crypto.spec.PSource; +import java.math.BigInteger; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.spec.MGF1ParameterSpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Base64; + +public class CookieRefresh { + private static final String PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\n" + + "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLgd2OAkcGVtoE3ThUREbio0Eg\n" + + "Uc/prcajMKXvkCKFCWhJYJcLkcM2DKKcSeFpD/j6Boy538YXnR6VhcuUJOhH2x71\n" + + "nzPjfdTcqMz7djHum0qSZA0AyCBDABUqCrfNgCiJ00Ra7GmRj+YCK1NJEuewlb40\n" + + "JNrRuoEUXpabUzGB8QIDAQAB\n" + + "-----END PUBLIC KEY-----"; + + public static void main(String[] args) { + try { + String correspondPath = getCorrespondPath(String.format("refresh_%d", System.currentTimeMillis()), PUBLIC_KEY); + System.out.println(correspondPath); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static String getCorrespondPath(String plaintext, String publicKeyStr) throws Exception { + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + publicKeyStr = publicKeyStr + .replace("-----BEGIN PUBLIC KEY-----", "") + .replace("-----END PUBLIC KEY-----", "") + .replace("\n", "") + .trim(); + byte[] publicBytes = Base64.getDecoder().decode(publicKeyStr); + X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(publicBytes); + PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec); + + String algorithm = "RSA/ECB/OAEPPadding"; + Cipher cipher = Cipher.getInstance(algorithm); + cipher.init(Cipher.ENCRYPT_MODE, publicKey); + + // Encode the plaintext to bytes + byte[] plaintextBytes = plaintext.getBytes("UTF-8"); + + // Add OAEP padding to the plaintext bytes + OAEPParameterSpec oaepParams = new OAEPParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT); + cipher.init(Cipher.ENCRYPT_MODE, publicKey, oaepParams); + // Encrypt the padded plaintext bytes + byte[] encryptedBytes = cipher.doFinal(plaintextBytes); + // Convert the encrypted bytes to a Base64-encoded string + return new BigInteger(1, encryptedBytes).toString(16); + } +} +``` + +``` +f87666152da692735123f4e49053e5a98c16854673b2e632f31a3ff0c029640772873661a9a8412db6be447a0bfa03a295d15548cbfd2bb35634e98ba5f25b1205519d6e6119b483f4c516c1e106d45b04ff98c73560949d379d3edaf3c0ecd10a1d46134fb9ca443122ab33c16d1dd48280496f949ed960a2fbcd65f10935e +``` + #### vercel云函数 ```bash From 11d42851ae07fd95f8af37a354c672f07f999ad2 Mon Sep 17 00:00:00 2001 From: cctyl <34262992+cctyl@users.noreply.github.com> Date: Mon, 20 May 2024 23:42:27 +0800 Subject: [PATCH 11/11] =?UTF-8?q?feat:=20bv<-->av=20=E5=A2=9E=E5=8A=A0java?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=20(#1021)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/misc/bvid_desc.md | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/docs/misc/bvid_desc.md b/docs/misc/bvid_desc.md index 86c80c6..f480b1c 100644 --- a/docs/misc/bvid_desc.md +++ b/docs/misc/bvid_desc.md @@ -248,6 +248,87 @@ print(av2bv(avid: 111298867365120)) print(bv2av(bvid: "BV1L9Uoa9EUx")) ``` + +### Java + +``` +import java.math.BigInteger; + +/** + * @author cctyl + */ +public class AVBVConverter { + + private static final BigInteger XOR_CODE = BigInteger.valueOf(23442827791579L); + private static final BigInteger MASK_CODE = BigInteger.valueOf(2251799813685247L); + private static final BigInteger MAX_AID = BigInteger.ONE.shiftLeft(51); + private static final int BASE = 58; + + private static final String DATA = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf"; + + public static String av2bv(int 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; + BigInteger tmp = MAX_AID.or(aid).xor(XOR_CODE); + while (tmp.compareTo(BigInteger.ZERO) > 0) { + bytes[bvIndex] = DATA.charAt(tmp.mod(BigInteger.valueOf(BASE)).intValue()); + tmp = tmp.divide(BigInteger.valueOf(BASE)); + bvIndex -= 1; + } + swap(bytes, 3, 9); + swap(bytes, 4, 7); + StringBuilder sb = new StringBuilder(bytes.length); + for (Character ch : bytes) { + sb.append(ch); + } + return sb.toString(); + } + + public static int bv2av(String bvid) { + char[] bvidArr = bvid.toCharArray(); + swap(bvidArr, 3, 9); + swap(bvidArr, 4, 7); + String adjustedBvid = new String(bvidArr, 3, bvidArr.length - 3); + BigInteger tmp = BigInteger.ZERO; + for (char c : adjustedBvid.toCharArray()) { + tmp = tmp.multiply(BigInteger.valueOf(BASE)).add(BigInteger.valueOf(DATA.indexOf(c))); + } + BigInteger xor = tmp.and(MASK_CODE).xor(XOR_CODE); + return xor.intValue(); + } + + + private static void swap(char[] array, int i, int j) { + char temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + + public static void main(String[] args) { + + final int aid1 = 643755790; + final String bv1 = "BV1bY4y1j7RA"; + + 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; + } +} + +``` + + ## 老版算法存档 **以下算法已失效**,编解码函数值域有限,不推荐使用,在此仅作为存档