From 3049e6e63be0bb78880e8bad85fa4e2066e7bd52 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Thu, 29 Feb 2024 21:37:46 +0700 Subject: [PATCH] Pyrofork: Fix NoneType error when sending video as media group Signed-off-by: wulan17 --- pyrogram/methods/messages/send_media_group.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pyrogram/methods/messages/send_media_group.py b/pyrogram/methods/messages/send_media_group.py index ef1d888f..65cf6f22 100644 --- a/pyrogram/methods/messages/send_media_group.py +++ b/pyrogram/methods/messages/send_media_group.py @@ -217,6 +217,17 @@ class SendMediaGroup: else: if not any([track.track_type == 'Audio' for track in videoInfo.tracks]): is_animation = True + attributes = [ + raw.types.DocumentAttributeVideo( + supports_streaming=True if is_animation else (i.supports_streaming or None), + duration=i.duration, + w=i.width, + h=i.height + ), + raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)) + ] + if is_animation: + attributes.append(raw.types.DocumentAttributeAnimated()) media = await self.invoke( raw.functions.messages.UploadMedia( peer=await self.resolve_peer(chat_id), @@ -226,16 +237,7 @@ class SendMediaGroup: spoiler=i.has_spoiler, mime_type=self.guess_mime_type(i.media) or "video/mp4", nosound_video=is_animation, - attributes=[ - raw.types.DocumentAttributeVideo( - supports_streaming=True if is_animation else (i.supports_streaming or None), - duration=i.duration, - w=i.width, - h=i.height - ), - raw.types.DocumentAttributeFilename(file_name=os.path.basename(i.media)), - raw.types.DocumentAttributeAnimated() if is_animation else None - ] + attributes=attributes ) ) )