nonebot-bison
nonebot-bison copied to clipboard
Bilibili平台的json解析失败,疑似更改
环境
- nonebot-bison 版本:0.7.3
- nonebot 版本:2.2.2
- 安装方式:(以下方式的一种或者其他方式)
- 通过 nb-cli 安装
- 操作系统: Ubuntu20.04
问题
最近发现B站的某些动态没有推送到群,查看nb日志发现请求的json中缺少需要的key"topic_details"
导致解析失败
日志
File "/root/.cache/pypoetry/virtualenvs/nbb-2-cnPePOHF-py3.10/lib/python3.10/site-packages/nonebot_bison/scheduler/scheduler.py", line 96,
in exec_fetch
to_send = await platform_obj.do_fetch_new_post(
File "/root/.cache/pypoetry/virtualenvs/nbb-2-cnPePOHF-py3.10/lib/python3.10/site-packages/nonebot_bison/platform/platform.py", line 94, in do_fetch_new_post
return await self.fetch_new_post(target, users)
File "/root/.cache/pypoetry/virtualenvs/nbb-2-cnPePOHF-py3.10/lib/python3.10/site-packages/nonebot_bison/platform/platform.py", line 331,
in fetch_new_post
res = await self.dispatch_user_post(target, new_posts, users)
File "/root/.cache/pypoetry/virtualenvs/nbb-2-cnPePOHF-py3.10/lib/python3.10/site-packages/nonebot_bison/platform/platform.py", line 203,
in dispatch_user_post
user_raw_post = await self.filter_user_custom(
File "/root/.cache/pypoetry/virtualenvs/nbb-2-cnPePOHF-py3.10/lib/python3.10/site-packages/nonebot_bison/platform/platform.py", line 190,
in filter_user_custom
raw_post_tags = self.get_tags(raw_post)
File "/root/.cache/pypoetry/virtualenvs/nbb-2-cnPePOHF-py3.10/lib/python3.10/site-packages/nonebot_bison/platform/bilibili.py", line 135,
in get_tags
raw_post["display"]["topic_info"]["topic_details"],
KeyError: ('topic_details', ['https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=3493087233968327&offset=0&need_t
op=0 Headers({\'host\': \'api.vc.bilibili.com\', \'accept\': \'*/*\', \'accept-encoding\': \'gzip, deflate\', \'connection\': \'keep-alive\'
, \'user-agent\': \'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36\', \'cookie\':
\'l=v; LIVE_BUVID=AUTO3116864601729701;
详细json附于此 err.log
- [x] 我搜索过了 issue,但是并没有发现过与我类似的问题
- [x] 我确认在日志中去掉了敏感信息
目前的处理是获取不到对应的字段则返回空列表 #354 topic_info字段的缺失并不在所有B站动态中出现
fixed by #573