From d493ac15b1959f00d7bc37ee0b010d746c93d198 Mon Sep 17 00:00:00 2001 From: Allerter <45076212+Allerter@users.noreply.github.com> Date: Wed, 2 Sep 2020 17:22:20 +0430 Subject: [PATCH] fixed issue where is_video returns False for byte array/stream videos --- telethon/utils.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/telethon/utils.py b/telethon/utils.py index 8ddf282f..fd26dc52 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -815,9 +815,16 @@ def is_audio(file): def is_video(file): - """Returns `True` if the file extension looks like a video file.""" - file = 'a' + _get_extension(file) - return (mimetypes.guess_type(file)[0] or '').startswith('video/') + """Returns `True` if the file has a video mime type.""" + filename = 'a' + _get_extension(file) + if filename == 'a': + metadata = _get_metadata(file) + if metadata and metadata.has('mime_type'): + return metadata.get('mime_type').startswith('video/') + else: + return False + else: + return (mimetypes.guess_type(filename)[0] or '').startswith('video/') def is_list_like(obj):