y-young / nazurin

🎉 Images collection done right. Telegram 图片收藏机器人 / A Telegram bot that helps you collect ACG illustrations.
http://nazurin.readthedocs.io
MIT License
264 stars 59 forks source link

以Telegram作为存储库部分图片无法上传 #105

Closed Rebellce closed 1 week ago

Rebellce commented 2 weeks ago

Describe the bug 以Telegram作为存储库部分图片无法上传,单张图片大小9MB

To Reproduce Steps to reproduce the behavior: 使用链接收藏pixiv图片部分上传图片失败,直接报错,其他正常

Expected behavior A clear and concise description of what you expected to happen.

Error output / Logs

2024-11-04 00:31:37,284+0000 - INFO     - nazurin.sites:68 -  - Loaded 14 sites
2024-11-04 00:31:37,287+0000 - INFO     - nazurin.storage:22 -  - Loaded 1 storage(s), using: ['Telegram']
2024-11-04 00:31:37,288+0000 - INFO     - nazurin.dispatcher:101 -  - Set webhook
2024-11-04 00:31:37,851+0000 - INFO     - aiogram.utils.executor:362 -  - Bot: Pixiv-bot [@FireMoewIMGBot]
2024-11-04 00:31:38,419+0000 - WARNING  - aiogram.utils.executor:358 -  - Updates were skipped successfully.
2024-11-04 00:31:38,612+0000 - INFO     - nazurin.bot:187 -  - Cleaning up temporary directory
======== Running on http://127.0.0.1:61131 ========
(Press CTRL+C to quit)
2024-11-04 00:31:38,638+0000 - INFO     - nazurin.bot:190 -  - Cleaned up temporary directory
2024-11-04 00:32:20,914+0000 - INFO     - nazurin.middleware:25 - update:425634817 - Message 296: https://www.pixiv.net/artworks/97045374
2024-11-04 00:32:20,920+0000 - INFO     - nazurin.bot:157 - update:425634817 - Collection update: source=pixiv, match=('97045374',)
2024-11-04 00:32:20,921+0000 - INFO     - nazurin.sites.pixiv.api:79 - update:425634817 - Pixiv logged in through cached tokens
2024-11-04 00:32:20,927+0000 - INFO     - aiohttp.web_log:206 -  - 127.0.0.1 "POST /XXXXX:XXXXX HTTP/1.1" 200 152 "-" "-"
2024-11-04 00:32:21,203+0000 - INFO     - nazurin.sites.pixiv.api:150 - update:425634817 - Bookmarked artwork 97045374, privacy = public
2024-11-04 00:32:21,371+0000 - INFO     - nazurin.models.file:70 - update:425634817 - File data/temp/97045374_p0 - 牛奶小偷 - 闷茶子(5373467).png already exists
2024-11-04 00:32:21,372+0000 - INFO     - nazurin.models.file:70 - update:425634817 - File data/temp/97045374_p1 - 牛奶小偷 - 闷茶子(5373467).png already exists
2024-11-04 00:32:22,110+0000 - INFO     - nazurin.models.image:67 - update:425634817 - Use thumbnail (Unknown size or size > 5MB [10436915]): https://i.pximg.net/img-master/img/2022/03/20/15/24/46/97045374_p0_master1200.jpg
2024-11-04 00:32:22,112+0000 - INFO     - nazurin.models.image:56 - update:425634817 - Use thumbnail (Unkown image size or width + height > 10000 [0, 0]): https://i.pximg.net/img-master/img/2022/03/20/15/24/46/97045374_p1_master1200.jpg
2024-11-04 00:32:22,492+0000 - WARNING  - nazurin.models.image:108 - update:425634817 - Downloaded file size True does not match image size 10436915, attempt 1 / 3
2024-11-04 00:32:22,496+0000 - INFO     - nazurin.models.file:73 - update:425634817 - Downloading https://i.pximg.net/img-original/img/2022/03/20/15/24/46/97045374_p0.png to data/temp/97045374_p0 - 牛奶小偷 - 闷茶子(5373467).png...
2024-11-04 00:32:23,888+0000 - INFO     - nazurin.models.file:76 - update:425634817 - Downloaded to data/temp/97045374_p0 - 牛奶小偷 - 闷茶子(5373467).png, size = 10436915
2024-11-04 00:32:29,741+0000 - ERROR    - nazurin.utils.helpers:35 - update:425634817 - BadRequest exception: Failed to send message #2 with the error message "webpage_curl_failed"
2024-11-04 00:32:29,741+0000 - ERROR    - __main__:103 - update:425634817 - Update {"update_id": 425634817, "message": {"message_id": 296, "from": {"id": 773639375, "is_bot": false, "first_name": "Fire", "last_name": "Meow", "language_code": "zh-hans"}, "chat": {"id": 773639375, "first_name": "Fire", "last_name": "Meow", "type": "private"}, "date": 1730680340, "text": "https://www.pixiv.net/artworks/97045374", "entities": [{"type": "url", "offset": 0, "length": 39}], "link_preview_options": {"url": "https://www.pixiv.net/artworks/97045374"}}} caused <class 'aiogram.utils.exceptions.BadRequest'>: Failed to send message #2 with the error message "webpage_curl_failed"
Traceback (most recent call last):

  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
           │         │     └ {'__name__': '__main__', '__doc__': None, '__package__': 'nazurin', '__loader__': <_frozen_importlib_external.SourceFileLoade...
           │         └ <code object <module> at 0x7ff036afdb30, file "/app/nazurin/__main__.py", line 1>
           └ <function _run_code at 0x7ff03a6d2040>
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
         │     └ {'__name__': '__main__', '__doc__': None, '__package__': 'nazurin', '__loader__': <_frozen_importlib_external.SourceFileLoade...
         └ <code object <module> at 0x7ff036afdb30, file "/app/nazurin/__main__.py", line 1>

  File "/app/nazurin/__main__.py", line 115, in <module>
    main()
    └ <function main at 0x7ff03a5355e0>

  File "/app/nazurin/__main__.py", line 111, in main
    dp.start()
    │  └ <function NazurinDispatcher.start at 0x7ff036fb7310>
    └ <nazurin.dispatcher.NazurinDispatcher object at 0x7ff036af1130>

  File "/app/nazurin/dispatcher.py", line 110, in start
    self.executor.run_app(
    │    │        └ <function Executor.run_app at 0x7ff038296c10>
    │    └ <aiogram.utils.executor.Executor object at 0x7ff036fbe250>
    └ <nazurin.dispatcher.NazurinDispatcher object at 0x7ff036af1130>

  File "/usr/local/lib/python3.8/site-packages/aiogram/utils/executor.py", line 292, in run_app
    web.run_app(self._web_app, **kwargs)
    │   │       │    │           └ {'host': '127.0.0.1', 'port': 61131, 'loop': <_UnixSelectorEventLoop running=True closed=False debug=False>, 'access_log_form...
    │   │       │    └ <Application 0x7ff036fb6f70>
    │   │       └ <aiogram.utils.executor.Executor object at 0x7ff036fbe250>
    │   └ <function run_app at 0x7ff0386f23a0>
    └ <module 'aiohttp.web' from '/usr/local/lib/python3.8/site-packages/aiohttp/web.py'>
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web.py", line 516, in run_app
    loop.run_until_complete(main_task)
    │    │                  └ <Task pending name='Task-7' coro=<_run_app() running at /usr/local/lib/python3.8/site-packages/aiohttp/web.py:433> wait_for=<...
    │    └ <function BaseEventLoop.run_until_complete at 0x7ff039cdaca0>
    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete
    self.run_forever()
    │    └ <function BaseEventLoop.run_forever at 0x7ff039cdac10>
    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
    │    └ <function BaseEventLoop._run_once at 0x7ff039da7790>
    └ <_UnixSelectorEventLoop running=True closed=False debug=False>
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1859, in _run_once
    handle._run()
    │      └ <function Handle._run at 0x7ff039baf670>
    └ <Handle <TaskStepMethWrapper object at 0x7ff036b38850>()>
  File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
    │    │            │    │           │    └ <member '_args' of 'Handle' objects>
    │    │            │    │           └ <Handle <TaskStepMethWrapper object at 0x7ff036b38850>()>
    │    │            │    └ <member '_callback' of 'Handle' objects>
    │    │            └ <Handle <TaskStepMethWrapper object at 0x7ff036b38850>()>
    │    └ <member '_context' of 'Handle' objects>
    └ <Handle <TaskStepMethWrapper object at 0x7ff036b38850>()>

> File "/app/nazurin/__main__.py", line 91, in on_error
    raise exception
          └ BadRequest('Failed to send message #2 with the error message "webpage_curl_failed"')

  File "/usr/local/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 1397, in process_response
    response = task.result()
               │    └ <method 'result' of '_asyncio.Task' objects>
               └ <Task finished name='Task-16' coro=<NazurinDispatcher.update_collection() done, defined at /app/nazurin/dispatcher.py:120> ex...

  File "/app/nazurin/dispatcher.py", line 122, in update_collection
    await self.bot.update_collection(urls, message)
          │    │   │                 │     └ <Message {"message_id": 296, "from": {"id": 773639375, "is_bot": false, "first_name": "Fire", "last_name": "Meow", "language_...
          │    │   │                 └ ['https://www.pixiv.net/artworks/97045374']
          │    │   └ <function NazurinBot.update_collection at 0x7ff036aed3a0>
          │    └ <nazurin.bot.NazurinBot object at 0x7ff036948220>
          └ <nazurin.dispatcher.NazurinDispatcher object at 0x7ff036af1130>

  File "/app/nazurin/bot.py", line 174, in update_collection
    await asyncio.gather(save, download)
          │       │      │     └ <Task finished name='Task-17' coro=<PixivIllust.download() done, defined at /app/nazurin/sites/pixiv/models.py:22> result=None>
          │       │      └ <Task finished name='Task-18' coro=<NazurinBot.send_to_gallery() done, defined at /app/nazurin/bot.py:126> exception=BadReque...
          │       └ <function gather at 0x7ff039cd0280>
          └ <module 'asyncio' from '/usr/local/lib/python3.8/asyncio/__init__.py'>

  File "/app/nazurin/bot.py", line 147, in send_to_gallery
    await self.send_illust(illust, message, config.GALLERY_ID)
          │    │           │       │        │      └ -100218564116
          │    │           │       │        └ <module 'nazurin.config' from '/app/nazurin/config.py'>
          │    │           │       └ <Message {"message_id": 296, "from": {"id": 773639375, "is_bot": false, "first_name": "Fire", "last_name": "Meow", "language_...
          │    │           └ PixivIllust(id=97045374, images=[PixivImage(name='97045374_p0 - 牛奶小偷 - 闷茶子(5373467).png', url='https://i.pximg.net/img-origin...
          │    └ <function NazurinBot.send_illust at 0x7ff036aed0d0>
          └ <nazurin.bot.NazurinBot object at 0x7ff036948220>

  File "/app/nazurin/bot.py", line 100, in send_illust
    await handle_bad_request(message, error)
          │                  └ <Message {"message_id": 296, "from": {"id": 773639375, "is_bot": false, "first_name": "Fire", "last_name": "Meow", "language_...
          └ <function handle_bad_request at 0x7ff036956ee0>

  File "/app/nazurin/utils/helpers.py", line 53, in handle_bad_request
    raise error
          └ BadRequest('Failed to send message #2 with the error message "webpage_curl_failed"')

  File "/app/nazurin/bot.py", line 98, in send_illust
    await self.send_photos(illust, chat_id, reply_to)
          │    │           │       │        └ None
          │    │           │       └ -100218564116
          │    │           └ PixivIllust(id=97045374, images=[PixivImage(name='97045374_p0 - 牛奶小偷 - 闷茶子(5373467).png', url='https://i.pximg.net/img-origin...
          │    └ <function NazurinBot.send_photos at 0x7ff036aed040>
          └ <nazurin.bot.NazurinBot object at 0x7ff036948220>

  File "/app/nazurin/bot.py", line 76, in send_photos
    await self.send_single_group(group, caption, chat_id, reply_to)
          │    │                 │      │        │        └ None
          │    │                 │      │        └ -100218564116
          │    │                 │      └ 'title: 牛奶小偷\nauthor: #闷茶子\ntags: #脚底 #赤脚 #Genshin_Impact #Diona #迪奥娜(原神) #imminent_tickling #Greek_foot #cat #おで娘 #原神10000收藏...
          │    │                 └ [PixivImage(name='97045374_p0 - 牛奶小偷 - 闷茶子(5373467).png', url='https://i.pximg.net/img-original/img/2022/03/20/15/24/46/97045...
          │    └ <function NazurinBot.send_single_group at 0x7ff036ae1f70>
          └ <nazurin.bot.NazurinBot object at 0x7ff036948220>

  File "/app/nazurin/utils/decorators.py", line 81, in decorator
    result = await func(*args, **kwargs)
                   │     │       └ {}
                   │     └ (<nazurin.bot.NazurinBot object at 0x7ff036948220>, [PixivImage(name='97045374_p0 - 牛奶小偷 - 闷茶子(5373467).png', url='https://i....
                   └ <function NazurinBot.send_single_group at 0x7ff036ae1ee0>

  File "/app/nazurin/bot.py", line 57, in send_single_group
    await self.send_media_group(chat_id, media, reply_to_message_id=reply_to)
          │    │                │        │                          └ None
          │    │                │        └ [<InputMediaPhoto {"media": "https://i.pximg.net/img-master/img/2022/03/20/15/24/46/97045374_p0_master1200.jpg?0.082388906149...
          │    │                └ -100218564116
          │    └ <function Bot.send_media_group at 0x7ff0384650d0>
          └ <nazurin.bot.NazurinBot object at 0x7ff036948220>

  File "/usr/local/lib/python3.8/site-packages/aiogram/bot/bot.py", line 1196, in send_media_group
    result = await self.request(api.Methods.SEND_MEDIA_GROUP, payload, files)
                   │    │       │   │       │                 │        └ {}
                   │    │       │   │       │                 └ {'chat_id': -100218564116, 'media': '[{"media": "https://i.pximg.net/img-master/img/2022/03/20/15/24/46/97045374_p0_master12...
                   │    │       │   │       └ <aiogram.utils.helper.Item object at 0x7ff0384cf220>
                   │    │       │   └ <class 'aiogram.bot.api.Methods'>
                   │    │       └ <module 'aiogram.bot.api' from '/usr/local/lib/python3.8/site-packages/aiogram/bot/api.py'>
                   │    └ <function BaseBot.request at 0x7ff038445d30>
                   └ <nazurin.bot.NazurinBot object at 0x7ff036948220>
  File "/usr/local/lib/python3.8/site-packages/aiogram/bot/base.py", line 236, in request
    return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
                 │   │                  │    │              │    │       │             │       │     └ {}
                 │   │                  │    │              │    │       │             │       └ {'chat_id': -100218564116, 'media': '[{"media": "https://i.pximg.net/img-master/img/2022/03/20/15/24/46/97045374_p0_master12...
                 │   │                  │    │              │    │       │             └ 'sendMediaGroup'
                 │   │                  │    │              │    │       └ <nazurin.bot.NazurinBot object at 0x7ff036948220>
                 │   │                  │    │              │    └ TelegramAPIServer(base='https://api.telegram.org/bot{token}/{method}', file='https://api.telegram.org/file/bot{token}/{path}')
                 │   │                  │    │              └ <nazurin.bot.NazurinBot object at 0x7ff036948220>
                 │   │                  │    └ <function BaseBot.get_session at 0x7ff0384455e0>
                 │   │                  └ <nazurin.bot.NazurinBot object at 0x7ff036948220>
                 │   └ <function make_request at 0x7ff0384c6af0>
                 └ <module 'aiogram.bot.api' from '/usr/local/lib/python3.8/site-packages/aiogram/bot/api.py'>
  File "/usr/local/lib/python3.8/site-packages/aiogram/bot/api.py", line 140, in make_request
    return check_result(method, response.content_type, response.status, await response.text())
           │            │       │        │             │        │             │        └ <function ClientResponse.text at 0x7ff039097670>
           │            │       │        │             │        │             └ <ClientResponse(https://api.telegram.org/botXXXXX:XXXXX/sendMediaGroup) [400 Bad Request]>...
           │            │       │        │             │        └ 400
           │            │       │        │             └ <ClientResponse(https://api.telegram.org/botXXXXX:XXXXX/sendMediaGroup) [400 Bad Request]>...
           │            │       │        └ <property object at 0x7ff03921c7c0>
           │            │       └ <ClientResponse(https://api.telegram.org/botXXXXX:XXXXX/sendMediaGroup) [400 Bad Request]>...
           │            └ 'sendMediaGroup'
           └ <function check_result at 0x7ff0384c6820>
  File "/usr/local/lib/python3.8/site-packages/aiogram/bot/api.py", line 115, in check_result
    exceptions.BadRequest.detect(description)
    │          │          │      └ 'Bad Request: failed to send message #2 with the error message "WEBPAGE_CURL_FAILED"'
    │          │          └ <classmethod object at 0x7ff03878bee0>
    │          └ <class 'aiogram.utils.exceptions.BadRequest'>
    └ <module 'aiogram.utils.exceptions' from '/usr/local/lib/python3.8/site-packages/aiogram/utils/exceptions.py'>
  File "/usr/local/lib/python3.8/site-packages/aiogram/utils/exceptions.py", line 141, in detect
    raise cls(description)
          │   └ 'bad request: failed to send message #2 with the error message "webpage_curl_failed"'
          └ <class 'aiogram.utils.exceptions.BadRequest'>

aiogram.utils.exceptions.BadRequest: Failed to send message #2 with the error message "webpage_curl_failed"

Environment (please complete the following information):

Additional context Add any other context about the problem here.

Rebellce commented 2 weeks ago

截图 注释掉设置画廊频道后可以正常存储。

Rebellce commented 2 weeks ago

好像问题是画廊最开始用的ID是群组的,开始也能正常用后面不知道为啥就出bug了。今天下午换成新建的频道了目前一切正常。

y-young commented 2 weeks ago

这个问题也有可能是临时的,或许多试几次就好了。