Skip to content

Commit

Permalink
feat: v17
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo2011 committed Jan 28, 2025
1 parent 087aec1 commit f0e2f83
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 2 deletions.
197 changes: 197 additions & 0 deletions CHANGELOGS/v17.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
# v17.0.0 2025/01/28

## Notice

此次更新伴随着针对底层网络请求功能的大规模重构,可以算是本次更新中最重要的一点。

现在开始,模块底层的网络请求功能全部通过用户实现的 `BiliAPIClient`(一个抽象类) 具体实现,`BiliAPIClient` 应当以类的实例为载体对第三方请求库的会话对象进行封装,使第三方请求库可以处理模块指定传入的数据。这种模式下,用户理论上可以利用 `BiliAPIClient` 使模块运用上所有的第三方请求库,前提是需要自己具体实现对应的 `BiliAPIClient` 的实现。模块目前默认提供 `curl_cffi``BiliAPIClient` 实现,将 `curl_cffi` 作为第三方请求库。

更多信息见 [自定义请求库](https://nemo2011.github.io/bilibili-api/#/request_client)

下文为本次更新其他更新内容,存在部分破坏修改。最后是所有在 `16.3.0 -> 17.0.0` 中修改的 API 的列表。

## What's Other Changed

- chore(deps): remove `httpx`
- chore(deps): update `aiohttp ~= 3.10.5 -> ~= 3.11.11`
- chore(deps): update `pycryptodomex ~= 3.20.0 -> ~= 3.21.0`
- chore(deps): update `yarl ~= 1.11.1 -> ~= 1.17.2`
- chore(deps): update `qrcode ~= 7.4.2 -> ~= 8.0`
- chore(deps): update `pyjwt ~= 2.9.0 -> ~= 2.10.0`
- chore(deps): update `pillow ~= 10.4.0 -> ~= 11.0.0`
- chore(deps): update `apscheduler ~= 3.10.4 -> ~= 3.11.0`

- feat: `login_v2` module. 使用样例见 [自定义请求库](https://nemo2011.github.io/bilibili-api/#/examples/login_v2)
- feat: 用户个人首页动态渲染数据风控 `w_webid` by @shouge in [#837](https://github.com/Nemo2011/bilibili-api/pull/837)
- feat: 直播禁言用户添加hour参数 by @TZFC in [#846](https://github.com/Nemo2011/bilibili-api/pull/846)
- feat: 禁言用户新增的参数,添加默认数值,以方便旧版本适配 by @TZFC in [#859](https://github.com/Nemo2011/bilibili-api/pull/859)
- feat: 新增获取直播间可用表情包,与直播间发送表情包功能 by @TZFC in [#864](https://github.com/Nemo2011/bilibili-api/pull/864)
- feat: `search.search_by_type` 增加功能:可以按照时间段查询 & 新增 `to_timestamps` 函数 by @xianrenzhou in [#866](https://github.com/Nemo2011/bilibili-api/pull/866)
- feat: `Dynamic.set_favorite`
- feat: `emoji.get_emoji_detail` & `emoji.get_all_emoji`
- **[BREAKING CHANGE]** feat: `live_area.fetch_live_area_data` **之后调用 `live_area` 查询分区函数必须先调用此方法**
- feat: `dynamic.get_lottery_info`
- feat: 支持在事件循环已经运行时同步执行异步代码 by @LondonClass in [#743](https://github.com/Nemo2011/bilibili-api/pull/743)
- feat: `dynamic.Dynamic.markdown`
- feat: `manga.get_followed_manga`

- fix: `VideoDownloadURLDataDetecter`
- **[BREAKING CHANGE]** fix: remove argument `uid` for `User.get_relation` **之后调用 `get_relation` 默认判断 `User.get_uid()` 与自己的信息而不是传入函数的参数**
- fix: 字母接口风控 [#841](https://github.com/Nemo2011/bilibili-api/issues/841) & 游客下无法访问用户视频投稿
- **[BREAKING CHANGE]** fix: `user.name2uid` 此方法目前必须携带凭据类 **经过测试,更改后的 api 只能登录后访问。若要不登录访问一定程度上可以使用搜索功能替代**
- fix: `comment.get_comments_lazy` 传参问题 [#871](https://github.com/Nemo2011/bilibili-api/issues/871)
- fix: `manga.get_info`
- fix: 当 `buvid3` 已有时仍尝试获取 `buvid3`
- fix: `Video.get_danmaku_view`
- **[BREAKING CHANGE]** fix: 因为 `video.get_cid_info` (属于 biliplus <https://hd.biliplus.com> 的 api)部分新视频数据没有记录,暂时缺少方法处理笔记正文内容视频卡片的 `cid` 数据,所以目前 **`note.Note.fetch_content` 不再支持解析视频卡片。**
- **[BREAKING CHANGE]** fix: 考虑到多方面因素,`interactive_video.InteractiveVideoDownloader` 参数 **`self_download_func` 不再默认提供。**
- fix: 查看用户合集中的视频(新版)API变更 by @TangMisaka23001 in [#880](https://github.com/Nemo2011/bilibili-api/pull/880)
- fix: `opus.get_info`
- **[BREAKING CHANGE]** fix: 因更新频率过高且不易维护,`emote.json` 被移除。**`dynamic.BuildDynamic.add_emoji` 被修改。**

- **[BREAKING CHANGE]** refactor: 重构 `bangumi` / `cheese` / `channel_series` / `video_tag` 等,移除所有同步代码,**部分原同步函数改为异步函数。**大多此类函数原来是同步的获取属性的函数,例如 `get_meta` `get_season_id`,这些数据原为 `__init__` 中通过同步请求获取。
- **[BREAKING CHANGE]** refactor: 重写大量 `opus` `dynamic` `article` `note` 间互相转换/关联的代码。
- refactor: `dynamic.BuildDynamic` 内部移除同步请求模式,相关完善正文内容请求将移至 `dynamic.send_dynamic` 进行,即 `dynamic.send_dynamic` 请求数可能会增多,但 `dynamic.BuildDynamic` 不会再有请求。

- **[BREAKING CHANGE]** chore: remove support for **Python 3.8**.
- chore: 更新 `data/**.json`
- **[BREAKING CHANGE]** chore: **`Manga` 类大多函数 和 `manga.manga_image_url_turn_to_Picture` `manga.get_raw_manga_index` `manga.get_manga_index` 无限期被移除。所有函数目前均已失效。**这是源于 bilibili 漫画接口在 2024 年末、2025 年初这段时间的变动,出现了新字段,接口返回数据也出现了加密。相关讨论:[#875](https://github.com/Nemo2011/bilibili-api/issues/875) [#bac1168](https://github.com/SocialSisterYi/bilibili-API-collect/issues/1168) [#bac1130](https://github.com/SocialSisterYi/bilibili-API-collect/discussions/1130)
- **[BREAKING CHANGE]** chore: **移除 `login` `login_func` 模块。**

## All Changed API

- `__init__.py`
- add `Api`
- add `BiliAPIClient`
- add `BiliAPIFile`
- add `BiliAPIResponse`
- add `BiliWsMsgType`
- add `Geetest`
- add `GeetestMeta`
- add `GeetestServerNotFoundException`
- add `GeetestUndoneException`
- move async `Picture.async_load_url()` to async `Picture.load_url()`
- move async `Picture.upload_file()` to async `Picture.upload()`
- add async `Picture.upload_by_note()`
- move `Picture.download_sync()` to `Picture.to_file()`
- remove async `Picture.download()`
- add `WbiRetryTimesExceedException`
- remove `get_aiohttp_session()`
- remove `set_aiohttp_session()`
- remove `get_httpx_sync_session()`
- remove `set_httpx_sync_session()`
- remove `get_buvid3()`
- rewrite `get_session()` response type `httpx.AsyncClient` -> `object`
- rewrite `set_session()` argument type `httpx.AsyncClient` -> `object`
- add `get_client()`
- add `get_selected_client()`
- add `register_client()`
- add `unregister_client()`
- add `select_client()`
- add `request_log`
- add `request_settings`
- add `get_registered_clients()`
- `article.py`
- change `article.Article.turn_to_opus()` async
- add async `article.Article.turn_to_dynamic()`
- remove `article.ArticleType`
- `bangumi.py`
- change `bangumi.Bangumi.get_media_id()` async
- change `bangumi.Bangumi.get_raw()` async
- change `bangumi.Bangumi.get_season_id()` async
- change `bangumi.Bangumi.get_up_info()` async
- change `bangumi.Bangumi.set_media_id()` async
- change `bangumi.Bangumi.set_ssid()` async
- change `bangumi.Episode.get_aid()` async
- change `bangumi.Episode.get_bangumi()` async
- change `bangumi.Episode.get_bvid()` async
- modify `bangumi.Episode.get_cid()` add `from_seg` `to_seg` arguments
- `black_room.py`
- change async `black_room.BlackRoom.get_id()` sync
- change async `black_room.BlackRoom.set_id()` sync
- `channel_series.py`
- change `channel_series.ChannelSeries.get_meta()` async
- `cheese.py`
- change `cheese.CheeseList.get_season_id()` async
- change `cheese.CheeseList.set_ep_id()` async
- change `cheese.set_season_id()` async
- change `cheese.Cheese.get_cheese()` async
- change `cheese.Cheese.get_cid()` async
- change `cheese.Cheese.get_meta()` async
- change `cheese.Cheese.set_epid()` async
- `dynamic.py`
- modify `dynamic.BuildDynamic.add_at()` add `uname` argument, make `uid` argument `int | user.User` -> `int`
- modify `dynamic.BuildDynamic.add_vote()` rename `vote` -> `vote_id` argument, make `vote_id` argument `vote.Vote` -> `int`
- change `dynamic.BuildDynamic.get_contents()` async
- add async `dynamic.Dynamic.get_lottery_info()`
- change `dynamic.Dynamic.is_opus()` async
- add async `dynamic.Dynamic.is_article()`
- add async `dynamic.Dynamic.set_favorite()`
- add async `dynamic.Dynamic.turn_to_article()`
- remove `dynamic.upload_image_sync()`
- add async `dynamic.Dynamic.markdown()`
- add async `dynamic.Dynamic.get_rid()`
- modify `dynamic.BuildDynamic.add_emoji()` remove `emoji_id` argument, add `emoji` argument
- `emoji.py`
- add async `emoji.get_all_emoji()`
- add async `emoji.get_emoji_detail()`
- modify async `emoji.get_emoji_list()` add `credential` argument
- `interactive_video.py`
- modify `interactive_video.InteractiveVideoDownloader.__init__` remove `self_download_func` argument's default value
- modify `interactive_video.InteractiveVideoDownloaderEvents` remove attributes `DOWNLOAD_START` `DOWNLOAD_PART` `DOWNLOAD_SUCCESS`
- `live.py`
- modify async `live.LiveRoom.ban_user()` add argument `hour`
- add async `live.LiveRoom.get_emoticons()`
- add async `live.LiveRoom.send_emoticons()`
- `live_area.py`
- add async `live_area.fetch_live_area_data()`
- `login.py`
- remove all
- `login_func.py`
- remove all
- `login_v2.py`
- add `login_v2`
- `manga.py`
- remove async `manga.Manga.get_images()`
- remove async `manga.manga_image_url_turn_to_Picture()`
- add async `manga.get_followed_manga()`
- add `manga.MangaOrderType`
- remove async `manga.get_manga_index()`
- remove async `manga.get_raw_manga_index()`
- `note.py`
- add async `note.upload_image()`
- `opus.py`
- change `opus.Opus.is_note()` async
- change `opus.Opus.turn_to_article()` async
- remove `opus.Opus.turn_to_note()`
- remove `opus.Opus.is_note()`
- remove `opus.Opus.get_type()`
- add async `opus.Opus.is_article()`
- remove `opus.OpusType`
- change `opus.Opus.markdown()` async
- add async `opus.Opus.set_like()`
- add async `opus.Opus.set_favorite()`
- add async `opus.Opus.add_coins()`
- add async `opus.Opus.get_reaction()`
- add async `opus.Opus.get_rid()`
- `search.py`
- modify async `search.search_by_type()` add `time_start` `time_end` arguments, remove `debug_param_func` argument
- `user.py`
- add async `user.User.get_access_id()`
- modify async `user.User.get_relation()` remove `uid` argument
- remove `user.get_user_info_sync()`
- add async `user.User.is_access_id_expired()`
- remove `user.name2uid_sync()`
- `video.py`
- remove `video.get_cid_info_sync()`
- `video_tag.py`
- remove async `video_tag.Tag.get_history_cards()`
- change `video_tag.Tag.get_tag_id()` async
- add async `video_tag.Tag.get_tag_name()`
- `video_zone.py`
- modify `video_zone.VideoZoneTypes` add attributes `MUSIC_FAN_VIDEOS` `MUSIC_AI_MUSIC` `MUSIC_RADIO` `CINEPHILE_MASHUP` `CINEPHILE_AI_IMAGING` `CINEPHILE_COMPREHENSIVE` `ENT_CP_RECOMMENDATION` `ENT_BEAUTY` `ENT_ENTERTAINMENT_NEWS` `TECH_DIY` `LIFE_PARENTING` `CAR_KNOWLEDGE` `ANIMAL_SECOND_EDITION` `ANIMAL_WILD_ANIMAL`, remove attributes `ANIMAL_PANDA` `ANIMAL_WILD_ANIMAL` `VLOG`
- `vote.py`
- remove `vote.Vote.get_info_sync()`
- `watchroom.py`
- change `watchroom.WatchRoom.get_episode_id()` async
- change `watchroom.WatchRoom.get_season_id()` async
97 changes: 96 additions & 1 deletion bilibili_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
)


BILIBILI_API_VERSION = "16.3.0"
BILIBILI_API_VERSION = "17.0.0"


def __register_all_clients():
Expand All @@ -127,3 +127,98 @@ def __register_all_clients():


__register_all_clients()


__all__ = [
"ApiException",
"ArgsException",
"BILIBILI_API_VERSION",
"BiliAPIClient",
"BiliAPIFile",
"BiliAPIResponse",
"BiliWsMsgType",
"CookiesRefreshException",
"Credential",
"CredentialNoAcTimeValueException",
"CredentialNoBiliJctException",
"CredentialNoBuvid3Exception",
"CredentialNoDedeUserIDException",
"CredentialNoSessdataException",
"Danmaku",
"DanmakuClosedException",
"DmFontSize",
"DmMode",
"DynamicExceedImagesException",
"ExClimbWuzhiException",
"Geetest",
"GeetestException",
"GeetestMeta",
"GeetestType",
"HEADERS",
"LiveException",
"LoginError",
"NetworkException",
"Picture",
"ResourceType",
"ResponseCodeException",
"ResponseException",
"SpecialDanmaku",
"StatementException",
"VideoUploadException",
"WbiRetryTimesExceedException",
"aid2bvid",
"app",
"article",
"article_category",
"ass",
"audio",
"audio_uploader",
"bangumi",
"black_room",
"bvid2aid",
"channel_series",
"cheese",
"client",
"comment",
"creative_center",
"dynamic",
"emoji",
"favorite_list",
"festival",
"game",
"get_client",
"get_real_url",
"get_registered_clients",
"get_selected_client",
"get_session",
"homepage",
"hot",
"interactive_video",
"live",
"live_area",
"login_v2",
"manga",
"music",
"note",
"opus",
"parse_link",
"rank",
"register_client",
"request_log",
"request_settings",
"search",
"select_client",
"session",
"set_session",
"show",
"sync",
"topic",
"unregister_client",
"user",
"video",
"video_tag",
"video_uploader",
"video_zone",
"vote",
"watchroom",
]
2 changes: 1 addition & 1 deletion docs/examples/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def main():
# 2. 下载音频
sess: requests.AsyncSession = (
get_session()
) # bilibili-api 默认使用 aiohttp 作为请求客户端
) # bilibili-api 默认使用 curl_cffi 作为请求客户端

# 创建歌单文件夹
if not os.path.exists(str(AUDIO_LIST_ID)):
Expand Down

0 comments on commit f0e2f83

Please sign in to comment.