]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/utils.py
[skeb] Add extractor (#1916)
[yt-dlp.git] / yt_dlp / utils.py
index 15cc4d3b2c94ef20a51f147be7c96cc7293ac536..9d400605165665b6387904a247f67c6624de12f3 100644 (file)
@@ -38,6 +38,7 @@
 import traceback
 import xml.etree.ElementTree
 import zlib
+import mimetypes
 
 from .compat import (
     compat_HTMLParseError,
@@ -4715,6 +4716,14 @@ def mimetype2ext(mt):
     return subtype.replace('+', '.')
 
 
+def ext2mimetype(ext_or_url):
+    if not ext_or_url:
+        return None
+    if '.' not in ext_or_url:
+        ext_or_url = f'file.{ext_or_url}'
+    return mimetypes.guess_type(ext_or_url)[0]
+
+
 def parse_codecs(codecs_str):
     # http://tools.ietf.org/html/rfc6381
     if not codecs_str: