From ef4f9a962c6ef41b1b1905186a26c0695b1e4be2 Mon Sep 17 00:00:00 2001 From: th3c00lw0lf <108631096+th3c00lw0lf@users.noreply.github.com> Date: Sat, 15 Oct 2022 19:01:29 +0100 Subject: [PATCH] Fix MediaEmptyError error when sending some videos (#3951) --- telethon/client/uploads.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/telethon/client/uploads.py b/telethon/client/uploads.py index a0df1b59..a27d2895 100644 --- a/telethon/client/uploads.py +++ b/telethon/client/uploads.py @@ -458,7 +458,7 @@ class UploadMethods: )) fm = utils.get_input_media( - r.document, supports_streaming=supports_streaming) + r.document, supports_streaming=supports_streaming) if captions: caption, msg_entities = captions.pop() @@ -753,13 +753,18 @@ class UploadMethods: thumb = str(thumb.absolute()) thumb = await self.upload_file(thumb, file_size=file_size) + # setting `nosound_video` to `True` doesn't affect videos with sound + # instead it prevents sending silent videos as GIFs + nosound_video = True if mime_type.split("/")[0] == 'video' else None + media = types.InputMediaUploadedDocument( file=file_handle, mime_type=mime_type, attributes=attributes, thumb=thumb, force_file=force_document and not is_image, - ttl_seconds=ttl + ttl_seconds=ttl, + nosound_video=nosound_video ) return file_handle, media, as_image