fix thumbnail for TDesktop and Telegram X users

This commit is contained in:
Shrimadhav U K 2021-01-17 19:54:43 +05:30
parent 00aa0a4bf1
commit cf84991872
2 changed files with 12 additions and 3 deletions

View File

@ -699,7 +699,8 @@ class UploadMethods:
force_document=force_document and not is_image,
voice_note=voice_note,
video_note=video_note,
supports_streaming=supports_streaming
supports_streaming=supports_streaming,
thumb=thumb
)
if not thumb:

View File

@ -664,7 +664,7 @@ def _get_metadata(file):
def get_attributes(file, *, attributes=None, mime_type=None,
force_document=False, voice_note=False, video_note=False,
supports_streaming=False):
supports_streaming=False, thumb=None):
"""
Get a list of attributes for the given file and
the mime type as a tuple ([attribute], mime_type).
@ -700,9 +700,17 @@ def get_attributes(file, *, attributes=None, mime_type=None,
if m.has('duration') else 0),
supports_streaming=supports_streaming
)
elif thumb:
t_m = _get_metadata(thumb)
width = 1
height = 1
if t_m and t_m.has("width"):
width = t_m.get("width")
if t_m and t_m.has("height"):
height = t_m.get("height")
else:
doc = types.DocumentAttributeVideo(
0, 1, 1, round_message=video_note,
0, width, height, round_message=video_note,
supports_streaming=supports_streaming)
attr_dict[types.DocumentAttributeVideo] = doc