diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py index d79ecfbe..02b9062d 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -17,6 +17,7 @@ # along with Pyrogram. If not, see . import binascii +import mimetypes import os import struct @@ -24,7 +25,7 @@ from pyrogram.api import functions, types from pyrogram.api.errors import FileIdInvalid from pyrogram.client.ext import BaseClient, utils from pyrogram.client.types import ( - InputMediaPhoto + InputMediaPhoto, InputMediaVideo ) @@ -81,6 +82,34 @@ class EditMessageMedia(BaseClient): ) ) + if isinstance(media, InputMediaVideo): + if os.path.exists(media.media): + media = self.send( + functions.messages.UploadMedia( + peer=self.resolve_peer(chat_id), + media=types.InputMediaUploadedDocument( + mime_type=mimetypes.types_map[".mp4"], + file=self.save_file(media.media), + attributes=[ + types.DocumentAttributeVideo( + supports_streaming=media.supports_streaming or None, + duration=media.duration, + w=media.width, + h=media.height + ), + types.DocumentAttributeFilename(os.path.basename(media.media)) + ] + ) + ) + ) + + media = types.InputMediaDocument( + id=types.InputDocument( + id=media.document.id, + access_hash=media.document.access_hash + ) + ) + r = self.send( functions.messages.EditMessage( peer=self.resolve_peer(chat_id),