Skip to content

Commit

Permalink
Merge pull request #668 from Nemo2011/dev
Browse files Browse the repository at this point in the history
Dev -> main
  • Loading branch information
z0z0r4 authored Feb 6, 2024
2 parents 5632838 + 74c1876 commit d3b7ab5
Show file tree
Hide file tree
Showing 132 changed files with 10,433 additions and 1,944 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine build
- name: Export branch and version
run: echo "${{ github.ref_name }}|${{ github.event.release.target_commitish }}" > github.txt
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python3 -m build --sdist --wheel
twine upload dist/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ virtualenv/
# IDE
.idea/
.vscode/settings.json
.vscode/launch.json
2 changes: 1 addition & 1 deletion CHANGELOGS/v15.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
- 【破坏修改】优化 `black_room` 模块
- 【破坏修改】优化 `live_area` 模块
- 【破坏修改】移动 `channel` 模块至 `video_zone` 模块(因为原来的 `channel` 模块全部是分区操作而并非真正意义的频道操作)
- 【破坏更改】移动 `rank` 模块的 `get_hot_videos`, `get_weakly_hot_videos_list`, `get_weakly_hot_videos`, `get_history_popular_videos` 函数至新模块 `hot` 模块
- 【破坏更改】移动 `rank` 模块的 `get_hot_videos`, `get_weekly_hot_videos_list`, `get_weekly_hot_videos`, `get_history_popular_videos` 函数至新模块 `hot` 模块
- 【破坏修改】移动 `user` 模块的 `ChannelOrder`, `ChannelSeries`, `ChannelType`, `create_channel_series`, `del_channel_series`, `add_aids_to_series`, `del_aids_from_series` 函数与类至 `channel_series` 模块
- 【破坏修改】删除 `video.Video.get_media_list` 函数
- 新增 `channel` 模块提供频道相关功能。
Expand Down
81 changes: 80 additions & 1 deletion CHANGELOGS/v16.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,82 @@
# v16.2.0

* build: upd pillow requirement from ~=10.0.1 to ~=10.1.0
* build: upd aiohttp requirement from ~=3.8.6 to ~=3.9.1
* build: upd httpx requirement from ~=0.24.1 to ~=0.26.0
* build: upd yarl requirement from ~=1.9.2 to ~=1.9.4
* build: upd lxml requirement from ~=4.9.3 to ~=5.1.0
* build: upd pycryptodomex requirement from ~=3.19.0 to ~=3.20.0
* build: upd pillow requirement from ~=10.1.0 to ~=10.2.0
* build: upd beautifulsoup4 requirement from ~=4.12.2 to ~=4.12.3
* build: remove setup.py, use pyproject.toml instead by @iconFehu in https://github.com/Nemo2011/bilibili-api/pull/604


* fix: POST params -400 by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/547
* fix: credential.refresh by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/557
* fix: unban user by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/578
* fix: 修复获取弹幕时发生的异常 by @amtoaer in https://github.com/Nemo2011/bilibili-api/pull/585
* fix: 修复无法获取弹幕和历史弹幕的bug by @wudizhangzhi in https://github.com/Nemo2011/bilibili-api/pull/552
* fix: 增加HEADERS以修复刷新cookie和使用验证码登录时发生的异常 by @blyc in https://github.com/Nemo2011/bilibili-api/pull/593
* fix: ass.py by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/149ac726c94cc68cfac780d5000cd93c79a292bb
* fix: login by @whille in https://github.com/Nemo2011/bilibili-api/pull/668/commits/741fc2d09145f81c7aac60dd329f340b7572e5c4
* **[BREAKING CHANGE]** fix: weekly by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/dce9402fe691b1910a841234386b1cc75729b129
* fix: User.get_relation api json by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/7bc108647ed0251921337b8a85cb6b1704141c73
* fix: User.get_videos -352 风控 by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/608
* fix: liveroom update room news api json by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/452747f3d2686a5c40edb2416a3af28ee3ebb3f3
* fix: detect dolby failed by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/16abaf77293e2f6820ac922be78a47020e7de6bf
* fix: pyproject.toml 安装时文件缺失的错误 by @amtoaer in https://github.com/Nemo2011/bilibili-api/pull/625
* 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
* fix: returns 412 msg for channel series by adding ua by @TimG233 in https://github.com/Nemo2011/bilibili-api/pull/629
* fix: video_uploader problems from git hook by @TimG233 in https://github.com/Nemo2011/bilibili-api/pull/629
* fix: update video zone json file by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/93f287d045262bf212e45656eed7c1f0e64c6c06
* fix: article.TextNode by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/3c1d2fae2a12e9d627cc93738c4d21826d81fe6e and more.
* fix: sessdata 未进行 url 编码会失效 by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/f36ed3b92f7ac9edcef233b554ab8eeb2dd33f38
* fix: Video.get_info() -412 by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/59cda9c1f2d6ff13f4f097b7770976e52005c43c
* fix: get_real_url by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/e1b379cb83f06094e87b67ae5f31054e5f91c9a4
* fix: get_danmakus by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/bbc7468810eb21df2169a575273b6c7d1b836d47
* fix: topic api json by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/a59651283b1e2d82e1955adc41ea42047183762f
* fix: subscribe music rank json by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/28363873caee03fc34c2a26c82ca089415f017ed
* fix: search.get_suggested_keywords by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/22cff8f8cd38252db5cbc401e21d44eaeebc60f1
* **[BREAKING CHANGE]** 移除 channel.py:目前除了 channel.get_channel_categories() 以外其他接口均无法使用,以前 b 站频道页现在也会自动跳转至搜索
* fix: manga api json by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/05858b722b9de30378f59211d2a5ff31a814017d
* fix: parse_link by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/3dc55f263b8d255d7efac0ca48502956e7f766b2
* **[BRAEKING CHANGE]** 移除 get_album_favorite_list
* fix: session by @Drelf2018 in https://github.com/Nemo2011/bilibili-api/pull/646
* **[BREAKING CHANGE]** SUBSCRIBE_SECRETLY 悄悄关注已失效
* **[BREAKING CHANGE]** get_client_info 失效
* fix: live.py重连清理无效的ws链接和心跳任务 by @blyc in https://github.com/Nemo2011/bilibili-api/pull/655
* **[BREAKING CHANGE]** fix: get_comment_lazy by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/c84993a86682dd1ce3d4725a07da96b54b51dc91
* fix: UnderLineNode by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/687c24040174b08c23fb2f716fa37f328eb1c293
* fix: bvid2aid by @nooblong in https://github.com/Nemo2011/bilibili-api/pull/666
* fix: topic.get_cards by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/404673ccc7faa7e8e2c840db575d45d3a4ebd3fb


* feat: video_uploader lines probe by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/548
* feat: live.get_room_status_by_uids in https://github.com/Nemo2011/bilibili-api/pull/556
* feat: live.send_danmaku.reply_mid by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/558
* feat: video_uploader enhancement in https://github.com/Nemo2011/bilibili-api/issues/543 by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/555
* feat: 增加查看及赠送免费人气票功能 by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/566
* feat: get_black_list 增加翻页功能 by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/567
* feat: audio_uploader by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/559
* feat: User.get_media_list by @TZFC in https://github.com/Nemo2011/bilibili-api/pull/599
* feat: liveroom update room news by @whille in https://github.com/Nemo2011/bilibili-api/pull/612
* 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.
* feat: session.EventType by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/636
* feat: bili_ticket by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/637
* feat: 登录记录/节操记录/经验记录 by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/fd804990091a6d15898b526fc2cdf55a8fa79d83
* 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
* feat: festival.py by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/f5a5d2a0282e4c1c5fccf4af1fbb07f7c69a72e4
* feat: login with tv by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/654
* feat: search_by_type page_size by @z0z0r4 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/244732145b035329007b1882d7eaa4cc648ad8d3
* feat: Credential.from_cookies by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/352099e3b312aebf80052c9ad4a407cf397b871c
* feat: opus.py by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/9f99241ea1e37588e075a6820d3a9906ee17b7c4 and more.
* feat: add StatementException instead of assert by @Nemo2011 in https://github.com/Nemo2011/bilibili-api/pull/668/commits/6cff631eb6fff0a6881c8ea95a3d0e05e307d432


* 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.
* **[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


# v16.1.1 2023/10/15

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


**Full Changelog**: https://github.com/Nemo2011/bilibili-api/compare/16.1.0...16.1.1
Expand Down
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
![bilibili-api logo](https://raw.githubusercontent.com/Nemo2011/bilibili-api/main/design/logo.png)
![bilibili-api logo](https://raw.githubusercontent.com/Nemo2011/bilibili-api/main/design/logo-newYear.jpg)

<div align="center">

# bilibili-api

[![API 数量](https://img.shields.io/badge/API%20数量-300+-blue)][api.json]
[![API 数量](https://img.shields.io/badge/API%20数量-400+-blue)][api.json]
[![LICENSE](https://img.shields.io/badge/LICENSE-GPLv3+-red)][LICENSE]
[![Python](https://img.shields.io/badge/python-3.11|3.10|3.9|3.8-blue)](https://www.python.org)
<!-- [![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi] -->
[![Python](https://img.shields.io/badge/python-3.12(dev)|3.11|3.10|3.9|3.8-blue)](https://www.python.org)
[![Stable Version](https://img.shields.io/pypi/v/bilibili-api-python?label=stable)][pypi]
[![Pre-release Version](https://img.shields.io/github/v/release/Nemo2011/bilibili-api?label=pre-release&include_prereleases&sort=semver)][pypi-dev]
[![STARS](https://img.shields.io/github/stars/nemo2011/bilibili-api?color=yellow&label=Github%20Stars)][stargazers]
[![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)
Expand Down Expand Up @@ -55,6 +55,7 @@ $ pip3 install bilibili-api-python
import asyncio
from bilibili_api import video


async def main() -> None:
# 实例化 Video 类
v = video.Video(bvid="BV1uv411q7Mv")
Expand All @@ -63,8 +64,10 @@ async def main() -> None:
# 打印信息
print(info)

if __name__ == '__main__':

if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())

```

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

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

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

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

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

> 注:
> 目前代码中采用 `WebSocket` 的部分(如视频实时检测、直播)采用 `aiohttp.ClientSession` 请求。其他地方均采用 `httpx.AsyncClient`
以下为 `API` 关于异步请求库使用的详细信息:

| Feature | 同步 | 异步 | aiohttp | httpx | 备注 |
| ------ | ---- | ----- | ------ | ------ | ---- |
| `LiveDanmaku` & `VideoOnlineMonitor` | [] | [x] | [x] | [ ] | httpx 暂不支持 `WebSocket` |
| `login` | [x] | [ ] | [ ] | [x] | 目前暂时仅支持同步请求 |
| other | [] | [x] | [x] | [x] | |

# FA♂Q

Expand Down
32 changes: 13 additions & 19 deletions bilibili_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,20 @@
import platform

from .utils.sync import sync
from .credential import Credential
from .utils.credential_refresh import Credential
from .utils.picture import Picture
from .utils.short import get_real_url
from .utils.parse_link import ResourceType, parse_link
from .utils.aid_bvid_transformer import aid2bvid, bvid2aid
from .utils.danmaku import DmMode, Danmaku, DmFontSize, SpecialDanmaku
from .utils.network import (
HEADERS,
Api,
retry,
enc_wbi,
get_nav,
check_valid,
get_session,
set_session,
get_mixin_key,
get_aiohttp_session,
set_aiohttp_session
set_aiohttp_session,
get_httpx_sync_session,
set_httpx_sync_session
)
from .errors import (
LoginError,
Expand Down Expand Up @@ -58,19 +54,21 @@
emoji,
login,
manga,
music,
topic,
video,
cheese,
client,
search,
article,
bangumi,
channel,
comment,
dynamic,
session,
festival,
homepage,
settings,
watchroom,
live_area,
video_tag,
black_room,
Expand All @@ -82,20 +80,19 @@
creative_center,
article_category,
interactive_video,
audio_uploader,
)

BILIBILI_API_VERSION = "16.1.1"
BILIBILI_API_VERSION = "16.1.2"

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

__all__ = [
"Api",
"ApiException",
"ArgsException",
"BILIBILI_API_VERSION",
"check_valid",
"Credential",
"CredentialNoBiliJctException",
"CredentialNoBuvid3Exception",
Expand All @@ -106,7 +103,6 @@
"DmFontSize",
"DmMode",
"DynamicExceedImagesException",
"enc_wbi",
"HEADERS",
"LiveException",
"LoginError",
Expand All @@ -122,12 +118,11 @@
"article",
"article_category",
"ass",
"asyncio",
"audio",
"audio_uploader",
"bangumi",
"black_room",
"bvid2aid",
"channel",
"channel_series",
"cheese",
"client",
Expand All @@ -136,10 +131,9 @@
"dynamic",
"emoji",
"favorite_list",
"festival",
"game",
"get_aiohttp_session",
"get_mixin_key",
"get_nav",
"get_real_url",
"get_session",
"homepage",
Expand All @@ -150,11 +144,10 @@
"login",
"login_func",
"manga",
"music",
"note",
"parse_link",
"platform",
"rank",
"retry",
"search",
"session",
"set_aiohttp_session",
Expand All @@ -169,4 +162,5 @@
"video_uploader",
"video_zone",
"vote",
"watchroom",
]
Loading

0 comments on commit d3b7ab5

Please sign in to comment.