From 70ef93a62ecf1a5aadb87276e8c2d3c4a48e38db Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 11 Mar 2018 09:38:52 +0100 Subject: [PATCH] Stop treating image/webp as images as Telegram throws error --- telethon/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 8e37714e..daf8c875 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -55,9 +55,6 @@ def get_display_name(entity): return '' -# For some reason, .webp (stickers' format) is not registered -add_type('image/webp', '.webp') - def get_extension(media): """Gets the corresponding extension for any Telegram media""" @@ -319,8 +316,10 @@ def get_input_media(media, is_photo=False): def is_image(file): """Returns True if the file extension looks like an image file""" - return (isinstance(file, str) and - (mimetypes.guess_type(file)[0] or '').startswith('image/')) + if not isinstance(file, str): + return False + mime = mimetypes.guess_type(file)[0] or '' + return mime.startswith('image/') and not mime.endswith('/webp') def is_audio(file):