Skip to content

Commit

Permalink
fix: comment.get_comments_lazy
Browse files Browse the repository at this point in the history
BREAKING CHANGE: 删除 next, ps 参数,增加 offset 参数
  • Loading branch information
Nemo2011 committed Aug 30, 2024
1 parent 653b27b commit 638406b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: 文档勘误
about: 使用该模板汇报文档错误
title: "[文档] 这里填写标题"
title: "[文档] 这里填写标题"
labels: 'documentation'
assignees: ''

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/features.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: 提交需求/新功能
about: 使用该模板进行提交需求/新功能
title: "[新功能] {这里填写标题}"
title: "[新功能] 这里填写标题"
labels: 'features'
assignees: ''

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: 提出疑问
about: 使用该模板进行提问
title: "[提问] {这里填写标题}"
title: "[提问] 这里填写标题"
labels: 'question'
assignees: ''

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/suggestion.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: 建言献策
about: 使用该模板提建议
title: "[建议] {这里填写标题}"
title: "[建议] 这里填写标题"
labels: '建议'
assignees: 'enhancement'

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: 漏洞反馈
about: 使用该模板进行漏洞反馈
title: "[漏洞] {这里填写标题}"
title: "[漏洞] 这里填写标题"
labels: 'bug'
assignees: ''

Expand Down
16 changes: 6 additions & 10 deletions bilibili_api/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,7 @@ async def get_comments(
async def get_comments_lazy(
oid: int,
type_: CommentResourceType,
# pagination_str: str = "",
pn: int = 1,
ps: int = 20,
offset: str = '',
order: OrderType = OrderType.TIME,
credential: Union[Credential, None] = None,
) -> dict:
Expand All @@ -449,11 +447,7 @@ async def get_comments_lazy(
type_ (CommentsResourceType) : 资源类枚举。
pagination_str (str, optional) : 分页依据 Defaults to `{"offset":""}`. 弃用 #658
pn (int, optional) : 页码. Defaults to 1.
ps (int, optional) : 每页数量. Defaults to 20.
offset (str, optional) : 偏移量。每次请求可获取下次请求对应的偏移量,类似单向链表。
order (OrderType, optional) : 排序方式枚举. Defaults to OrderType.TIME.
Expand All @@ -462,12 +456,14 @@ async def get_comments_lazy(
Returns:
dict: 调用 API 返回的结果
"""
offset = offset.replace('"', '\\"')
offset = '{"offset":"' + offset + '"}'
api = API["comment"]["reply_by_session_id"]
params = {
"oid": oid,
"type": type_.value,
"mode": order.value,
"next": pn - 1,
"ps": ps,
"pagination_str": offset,
"web_location": "1315875",
}
return await Api(**api, credential=credential).update_params(**params).result
4 changes: 1 addition & 3 deletions docs/modules/comment.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ from bilibili_api import comment
| - | - | - |
| oid | int | 资源 ID。 |
| type_ | CommentsResourceType | 资源类枚举。 |
| pagination_str | Union[str, None] | 分页依据 Defaults to `{"offset" |
| pn | Union[int, None] | 页码. Defaults to 1. |
| ps | Union[int, None] | 每页数量. Defaults to 20. |
| offset | Union[str, None] | 偏移量。每次请求可获取下次请求对应的偏移量,类似单向链表。 |
| order | Union[OrderType, None] | 排序方式枚举. Defaults to OrderType.TIME. |
| credential | Union[Credential, None] | 凭据。Defaults to None. |

Expand Down

0 comments on commit 638406b

Please sign in to comment.