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

[Bug]: media caption 过长会导致转发失败 #157

Open
zj1123581321 opened this issue Mar 19, 2024 · 0 comments
Open

[Bug]: media caption 过长会导致转发失败 #157

zj1123581321 opened this issue Mar 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@zj1123581321
Copy link

telegram_media_downloader version or commit

v2.2.3

What OS are you seeing the problem on?

Windows

Python Version

3.11.6

What happened?

telegram 频道里的 photo/video 的 caption 字符长度如果超过 1024,则无法通过 api 转发,会报错 caption 过长。

这里原因在于:Media captions on Telegram can have up to 1024 characters, but Premium users can have up to 2048 characters.

Increase character limit for media captions – Bugs and Suggestions

Expected Behavior

可以将 caption 拆分成 3 段文本,然后结合媒体再进行发送

Current Behavior

发送失败,且 bot 无提示。

Possible Solution

可以将 caption 拆分成 3 段文本,然后结合媒体再进行发送

Steps to Reproduce

转发任意 photo/video 的 caption 超过 1024 长度即可复现。

Relevant log output

2024-03-19 23:10:31.069 | ERROR    | module.pyrogram_extension:upload_telegram_chat_message:305 - Upload file D:\Tg_media_downloader\2023_11\25032..mp4 error: Telegram says: [400 MEDIA_CAPTION_TOO_LONG] - The media caption is too long (caused by "messages.SendMultiMedia")
Traceback (most recent call last):

  File "media_downloader.py", line 662, in <module>

  File "media_downloader.py", line 636, in main

  File "media_downloader.py", line 590, in _exec_loop

  File "asyncio\base_events.py", line 640, in run_until_complete

  File "asyncio\windows_events.py", line 321, in run_forever

  File "asyncio\base_events.py", line 607, in run_forever

  File "asyncio\base_events.py", line 1922, in _run_once

  File "asyncio\events.py", line 80, in _run

  File "media_downloader.py", line 498, in worker

  File "media_downloader.py", line 284, in download_task

  File "module\pyrogram_extension.py", line 256, in upload_telegram_chat

> File "module\pyrogram_extension.py", line 295, in upload_telegram_chat_message

  File "module\pyrogram_extension.py", line 450, in _upload_telegram_chat_message

  File "module\pyrogram_extension.py", line 532, in forward_multi_media

  File "module\pyrogram_extension.py", line 568, in proc_cache_forward

  File "module\send_media_group_v2.py", line 389, in send_media_group_v2

  File "pyrogram\methods\advanced\invoke.py", line 79, in invoke

  File "pyrogram\session\session.py", line 358, in invoke

  File "pyrogram\session\session.py", line 328, in send

  File "pyrogram\errors\rpc_error.py", line 91, in raise_it

pyrogram.errors.exceptions.bad_request_400.MediaCaptionTooLong: Telegram says: [400 MEDIA_CAPTION_TOO_LONG] - The media caption is too long (caused by "messages.SendMultiMedia")
@zj1123581321 zj1123581321 added the bug Something isn't working label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant