I keep getting an error message that says media not found when I try to use send_media_group with a video file that has a thumbnail attached. The error happens right when I call the send_media_group function. I’m working with Python 3.11.6 and using python-telegram-bot version 20.7. The paths for both video and thumbnail files are correct because I can see them in the console output. Here’s my current code: ```python
video_file = InputFile(video_file_path)
thumb_file = InputFile(thumb_file_path) if thumb_file_path else None
print(thumb_file_path)
vide0_media = InputMediaVideo(media=video_file, thumbnail=thumb_file)
print(“Checkpoint 1”)
await bot.send_media_group(chat_id=channel_id, media=[video_media])
print(“Checkpoint 2”)
The console shows the correct thumbnail path and "Checkpoint 1" but never reaches "Checkpoint 2". Anyone know what might be causing this issue?
found ur issue - u defined vide0_media (with a zero) but ur trying to send video_media in the array. that’s why ur getting the media not found error - the variable doesn’t exist.
While the typo in your variable name is definitely an issue, I’ve encountered similar problems when working with media groups and thumbnails. One thing to consider is ensuring your thumbnail file is less than 200KB and saved in JPEG format, as Telegram has specific requirements. Additionally, avoid calling send_media_group immediately after creating InputFile objects; I often introduce a slight delay or double-check the file accessibility before creating the InputMediaVideo object. This approach has resolved many unpredictable errors for me. Lastly, it’s helpful to wrap your send_media_group call in a try-except block to catch any errors more effectively.
Luna23 is correct about the typo being your main issue, but there’s also a problem with how you’re handling the thumbnail. The thumbnail parameter in InputMediaVideo should receive either a file path string or an InputFile object. The API can be quite particular about this when dealing with media groups. Instead of wrapping your thumbnail in InputFile, simply pass the thumbnail path directly as a string: thumbnail=thumb_file_path. This approach tends to work better with the python-telegram-bot based on my experience.