Skip to content

Commit

Permalink
chore: 新增 dynamic 获取点赞列表 API 并修复注释错误。
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo2011 committed Jun 29, 2022
1 parent 4074417 commit dfaa097
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
11 changes: 11 additions & 0 deletions bilibili_api/data/api/dynamic.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@
},
"comment": "动态转发信息,最多获取 560 条左右"
},
"likes": {
"url": "https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/spec_item_likes",
"method": "GET",
"verify": false,
"params": {
"dynamic_id": "int: 动态 ID",
"pn": "页码",
"ps": "每页数量"
},
"comment": "动态点赞信息"
},
"detail": {
"url": "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail",
"method": "GET",
Expand Down
20 changes: 20 additions & 0 deletions bilibili_api/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ async def get_reposts(self, offset: str = "0"):
Args:
offset (str, optional): 偏移值(下一页的第一个动态 ID,为该请求结果中的 offset 键对应的值),类似单向链表. Defaults to "0"
Returns:
调用 API 返回的结果
"""
api = API["info"]["repost"]
params = {"dynamic_id": self.dynamic_id}
Expand All @@ -329,6 +332,23 @@ async def get_reposts(self, offset: str = "0"):
"GET", api["url"], params=params, credential=self.credential
)

async def get_likes(self, pn: int = 1, ps: int = 30):
"""
获取动态点赞列表
Args:
pn(int): 页码,defaults to 1
ps(int): 每页大小,defaults to 30
Returns:
调用 API 返回的结果
"""
api = API["info"]["likes"]
params = {"dynamic_id": self.dynamic_id, "pn": pn, "ps": ps}
return await request(
"GET", api["url"], params=params, credential=self.credential
)

async def set_like(self, status: bool = True):
"""
设置动态点赞状态
Expand Down
6 changes: 3 additions & 3 deletions bilibili_api/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,9 +1122,9 @@ async def recall_danmaku(self, page_index: int=None, dmid: int=0, cid: int=None)
撤回弹幕
Args:
page_index: 分 P 号
dmid: 弹幕 id
cid: 分 P 编码
page_index(int): 分 P 号
dmid(int) : 弹幕 id
cid(int) : 分 P 编码
Returns:
调用 API 返回的结果
"""
Expand Down

0 comments on commit dfaa097

Please sign in to comment.