Well2333 / nonebot-plugin-bilichat

一个通过 OpenAI 来对b站视频进行总结的多功能 B站解析插件
GNU Affero General Public License v3.0
229 stars 10 forks source link

使用SSR获取动态失败 #247

Closed Yppup closed 3 weeks ago

Yppup commented 3 weeks ago

操作系统

Linux

Python 版本

3.10.8

NoneBot 版本

2.3.0

Bilichat 版本

5.12.4

描述问题

[ERROR] nonebot_plugin_bilichat | [Dynamic] 获取 UID RSS 动态失败: Request URL is missing an 'http://' or 'https://' protocol. 使用RSSHub自建源,源经RSS阅读器测试可以正常使用。

插件的配置项

DRIVER=~fastapi ONEBOT_ACCESS_TOKEN= SUPERUSERS=[""] LOG_LEVEL=DEBUG

COMMAND_SEP=[""] COMMAND_START=[""] bilichat_cmd_start=""

bilichat_rss_base = "http://IP:PORT/" bilichat_cd_time = 120 bilichat_neterror_retry = 3 bilichat_use_browser = True

截图或日志

09-02 17:15:43 [ERROR] nonebot_plugin_bilichat | [Dynamic] 获取 UID RSS 动态失败: Request URL is missing an 'http://' or 'https://' protocol.
Traceback (most recent call last):
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
    yield
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 373, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 167, in handle_async_request
    raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot/__init__.py", line 335, in run
    get_driver().run(*args, **kwargs)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 186, in run
    uvicorn.run(
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/uvicorn/main.py", line 575, in run
    server.run()
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/uvicorn/server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/local/bin/python3/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot/message.py", line 476, in check_and_run_matcher
    await _run_matcher(
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot/message.py", line 428, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 850, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 825, in simple_run
    await handler(
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 94, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot_plugin_bilichat/commands/functions.py", line 30, in check_dynamic_v11
    if dyn := await fetch_last_dynamic(up):
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot_plugin_bilichat/lib/fetch_dynamic.py", line 32, in fetch_last_dynamic
    return await _fetchlast_rss(up.mid)
> File "/root/BiliBot/.venv/lib/python3.10/site-packages/nonebot_plugin_bilichat/lib/fetch_dynamic.py", line 98, in _fetchlast_rss
    response = await client.get(url)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1801, in get
    return await self.request(
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1574, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1661, in send
    response = await self._send_handling_auth(
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1689, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_client.py", line 1763, in _send_single_request
    response = await transport.handle_async_request(request)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 372, in handle_async_request
    with map_httpcore_exceptions():
  File "/usr/local/bin/python3/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/root/BiliBot/.venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.
09-02 17:15:43 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_bilichat.commands.functions, lineno=19) running complete
09-02 17:15:43 [DEBUG] nonebot | Checking for matchers in priority 2...
09-02 17:15:43 [INFO] nonebot_plugin_bilichat | 查询 Text(text='checkdynamic UID', styles={}) 返回内容为空
djkcyl commented 3 weeks ago

如果可以的话,在nonebot_plugin_bilichat/lib/fetch_dynamic.py 这个文件的第98行前面打印一下 url,看看返回的是什么内容

Well2333 commented 3 weeks ago

请您提供从命令开始到报错的完整日志

Well2333 commented 3 weeks ago

另外,请您查看rsshub对于此up的返回信息,其中动态链接是否包含http头。 例如 https://rsshub.app/bilibili/user/dynamic/2267573

<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>DIYgod 的 bilibili 动态</title>
<link>https://space.bilibili.com/2267573/dynamic</link>
<atom:link href="http://rsshub.app/bilibili/user/dynamic/2267573" rel="self" type="application/rss+xml"/>
<description>DIYgod 的 bilibili 动态 - Powered by RSSHub</description>
<generator>RSSHub</generator>
<webMaster>contact@rsshub.app (RSSHub)</webMaster>
<language>en</language>
<image>
<url>https://i2.hdslb.com/bfs/face/9882696336717748a66cb70b0ed3f488f0cc9dad.jpg</url>
<title>DIYgod 的 bilibili 动态</title>
<link>https://space.bilibili.com/2267573/dynamic</link>
</image>
<lastBuildDate>Sun, 28 Jul 2024 19:05:55 GMT</lastBuildDate>
<ttl>180</ttl>
<item>
<title>【幻兽帕鲁】佐伊塔主暴揍佐伊塔主</title>
<description>视频地址:<a href="https://www.bilibili.com/video/BV1eu4m1N7cL">https://www.bilibili.com/video/BV1eu4m1N7cL</a><br><iframe src="https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=BV1eu4m1N7cL&amp;high_quality=1&amp;autoplay=0" width="650" height="477" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" referrerpolicy="no-referrer"></iframe><br><img src="http://i0.hdslb.com/bfs/archive/184adce3ab73bcbb0d441babc141262dd7e9b99f.jpg" referrerpolicy="no-referrer"></description>
<link>https://t.bilibili.com/895773042317197331</link>
<guid isPermaLink="false">https://t.bilibili.com/895773042317197331</guid>
<pubDate>Thu, 08 Feb 2024 14:16:54 GMT</pubDate>
<author>DIYgod</author>
</item>
<item>
<title>【幻兽帕鲁】佐伊塔主老婆带回家</title>
<description>视频地址:<a href="https://www.bilibili.com/video/BV1vF4m1T7Wi">https://www.bilibili.com/video/BV1vF4m1T7Wi</a><br><iframe src="https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=BV1vF4m1T7Wi&amp;high_quality=1&amp;autoplay=0" width="650" height="477" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" referrerpolicy="no-referrer"></iframe><br><img src="http://i1.hdslb.com/bfs/archive/22c8b133bdbf2626af8b7b992da6537da7ce310e.jpg" referrerpolicy="no-referrer"></description>
<link>https://t.bilibili.com/895764525364543512</link>
<guid isPermaLink="false">https://t.bilibili.com/895764525364543512</guid>
<pubDate>Thu, 08 Feb 2024 13:43:51 GMT</pubDate>
<author>DIYgod</author>
</item>

其中 <link>https://t.bilibili.com/895773042317197331</link> 是正常的返回链接

Yppup commented 3 weeks ago

如果可以的话,在nonebot_plugin_bilichat/lib/fetch_dynamic.py 这个文件的第98行前面打印一下 url,看看返回的是什么内容

如果我没有写错的话,这里url是空的,没有返回任何值。

截屏2024-09-03 11 04 35
Well2333 commented 3 weeks ago

了解问题了,是if表达式范围出错的问题,马上修复

Yppup commented 3 weeks ago

了解问题了,是if表达式范围出错的问题,马上修复

感谢🙏