From d1fee278146940d5cdb825223dc19bb4f900d54a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 23 Jan 2019 14:37:28 +0100 Subject: [PATCH] Register several known mimetypes (#1096) --- telethon/utils.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 8a9da202..d5e38a43 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -25,10 +25,26 @@ try: except ImportError: hachoir = None -# .webp (stickers) and .ogg (some voice notes) mimetypes are unknown on some -# operative systems. Manually register them here to make them work everywhere. +# Register some of the most common mime-types to avoid any issues. +# See https://github.com/LonamiWebs/Telethon/issues/1096. +mimetypes.add_type('image/png', '.png') +mimetypes.add_type('image/jpeg', '.jpeg') mimetypes.add_type('image/webp', '.webp') +mimetypes.add_type('image/gif', '.gif') +mimetypes.add_type('image/bmp', '.bmp') +mimetypes.add_type('image/x-tga', '.tga') +mimetypes.add_type('image/tiff', '.tiff') +mimetypes.add_type('image/vnd.adobe.photoshop', '.psd') + +mimetypes.add_type('video/mp4', '.mp4') +mimetypes.add_type('video/quicktime', '.mov') +mimetypes.add_type('video/avi', '.avi') + +mimetypes.add_type('audio/mp3', '.mp3') +mimetypes.add_type('audio/m4a', '.m4a') +mimetypes.add_type('audio/aac', '.aac') mimetypes.add_type('audio/ogg', '.ogg') +mimetypes.add_type('audio/flac', '.flac') USERNAME_RE = re.compile( r'@|(?:https?://)?(?:www\.)?(?:telegram\.(?:me|dog)|t\.me)/(joinchat/)?'