From c49c8c0ce665b2f5e66f99e009490547451ca4e8 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 4 Apr 2018 22:23:20 +0200 Subject: [PATCH] Handle Audio type --- pyrogram/client/utils.py | 70 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/pyrogram/client/utils.py b/pyrogram/client/utils.py index 98f605a5..196e795b 100644 --- a/pyrogram/client/utils.py +++ b/pyrogram/client/utils.py @@ -84,6 +84,35 @@ def parse_channel_chat(channel: types.Channel): ) +def parse_thumb(thumb: types.PhotoSize or types.PhotoCachedSize): + if isinstance(thumb, (types.PhotoSize, types.PhotoCachedSize)): + loc = thumb.location + + if isinstance(thumb, types.PhotoSize): + file_size = thumb.size + else: + file_size = len(thumb.bytes) + + if isinstance(loc, types.FileLocation): + return pyrogram.PhotoSize( + file_id=encode( + pack( + "