mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-18 04:20:57 +03:00
Fix get_extension missing even more photo cases
This commit is contained in:
parent
86cdb7c1f8
commit
35ba9848d9
|
@ -106,9 +106,13 @@ def get_extension(media):
|
||||||
"""Gets the corresponding extension for any Telegram media."""
|
"""Gets the corresponding extension for any Telegram media."""
|
||||||
|
|
||||||
# Photos are always compressed as .jpg by Telegram
|
# Photos are always compressed as .jpg by Telegram
|
||||||
if isinstance(media, (types.UserProfilePhoto,
|
try:
|
||||||
types.ChatPhoto, types.MessageMediaPhoto)):
|
get_input_photo(media)
|
||||||
return '.jpg'
|
return '.jpg'
|
||||||
|
except TypeError:
|
||||||
|
# These cases are not handled by input photo because it can't
|
||||||
|
if isinstance(media, (types.UserProfilePhoto, types.ChatPhoto)):
|
||||||
|
return '.jpg'
|
||||||
|
|
||||||
# Documents will come with a mime type
|
# Documents will come with a mime type
|
||||||
if isinstance(media, types.MessageMediaDocument):
|
if isinstance(media, types.MessageMediaDocument):
|
||||||
|
@ -290,7 +294,10 @@ def get_input_photo(photo):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
_raise_cast_fail(photo, 'InputPhoto')
|
_raise_cast_fail(photo, 'InputPhoto')
|
||||||
|
|
||||||
if isinstance(photo, types.photos.Photo):
|
if isinstance(photo, types.Message):
|
||||||
|
photo = photo.media
|
||||||
|
|
||||||
|
if isinstance(photo, (types.photos.Photo, types.MessageMediaPhoto)):
|
||||||
photo = photo.photo
|
photo = photo.photo
|
||||||
|
|
||||||
if isinstance(photo, types.Photo):
|
if isinstance(photo, types.Photo):
|
||||||
|
@ -302,6 +309,7 @@ def get_input_photo(photo):
|
||||||
|
|
||||||
if isinstance(photo, types.messages.ChatFull):
|
if isinstance(photo, types.messages.ChatFull):
|
||||||
photo = photo.full_chat
|
photo = photo.full_chat
|
||||||
|
|
||||||
if isinstance(photo, types.ChannelFull):
|
if isinstance(photo, types.ChannelFull):
|
||||||
return get_input_photo(photo.chat_photo)
|
return get_input_photo(photo.chat_photo)
|
||||||
elif isinstance(photo, types.UserFull):
|
elif isinstance(photo, types.UserFull):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user