Skip to content

Commit d3b7ab5

Browse files
authored
Merge pull request #668 from Nemo2011/dev
Dev -> main
2 parents 5632838 + 74c1876 commit d3b7ab5

File tree

132 files changed

+10433
-1944
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+10433
-1944
lines changed

.github/workflows/python-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
- name: Install dependencies
2121
run: |
2222
python -m pip install --upgrade pip
23-
pip install setuptools wheel twine
23+
pip install setuptools wheel twine build
2424
- name: Export branch and version
2525
run: echo "${{ github.ref_name }}|${{ github.event.release.target_commitish }}" > github.txt
2626
- name: Build and publish
2727
env:
2828
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2929
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3030
run: |
31-
python setup.py sdist bdist_wheel
31+
python3 -m build --sdist --wheel
3232
twine upload dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ virtualenv/
2525
# IDE
2626
.idea/
2727
.vscode/settings.json
28+
.vscode/launch.json

CHANGELOGS/v15.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
- 【破坏修改】优化 `black_room` 模块
114114
- 【破坏修改】优化 `live_area` 模块
115115
- 【破坏修改】移动 `channel` 模块至 `video_zone` 模块(因为原来的 `channel` 模块全部是分区操作而并非真正意义的频道操作)
116-
- 【破坏更改】移动 `rank` 模块的 `get_hot_videos`, `get_weakly_hot_videos_list`, `get_weakly_hot_videos`, `get_history_popular_videos` 函数至新模块 `hot` 模块
116+
- 【破坏更改】移动 `rank` 模块的 `get_hot_videos`, `get_weekly_hot_videos_list`, `get_weekly_hot_videos`, `get_history_popular_videos` 函数至新模块 `hot` 模块
117117
- 【破坏修改】移动 `user` 模块的 `ChannelOrder`, `ChannelSeries`, `ChannelType`, `create_channel_series`, `del_channel_series`, `add_aids_to_series`, `del_aids_from_series` 函数与类至 `channel_series` 模块
118118
- 【破坏修改】删除 `video.Video.get_media_list` 函数
119119
- 新增 `channel` 模块提供频道相关功能。

CHANGELOGS/v16.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,82 @@
1+
# v16.2.0
2+
3+
* build: upd pillow requirement from ~=10.0.1 to ~=10.1.0
4+
* build: upd aiohttp requirement from ~=3.8.6 to ~=3.9.1
5+
* build: upd httpx requirement from ~=0.24.1 to ~=0.26.0
6+
* build: upd yarl requirement from ~=1.9.2 to ~=1.9.4
7+
* build: upd lxml requirement from ~=4.9.3 to ~=5.1.0
8+
* build: upd pycryptodomex requirement from ~=3.19.0 to ~=3.20.0
9+
* build: upd pillow requirement from ~=10.1.0 to ~=10.2.0
10+
* build: upd beautifulsoup4 requirement from ~=4.12.2 to ~=4.12.3
11+
* build: remove setup.py, use pyproject.toml instead by @iconFehu in https://github.com/Nemo2011/bilibili-api/pull/604
12+
13+
14+
* fix: POST params -400 by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/547
15+
* fix: credential.refresh by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/557
16+
* fix: unban user by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/578
17+
* fix: 修复获取弹幕时发生的异常 by @amtoaer in https://github.com/Nemo2011/bilibili-api/pull/585
18+
* fix: 修复无法获取弹幕和历史弹幕的bug by @wudizhangzhi in https://github.com/Nemo2011/bilibili-api/pull/552
19+
* fix: 增加HEADERS以修复刷新cookie和使用验证码登录时发生的异常 by @blyc in https://github.com/Nemo2011/bilibili-api/pull/593
20+
* fix: ass.py by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/149ac726c94cc68cfac780d5000cd93c79a292bb
21+
* fix: login by @whille in https://github.com/Nemo2011/bilibili-api/pull/668/commits/741fc2d09145f81c7aac60dd329f340b7572e5c4
22+
* **[BREAKING CHANGE]** fix: weekly by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/dce9402fe691b1910a841234386b1cc75729b129
23+
* fix: User.get_relation api json by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/7bc108647ed0251921337b8a85cb6b1704141c73
24+
* fix: User.get_videos -352 风控 by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/608
25+
* fix: liveroom update room news api json by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/452747f3d2686a5c40edb2416a3af28ee3ebb3f3
26+
* fix: detect dolby failed by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/16abaf77293e2f6820ac922be78a47020e7de6bf
27+
* fix: pyproject.toml 安装时文件缺失的错误 by @amtoaer in https://github.com/Nemo2011/bilibili-api/pull/625
28+
* fix: favorite_list in https://github.com/Nemo2011/bilibili-api/issues/245 by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/6f705c4398ff9e90d1579c3159a31365f8915add
29+
* fix: returns 412 msg for channel series by adding ua by @TimG233 in https://github.com/Nemo2011/bilibili-api/pull/629
30+
* fix: video_uploader problems from git hook by @TimG233 in https://github.com/Nemo2011/bilibili-api/pull/629
31+
* fix: update video zone json file by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/93f287d045262bf212e45656eed7c1f0e64c6c06
32+
* fix: article.TextNode by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/3c1d2fae2a12e9d627cc93738c4d21826d81fe6e and more.
33+
* fix: sessdata 未进行 url 编码会失效 by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/f36ed3b92f7ac9edcef233b554ab8eeb2dd33f38
34+
* fix: Video.get_info() -412 by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/59cda9c1f2d6ff13f4f097b7770976e52005c43c
35+
* fix: get_real_url by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/e1b379cb83f06094e87b67ae5f31054e5f91c9a4
36+
* fix: get_danmakus by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/bbc7468810eb21df2169a575273b6c7d1b836d47
37+
* fix: topic api json by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/a59651283b1e2d82e1955adc41ea42047183762f
38+
* fix: subscribe music rank json by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/28363873caee03fc34c2a26c82ca089415f017ed
39+
* fix: search.get_suggested_keywords by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/22cff8f8cd38252db5cbc401e21d44eaeebc60f1
40+
* **[BREAKING CHANGE]** 移除 channel.py:目前除了 channel.get_channel_categories() 以外其他接口均无法使用,以前 b 站频道页现在也会自动跳转至搜索
41+
* fix: manga api json by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/05858b722b9de30378f59211d2a5ff31a814017d
42+
* fix: parse_link by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/3dc55f263b8d255d7efac0ca48502956e7f766b2
43+
* **[BRAEKING CHANGE]** 移除 get_album_favorite_list
44+
* fix: session by @Drelf2018 in https://github.com/Nemo2011/bilibili-api/pull/646
45+
* **[BREAKING CHANGE]** SUBSCRIBE_SECRETLY 悄悄关注已失效
46+
* **[BREAKING CHANGE]** get_client_info 失效
47+
* fix: live.py重连清理无效的ws链接和心跳任务 by @blyc in https://github.com/Nemo2011/bilibili-api/pull/655
48+
* **[BREAKING CHANGE]** fix: get_comment_lazy by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/c84993a86682dd1ce3d4725a07da96b54b51dc91
49+
* fix: UnderLineNode by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/687c24040174b08c23fb2f716fa37f328eb1c293
50+
* fix: bvid2aid by @nooblong in https://github.com/Nemo2011/bilibili-api/pull/666
51+
* fix: topic.get_cards by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/404673ccc7faa7e8e2c840db575d45d3a4ebd3fb
52+
53+
54+
* feat: video_uploader lines probe by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/548
55+
* feat: live.get_room_status_by_uids in https://github.com/Nemo2011/bilibili-api/pull/556
56+
* feat: live.send_danmaku.reply_mid by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/558
57+
* feat: video_uploader enhancement in https://github.com/Nemo2011/bilibili-api/issues/543 by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/555
58+
* feat: 增加查看及赠送免费人气票功能 by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/566
59+
* feat: get_black_list 增加翻页功能 by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/567
60+
* feat: audio_uploader by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/559
61+
* feat: User.get_media_list by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/599
62+
* feat: liveroom update room news by @whille in https://github.com/Nemo2011/bilibili-api/pull/612
63+
* feat: network synchronous request & two kinds of http client support (httpx and aiohttp) by @iconFehu in https://github.com/Nemo2011/bilibili-api/pull/615, bug fixed by @z0z0r4 and @Nemo2011 in other commits.
64+
* feat: session.EventType by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/636
65+
* feat: bili_ticket by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/637
66+
* feat: 登录记录/节操记录/经验记录 by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/fd804990091a6d15898b526fc2cdf55a8fa79d83
67+
* feat: add festival to be able to resolve url without bvid in parse_link by `__INITIAL_STATE__` by @TimG233 in https://github.com/Nemo2011/bilibili-api/pull/640
68+
* feat: festival.py by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/f5a5d2a0282e4c1c5fccf4af1fbb07f7c69a72e4
69+
* feat: login with tv by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/654
70+
* feat: search_by_type page_size by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/244732145b035329007b1882d7eaa4cc648ad8d3
71+
* feat: Credential.from_cookies by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/352099e3b312aebf80052c9ad4a407cf397b871c
72+
* feat: opus.py by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/9f99241ea1e37588e075a6820d3a9906ee17b7c4 and more.
73+
* feat: add StatementException instead of assert by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/6cff631eb6fff0a6881c8ea95a3d0e05e307d432
74+
75+
76+
* refactor: remove httpx.get, use Api instead by @iconFehu in https://github.com/Nemo2011/bilibili-api/pull/615, bug fixed by @z0z0r4 and @Nemo2011 in other commits.
77+
* **[BREAKING CHANGE]** refactor: remove topic.get_cards, rename `topic.get_raw_cards -> topic.get_cards by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/404673ccc7faa7e8e2c840db575d45d3a4ebd3fb
78+
79+
180
# v16.1.1 2023/10/15
281

382
* fix: platform=html5 且登陆时获取 1080P 画质 by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/538/commits/2e5d498beaba99df22297f5ec62c0c4640176dab
@@ -9,7 +88,7 @@
988
* feat: user.get_relation by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/531
1089
* feat: user.get_masterpiece by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/532
1190
* feat: comment.report by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/533
12-
* ai_conclusion and relation by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/537
91+
* feat: ai_conclusion and relation by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/537
1392

1493

1594
**Full Changelog**: https://github.com/Nemo2011/bilibili-api/compare/16.1.0...16.1.1

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
![bilibili-api logo](https://raw.githubusercontent.com/Nemo2011/bilibili-api/main/design/logo.png)
1+
![bilibili-api logo](https://raw.githubusercontent.com/Nemo2011/bilibili-api/main/design/logo-newYear.jpg)
22

33
<div align="center">
44

55
# bilibili-api
66

7-
[![API 数量](https://img.shields.io/badge/API%20数量-300+-blue)][api.json]
7+
[![API 数量](https://img.shields.io/badge/API%20数量-400+-blue)][api.json]
88
[![LICENSE](https://img.shields.io/badge/LICENSE-GPLv3+-red)][LICENSE]
9-
[![Python](https://img.shields.io/badge/python-3.11|3.10|3.9|3.8-blue)](https://www.python.org)
10-
<!-- [![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi] -->
9+
[![Python](https://img.shields.io/badge/python-3.12(dev)|3.11|3.10|3.9|3.8-blue)](https://www.python.org)
10+
[![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi]
1111
[![Pre-release Version](https://img.shields.io/github/v/release/Nemo2011/bilibili-api?label=pre-release&include_prereleases&sort=semver)][pypi-dev]
1212
[![STARS](https://img.shields.io/github/stars/nemo2011/bilibili-api?color=yellow&label=Github%20Stars)][stargazers]
1313
[![Testing](https://github.com/Nemo2011/bilibili-api/actions/workflows/testing.yml/badge.svg?branch=dev)](https://github.com/Nemo2011/bilibili-api/actions/workflows/testing.yml)
@@ -55,6 +55,7 @@ $ pip3 install bilibili-api-python
5555
import asyncio
5656
from bilibili_api import video
5757

58+
5859
async def main() -> None:
5960
# 实例化 Video 类
6061
v = video.Video(bvid="BV1uv411q7Mv")
@@ -63,8 +64,10 @@ async def main() -> None:
6364
# 打印信息
6465
print(info)
6566

66-
if __name__ == '__main__':
67+
68+
if __name__ == "__main__":
6769
asyncio.get_event_loop().run_until_complete(main())
70+
6871
```
6972

7073
输出(已格式化,已省略部分):
@@ -115,16 +118,21 @@ if __name__ == '__main__':
115118
116119
# 异步迁移
117120

118-
由于从 v5 版本开始,全部改为异步,如果你不会异步,可以参考 [asyncio](https://docs.python.org/zh-cn/3/library/asyncio.html)
121+
由于从 v5 版本开始,基本全部改为异步,如果你不会异步,可以参考 [asyncio](https://docs.python.org/zh-cn/3/library/asyncio.html)
119122

120123
异步可以进行并发请求,性能更高,不过如果请求过快仍然会导致被屏蔽。
121124

122125
总的来说,异步比同步更有优势,所以不会的话可以去学一下,会发现新天地(误
123126

124127
如果你仍然想继续使用同步代码,请参考 [同步执行异步代码](https://nemo2011.github.io/bilibili-api/#/sync-executor)
125128

126-
> 注:
127-
> 目前代码中采用 `WebSocket` 的部分(如视频实时检测、直播)采用 `aiohttp.ClientSession` 请求。其他地方均采用 `httpx.AsyncClient`
129+
以下为 `API` 关于异步请求库使用的详细信息:
130+
131+
| Feature | 同步 | 异步 | aiohttp | httpx | 备注 |
132+
| ------ | ---- | ----- | ------ | ------ | ---- |
133+
| `LiveDanmaku` & `VideoOnlineMonitor` | [] | [x] | [x] | [ ] | httpx 暂不支持 `WebSocket` |
134+
| `login` | [x] | [ ] | [ ] | [x] | 目前暂时仅支持同步请求 |
135+
| other | [] | [x] | [x] | [x] | |
128136

129137
# FA♂Q
130138

bilibili_api/__init__.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,20 @@
88
import platform
99

1010
from .utils.sync import sync
11-
from .credential import Credential
11+
from .utils.credential_refresh import Credential
1212
from .utils.picture import Picture
1313
from .utils.short import get_real_url
1414
from .utils.parse_link import ResourceType, parse_link
1515
from .utils.aid_bvid_transformer import aid2bvid, bvid2aid
1616
from .utils.danmaku import DmMode, Danmaku, DmFontSize, SpecialDanmaku
1717
from .utils.network import (
1818
HEADERS,
19-
Api,
20-
retry,
21-
enc_wbi,
22-
get_nav,
23-
check_valid,
2419
get_session,
2520
set_session,
26-
get_mixin_key,
2721
get_aiohttp_session,
28-
set_aiohttp_session
22+
set_aiohttp_session,
23+
get_httpx_sync_session,
24+
set_httpx_sync_session
2925
)
3026
from .errors import (
3127
LoginError,
@@ -58,19 +54,21 @@
5854
emoji,
5955
login,
6056
manga,
57+
music,
6158
topic,
6259
video,
6360
cheese,
6461
client,
6562
search,
6663
article,
6764
bangumi,
68-
channel,
6965
comment,
7066
dynamic,
7167
session,
68+
festival,
7269
homepage,
7370
settings,
71+
watchroom,
7472
live_area,
7573
video_tag,
7674
black_room,
@@ -82,20 +80,19 @@
8280
creative_center,
8381
article_category,
8482
interactive_video,
83+
audio_uploader,
8584
)
8685

87-
BILIBILI_API_VERSION = "16.1.1"
86+
BILIBILI_API_VERSION = "16.1.2"
8887

8988
# 如果系统为 Windows,则修改默认策略,以解决代理报错问题
9089
if "windows" in platform.system().lower():
9190
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) # type: ignore
9291

9392
__all__ = [
94-
"Api",
9593
"ApiException",
9694
"ArgsException",
9795
"BILIBILI_API_VERSION",
98-
"check_valid",
9996
"Credential",
10097
"CredentialNoBiliJctException",
10198
"CredentialNoBuvid3Exception",
@@ -106,7 +103,6 @@
106103
"DmFontSize",
107104
"DmMode",
108105
"DynamicExceedImagesException",
109-
"enc_wbi",
110106
"HEADERS",
111107
"LiveException",
112108
"LoginError",
@@ -122,12 +118,11 @@
122118
"article",
123119
"article_category",
124120
"ass",
125-
"asyncio",
126121
"audio",
122+
"audio_uploader",
127123
"bangumi",
128124
"black_room",
129125
"bvid2aid",
130-
"channel",
131126
"channel_series",
132127
"cheese",
133128
"client",
@@ -136,10 +131,9 @@
136131
"dynamic",
137132
"emoji",
138133
"favorite_list",
134+
"festival",
139135
"game",
140136
"get_aiohttp_session",
141-
"get_mixin_key",
142-
"get_nav",
143137
"get_real_url",
144138
"get_session",
145139
"homepage",
@@ -150,11 +144,10 @@
150144
"login",
151145
"login_func",
152146
"manga",
147+
"music",
153148
"note",
154149
"parse_link",
155-
"platform",
156150
"rank",
157-
"retry",
158151
"search",
159152
"session",
160153
"set_aiohttp_session",
@@ -169,4 +162,5 @@
169162
"video_uploader",
170163
"video_zone",
171164
"vote",
165+
"watchroom",
172166
]

0 commit comments

Comments
 (0)