Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重构B站解析插件 #1518

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

重构B站解析插件 #1518

wants to merge 1 commit into from

Conversation

leekooyo
Copy link

@leekooyo leekooyo commented Feb 3, 2024

现在可以解析QQ小程序及聊天记录中有关视频、直播、动态、专栏的内容。由于B站验证码原因,动态和专栏的截图可能会失败。

现在可以解析QQ小程序及聊天记录中有关视频、直播、动态、专栏的内容。由于B站验证码原因,动态和专栏的截图可能会失败。
@1411484730
Copy link

解析小程序时会报错误码: -400, 信息: 请求错误

@leekooyo
Copy link
Author

解析小程序时会报错误码: -400, 信息: 请求错误

能否提供一下详细的信息,我试验过安卓版本和HD版本的b站转发没有问题

@1411484730
Copy link

日志如下
`02-13 16:58:25 [ERROR] nonebot | Running Matcher(type='message', module=plugins.bilibiliParse) failed.
Traceback (most recent call last):
File "/home/pc/桌面/zhenxun_bot-main/bot.py", line 21, in
nonebot.run()
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/init.py", line 273, in run
get_driver().run(*args, **kwargs)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 172, in run
uvicorn.run(
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run
server.run()
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run
await handler(
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/home/pc/桌面/zhenxun_bot-main/plugins/bilibiliParse/init.py", line 120, in msgParse
vd_info, live_info, vd_url, live_url, image_info, image_url = await parse_bili_url(get_url, information_container)
File "/home/pc/桌面/zhenxun_bot-main/plugins/bilibiliParse/parse_bili_url.py", line 39, in parse_bili_url
vd_info = await video.get_video_base_info(vid)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/bilireq/video/init.py", line 11, in get_video_base_info
return await get(url, params=params)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/bilireq/utils/init.py", line 167, in get
return await request("GET", url, **kwargs)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/bilireq/utils/init.py", line 158, in request
raise ResponseCodeError(
bilireq.exceptions.ResponseCodeError: 错误码: -400, 信息: 请求错误
`

@leekooyo
Copy link
Author

日志如下
`02-13 16:58:25 [ERROR] nonebot | Running Matcher(type='message', module=plugins.bilibiliParse) failed.
Traceback (most recent call last):
File "/home/pc/桌面/zhenxun_bot-main/bot.py", line 21, in
nonebot.run()
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/init.py", line 273, in run
get_driver().run(*args, **kwargs)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 172, in run
uvicorn.run(
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run
server.run()
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run
await handler(
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "/home/pc/桌面/zhenxun_bot-main/plugins/bilibiliParse/init.py", line 120, in msgParse
vd_info, live_info, vd_url, live_url, image_info, image_url = await parse_bili_url(get_url, information_container)
File "/home/pc/桌面/zhenxun_bot-main/plugins/bilibiliParse/parse_bili_url.py", line 39, in parse_bili_url
vd_info = await video.get_video_base_info(vid)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/bilireq/video/init.py", line 11, in get_video_base_info
return await get(url, params=params)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/bilireq/utils/init.py", line 167, in get
return await request("GET", url, **kwargs)
File "/home/pc/.cache/pypoetry/virtualenvs/zhenxun-bot-PY0IqCSM-py3.10/lib/python3.10/site-packages/bilireq/utils/init.py", line 158, in request
raise ResponseCodeError(
bilireq.exceptions.ResponseCodeError: 错误码: -400, 信息: 请求错误
`
提供一下你的b站版本和qq版本,不然只看日志没有办法复现

@1411484730
Copy link

b站版本v7.66.0,qq版本9.0.17,gocq协议为8.9.78

@leekooyo
Copy link
Author

b站版本v7.66.0,qq版本9.0.17,gocq协议为8.9.78

很遗憾,除了使用的协议不同(我使用的是shamrock,但应该不是协议的问题),其他相同条件下我都无法成功复现。

根据你提供的日志,目前可以确定是问题出现在bilireq。-400状态码有可能是b站的风控问题,例如短时间内请求过多导致。

我检查了我一个月内的error日志,并未发现-400的状态码。如果之后还出现这样的问题的话,我再尝试复现,目前来讲我这边是没有这种问题的。

@1411484730
Copy link

bilireq=0.2.11版本及之前的会出现-400状态码,0.2.12版本无法使用报错如下

httpx.ConnectError: All connection attempts failed

@leekooyo
Copy link
Author

bilireq=0.2.11版本及之前的会出现-400状态码,0.2.12版本无法使用报错如下

httpx.ConnectError: All connection attempts failed

你有修改过“pyproject.toml”中的文件吗,我的bilireq版本为0.2.3.post0,目前是没问题的,你可以试一试

@1411484730
Copy link

1411484730 commented Feb 17, 2024

修改pyyaml=6.0.1,添加strenum=0.4.12和requests=2.21.0,我去试试降级bilireq到0.2.3.post0
更新:降级到0.2.3.post0后没有再遇到-400的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants