bilibili-api icon indicating copy to clipboard operation
bilibili-api copied to clipboard

[漏洞] 老问题 'NoneType' object has no attribute '__dict__'

Open tonylua opened this issue 1 year ago • 1 comments

bilibili-api-python 16.2.0

video_uploader.py 中,需要修改 porder 相关行为:

"porder": self.porder.dict() if self.porder else None

tonylua avatar May 21 '24 16:05 tonylua

相同版本 我已经将"porder": self.porder.__dict__() 修改为 "porder": self.porder.dict() if self.porder else None ,但在获取评论的程序中仍然报错, 获取评论的代码:

async def main() ->None :

    credential=Credential(sessdata=SESSDATA , bili_jct=BILI_JCT)
    comments = []
    # 页码
    page = 1
    # 当前已获取数量
    count = 0
    while True:
        # 获取评论
        c = await comment.get_comments(418788911, comment.CommentResourceType.VIDEO, page)
        # 存储评论
        comments.extend(c['replies'])
        # 增加已获取数量
        count += c['page']['size']
        # 增加页码
        page += 1

        if count >= c['page']['count']:
            # 当前已获取数量已达到评论总数,跳出循环
            break

    # 打印评论
    for cmt in comments:
        print(f"{cmt['member']['uname']}: {cmt['content']['message']}")

    # 打印评论总数
    print(f"\n\n共有 {count} 条评论(不含子评论)")


sync(main())

Fallenstarstwice avatar Jun 28 '24 07:06 Fallenstarstwice