Skip to content

Commit

Permalink
docs: improve docstring / docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo2011 committed Feb 10, 2025
1 parent a043471 commit 41929f6
Show file tree
Hide file tree
Showing 62 changed files with 1,761 additions and 1,861 deletions.
10 changes: 5 additions & 5 deletions bilibili_api/bangumi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ async def get_up_info(self) -> dict:
番剧上传者信息 出差或者原版
Returns:
Api 相关字段
dict: Api 相关字段
"""
if not self.__up_info:
await self.__fetch_raw()
Expand All @@ -1129,7 +1129,7 @@ async def get_raw(self) -> Tuple[dict, bool]:
原始初始化数据
Returns:
Api 相关字段
dict: Api 相关字段
"""
if not self.__raw:
await self.__fetch_raw()
Expand Down Expand Up @@ -1599,7 +1599,7 @@ async def get_player_info(self):
获取视频上一次播放的记录,字幕和地区信息。需要分集的 cid, 返回数据中含有json字幕的链接
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
return await super().get_player_info(await self.get_cid(), self.get_epid())

Expand All @@ -1608,7 +1608,7 @@ async def get_subtitle(self):
获取字幕信息
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
return (await self.get_player_info()).get("subtitle")

Expand Down Expand Up @@ -1655,7 +1655,7 @@ async def get_pbp(self):
获取高能进度条
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
return await super().get_pbp(0)

Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/channel_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def get_meta(self) -> dict:
获取元数据
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
if not self.meta:
await self.__fetch_meta()
Expand All @@ -125,7 +125,7 @@ async def get_videos(
ps(int) : 每一页显示的视频数量
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
if self.__uid == -1:
await self.__fetch_meta()
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/cheese.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async def get_meta(self) -> dict:
获取教程元数据
Returns:
调用 API 所得的结果。
dict: 调用 API 返回的结果
"""
api = API["info"]["meta"]
params = {"season_id": await self.get_season_id()}
Expand Down Expand Up @@ -639,7 +639,7 @@ async def get_pbp(self) -> dict:
获取高能进度条
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
cid = await self.get_cid()
api = API_video["info"]["pbp"]
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/creative_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ async def get_video_upload_manager_info(
ps (int): 每页项数
tid: (VideoZoneTypes, None, int): 分区
tid (VideoZoneTypes, None, int): 分区
status (UploadManagerStatus): 稿件状态
Expand Down
8 changes: 4 additions & 4 deletions bilibili_api/homepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def get_top_photo() -> dict:
例如:b 站的风叶穿行,通过这个 API 获取的图片就是风叶穿行的图片。
Returns:
调用 API 返回的结果。
dict: 调用 API 返回的结果。
"""
api = API["info"]["top_photo"]
params = {"resource_id": 142}
Expand All @@ -34,7 +34,7 @@ async def get_links(credential: Union[Credential, None] = None):
credential (Credential | None): 凭据类
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
api = API["info"]["links"]
params = {"pf": 0, "ids": 4694}
Expand All @@ -50,7 +50,7 @@ async def get_popularize(credential: Union[Credential, None] = None):
credential(Credential | None): 凭据类
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
api = API["info"]["popularize"]
params = {"pf": 0, "ids": 34}
Expand All @@ -65,7 +65,7 @@ async def get_videos(credential: Union[Credential, None] = None):
credential (Credential | None): 凭据类
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
api = API["info"]["videos"]
return await Api(**api, credential=credential).result
2 changes: 1 addition & 1 deletion bilibili_api/hot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def get_weekly_hot_videos_list() -> dict:
获取每周必看列表(仅概述)
Returns:
调用 API 返回的结果
dict: 调用 API 返回的结果
"""
api = API_rank["info"]["weekly_series"]
return await Api(**api).result
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/interactive_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def run_command(self) -> List["InteractiveVariable"]:
执行操作
Returns:
List[InteractiveVariable]
List[InteractiveVariable]: 所有变量的最终值
"""
if self.__command == "":
return self.__vars
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ async def update_news(self, content: str) -> dict:
更新公告
Args:
content: 最多60字符
content (str): 最多 60 字符
Returns:
dict: 调用 API 返回的结果
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/live_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_area_info_by_id(id: int) -> Tuple[Union[dict, None], Union[dict, None]]:
id (int): 分区的 id。
Returns:
`Tuple[dict | None, dict | None]`: 第一个是主分区,第二个是子分区,没有时返回 None。
Tuple[dict | None, dict | None]: 第一个是主分区,第二个是子分区,没有时返回 None。
"""
global live_area_data
if not live_area_data:
Expand Down
12 changes: 6 additions & 6 deletions bilibili_api/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ def __init__(self, data: dict, self_uid: int):
信息事件类型
Args:
data: 接收到的事件详细信息
data (dict): 接收到的事件详细信息
self_uid: 用户自身 UID
self_uid (int): 用户自身 UID
"""
self.__dict__.update(data)
self.uid = self_uid
Expand Down Expand Up @@ -479,7 +479,7 @@ async def run(self, exclude_self: bool = True) -> None:
非阻塞异步爬虫 定时发送请求获取消息
Args:
exclude_self: bool 是否排除自己发出的消息,默认排除
exclude_self (bool): 是否排除自己发出的消息,默认排除
"""

# 获取自身UID 用于后续判断消息是发送还是接收
Expand Down Expand Up @@ -558,7 +558,7 @@ async def start(self, exclude_self: bool = True) -> None:
阻塞异步启动 通过调用 self.close() 后可断开连接
Args:
exclude_self: bool 是否排除自己发出的消息,默认排除
exclude_self (bool): 是否排除自己发出的消息,默认排除
"""

await self.run(exclude_self)
Expand All @@ -573,9 +573,9 @@ async def reply(self, event: Event, content: Union[str, Picture]) -> dict: # ty
快速回复消息
Args:
event : Event 要回复的消息
event (Event) : 要回复的消息
content: str | Picture 要回复的文字内容
content (str | Picture): 要回复的文字内容
Returns:
dict: 调用接口返回的内容。
Expand Down
20 changes: 10 additions & 10 deletions bilibili_api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ async def create_subscribe_group(name: str, credential: Credential) -> dict:
credential (Credential): Credential
Returns:
API 调用返回结果。
dict: API 调用返回结果。
"""
credential.raise_for_no_sessdata()
credential.raise_for_no_bili_jct()
Expand All @@ -1157,7 +1157,7 @@ async def delete_subscribe_group(group_id: int, credential: Credential) -> dict:
credential (Credential): Credential
Returns:
调用 API 返回结果
dict: 调用 API 返回结果
"""
credential.raise_for_no_sessdata()
credential.raise_for_no_bili_jct()
Expand All @@ -1182,7 +1182,7 @@ async def rename_subscribe_group(
credential (Credential): Credential
Returns:
调用 API 返回结果
dict: 调用 API 返回结果
"""
credential.raise_for_no_sessdata()
credential.raise_for_no_bili_jct()
Expand All @@ -1207,7 +1207,7 @@ async def set_subscribe_group(
credential (Credential): Credential
Returns:
API 调用结果
dict: API 调用结果
"""
credential.raise_for_no_sessdata()
credential.raise_for_no_bili_jct()
Expand Down Expand Up @@ -1465,11 +1465,11 @@ async def get_self_notes_info(
获取自己的笔记列表
Args:
page_num: 页码
page_num (int): 页码
page_size: 每页项数
page_size (int): 每页项数
credential(Credential): 凭据类
credential (Credential): 凭据类
Returns:
dict: 调用 API 返回的结果
Expand All @@ -1492,11 +1492,11 @@ async def get_self_public_notes_info(
获取自己的公开笔记列表
Args:
page_num: 页码
page_num (int): 页码
page_size: 每页项数
page_size (int): 每页项数
credential(Credential): 凭据类
credential (Credential): 凭据类
Returns:
dict: 调用 API 返回的结果
Expand Down
4 changes: 2 additions & 2 deletions bilibili_api/utils/AsyncEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def remove_event_listener(self, name: str, handler: Union[Callable, Coroutine])
handler (Union[Callable, Coroutine]): 要移除的函数。
Returns:
bool, 是否移除成功。
bool: 是否移除成功。
"""
name = name.upper()
if name in self.__handlers:
Expand Down Expand Up @@ -92,7 +92,7 @@ def dispatch(self, name: str, *args, **kwargs) -> None:
Args:
name (str): 事件名。
*args, **kwargs: 要传递给函数的参数。
*args, **kwargs (Any): 要传递给函数的参数。
"""
if len(args) == 0 and len(kwargs.keys()) == 0:
args = [{}]
Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/utils/danmaku.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def to_xml(self):
将弹幕转换为 xml 格式弹幕
Returns:
xml
str: xml
"""
txt = self.text.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
string = f'<d p="{self.dm_time},{self.mode},{self.font_size},{int(self.color, 16)},{self.send_time},{self.pool},{self.crc32_id},{self.id_},11">{txt}</d>'
Expand Down
10 changes: 5 additions & 5 deletions bilibili_api/utils/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ def has_dedeuserid(self) -> bool:
是否提供 dedeuserid。
Returns:
bool。
bool: 是否提供 dedeuserid
"""
return self.dedeuserid is not None and self.sessdata != ""

Expand All @@ -1123,7 +1123,7 @@ def has_sessdata(self) -> bool:
是否提供 sessdata。
Returns:
bool。
bool: 是否提供 sessdata
"""
return self.sessdata is not None and self.sessdata != ""

Expand All @@ -1132,7 +1132,7 @@ def has_bili_jct(self) -> bool:
是否提供 bili_jct。
Returns:
bool。
bool: 是否提供 bili_jct
"""
return self.bili_jct is not None and self.sessdata != ""

Expand All @@ -1141,7 +1141,7 @@ def has_buvid3(self) -> bool:
是否提供 buvid3
Returns:
bool.
bool: 是否提供 buvid3
"""
return self.buvid3 is not None and self.sessdata != ""

Expand All @@ -1150,7 +1150,7 @@ def has_ac_time_value(self) -> bool:
是否提供 ac_time_value
Returns:
bool.
bool: 是否提供 ac_time_value
"""
return self.ac_time_value is not None and self.sessdata != ""

Expand Down
8 changes: 3 additions & 5 deletions bilibili_api/utils/short.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ async def get_real_url(short_url: str, credential: Optional[Credential] = None)
获取短链接跳转目标,以进行操作。
Args:
short_url(str): 短链接。
short_url (str): 短链接。
credential(Credential | None): 凭据类。
credential (Credential | None): 凭据类。
Returns:
目标链接(如果不是有效的链接会报错)
返回值为原 url 类型
str: 目标链接(如果不是有效的链接会报错)
"""
credential = credential if credential else Credential()

Expand Down
2 changes: 1 addition & 1 deletion bilibili_api/utils/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def sync(
obj (Coroutine | Future): 异步函数
Returns:
该异步函数的返回值
Any: 该异步函数的返回值
"""
try:
asyncio.get_running_loop()
Expand Down
Loading

0 comments on commit 41929f6

Please sign in to comment.