mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 18:46:40 +00:00
Fix thumbnail for TDesktop and Telegram X users (#1673)
This commit is contained in:
parent
00aa0a4bf1
commit
3ddb0a3903
@ -699,7 +699,8 @@ class UploadMethods:
|
|||||||
force_document=force_document and not is_image,
|
force_document=force_document and not is_image,
|
||||||
voice_note=voice_note,
|
voice_note=voice_note,
|
||||||
video_note=video_note,
|
video_note=video_note,
|
||||||
supports_streaming=supports_streaming
|
supports_streaming=supports_streaming,
|
||||||
|
thumb=thumb
|
||||||
)
|
)
|
||||||
|
|
||||||
if not thumb:
|
if not thumb:
|
||||||
|
@ -664,7 +664,7 @@ def _get_metadata(file):
|
|||||||
|
|
||||||
def get_attributes(file, *, attributes=None, mime_type=None,
|
def get_attributes(file, *, attributes=None, mime_type=None,
|
||||||
force_document=False, voice_note=False, video_note=False,
|
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
|
Get a list of attributes for the given file and
|
||||||
the mime type as a tuple ([attribute], mime_type).
|
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),
|
if m.has('duration') else 0),
|
||||||
supports_streaming=supports_streaming
|
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:
|
else:
|
||||||
doc = types.DocumentAttributeVideo(
|
doc = types.DocumentAttributeVideo(
|
||||||
0, 1, 1, round_message=video_note,
|
0, 1, 1, round_message=video_note,
|
||||||
|
Loading…
Reference in New Issue
Block a user