Fixed loss of thumbnails after media editing. (#216)

This commit is contained in:
23rd 2019-02-11 13:07:02 +03:00 committed by Dan
parent c05e008656
commit 69f347ddec

View File

@ -123,6 +123,7 @@ class EditMessageMedia(BaseClient):
peer=self.resolve_peer(chat_id), peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media), file=self.save_file(media.media),
attributes=[ attributes=[
types.DocumentAttributeVideo( types.DocumentAttributeVideo(
@ -179,6 +180,7 @@ class EditMessageMedia(BaseClient):
peer=self.resolve_peer(chat_id), peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + media.media.split(".")[-1], "audio/mpeg"), mime_type=mimetypes.types_map.get("." + media.media.split(".")[-1], "audio/mpeg"),
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media), file=self.save_file(media.media),
attributes=[ attributes=[
types.DocumentAttributeAudio( types.DocumentAttributeAudio(
@ -234,6 +236,7 @@ class EditMessageMedia(BaseClient):
peer=self.resolve_peer(chat_id), peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media), file=self.save_file(media.media),
attributes=[ attributes=[
types.DocumentAttributeVideo( types.DocumentAttributeVideo(
@ -291,6 +294,7 @@ class EditMessageMedia(BaseClient):
peer=self.resolve_peer(chat_id), peer=self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + media.media.split(".")[-1], "text/plain"), mime_type=mimetypes.types_map.get("." + media.media.split(".")[-1], "text/plain"),
thumb=None if media.thumb is None else self.save_file(media.thumb),
file=self.save_file(media.media), file=self.save_file(media.media),
attributes=[ attributes=[
types.DocumentAttributeFilename(os.path.basename(media.media)) types.DocumentAttributeFilename(os.path.basename(media.media))