0

The code I'm using looks like that:

bot.send_photo(id, message.video.thumbnail.file_id, caption=message.caption)

And it throws this error:

telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't use file of type Thumbnail as Photo

How do I forward the thumbnail without downloading it?

Barbara Gendron
  • 385
  • 1
  • 2
  • 16
Kuki
  • 33
  • 7
  • Have you tried saving the file first and then attaching it? – doneforaiur Aug 08 '23 at 14:10
  • @doneforaiur, yes, it worked, but I'm searching for a way to do it without downloading the file – Kuki Aug 08 '23 at 14:14
  • Replacing `message.video.thumbnail.file_id` with `open(bot.download_media(message.video.thumbnail.file_id, in_memory=True))` should work. Could you try? – doneforaiur Aug 08 '23 at 14:22
  • `Unresolved attribute reference 'download_media' for class 'TeleBot' ` – Kuki Aug 08 '23 at 14:26
  • `thumbnail_file = bot.get_file(message.video.thumb.file_id) thumbnail_url = f"https://api.telegram.org/file/bot{bot.token}/{thumbnail_file.file_path}" response = requests.get(thumbnail_url) if response.status_code == 200: thumbnail_image = BytesIO(response.content) bot.send_photo(id, photo=thumbnail_image, caption=message.caption)` This code worked, but I want to find a way to forward the thumb (or thumbnail, I don't know the difference) without having to download it – Kuki Aug 08 '23 at 14:34
  • Oh my bad! I totally mixed up telebot and pyrogram. :') According to [doc](https://pytba.readthedocs.io/en/latest/types.html#telebot.types.InputFile)s, [send_photo](https://pytba.readthedocs.io/en/latest/sync_version/index.html#telebot.TeleBot.send_photo) accepts `io.IOBase` or `pathlib.Path` or `str`. Could you print `message.video` and `message.video.thumbnail`? I'm not sure if I can help but I'm curious. :^) – doneforaiur Aug 08 '23 at 14:45
  • [This](https://stackoverflow.com/a/44481279/8658598) should work since you can get the URL. – doneforaiur Aug 08 '23 at 14:48
  • video - {'file_id': '...', 'file_unique_id': '...', 'width': 1280, 'height': 720, 'duration': 49, 'thumbnail': {'file_id': '...', 'file_unique_id': '...', 'width': 320, 'height': 180, 'file_size': 6523}, 'file_name': None, 'mime_type': 'video/mp4', 'file_size': 9840542} thumbnail - {'file_id': '...', 'file_unique_id': '...', 'width': 320, 'height': 180, 'file_size': 6523} I replaced the ids with triple dots – Kuki Aug 08 '23 at 17:30
  • Thank you for the option, but I mean... There must be a way to forward the photo like this: `bot.send_photo(id, message.photo[0].file_id, caption=message.caption)`. in this example I forward photos without any saving at all! and I think it is possible to forward the thumbnails in a similar way – Kuki Aug 08 '23 at 17:36

0 Answers0