Fix thumbnail for TDesktop and Telegram X users (#1673)

This commit is contained in:
Shrimadhav U K 2021-01-17 22:01:26 +05:30 committed by GitHub
parent 00aa0a4bf1
commit 3ddb0a3903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 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,6 +700,18 @@ 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")
doc = types.DocumentAttributeVideo(
0, width, height, round_message=video_note,
supports_streaming=supports_streaming)
else:
doc = types.DocumentAttributeVideo(
0, 1, 1, round_message=video_note,