From 61011ecea0eb86f50813d39a9172e86d417c1c0d Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 2 Oct 2025 09:53:51 +0200 Subject: [PATCH] use ayon api implementation of mime type --- client/ayon_core/lib/transcoding.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index b3958863fe..dd44d4a673 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -1519,12 +1519,24 @@ def get_media_mime_type(filepath: str) -> Optional[str]: Optional[str]: Mime type or None if is unknown mime type. """ + try: + from ayon_api.utils import ( + get_media_mime_type_for_content as _ayon_api_func + ) + except ImportError: + _ayon_api_func = None + if not filepath or not os.path.exists(filepath): return None with open(filepath, "rb") as stream: content = stream.read() + if _ayon_api_func is not None: + mime_type = _ayon_api_func(content) + if mime_type is not None: + return mime_type + content_len = len(content) # Pre-validation (largest definition check) # - hopefully there cannot be media defined in less than 12 bytes